allow empty title

This commit is contained in:
Daniella / Tove 2023-03-19 16:23:42 +01:00
parent a724192fb0
commit 70ac7de23f
Signed by: TudbuT
GPG key ID: 7D63D5634B7C417F
2 changed files with 5 additions and 3 deletions

View file

@ -44,7 +44,8 @@ server.all('/', function get(req, res) {
for (let i = Math.max(0, posts.length - 2000); i < posts.length; i++) {
mainPage.comments.push({timestamp: posts[i].timestamp, author: posts[i].author, title: posts[i].title, content: posts[i].content, comments: []})
}
if(req.body.name && req.body.title && req.body.content) {
if(req.body.name && req.body.content) {
if(!req.body.title) req.body.title = '';
let post = {timestamp: new Date().getTime(), author: req.body.name, title: req.body.title, content: req.body.content.replaceAll('\r\n', '\n'), comments: []}
if(fake) {
mainPage.comments.push(post)
@ -108,7 +109,8 @@ server.all('/comment', function get(req, res) {
res.render('post.ejs', {post: posts[id], postid: id, webname: webname, email: email, comment: cid, fake: fake})
}
else {
if(req.body.name && req.body.title && req.body.content) {
if(req.body.name && req.body.content) {
if(!req.body.title) req.body.title = '';
let p = {timestamp: new Date().getTime(), author: req.body.name, title: req.body.title, content: req.body.content.replaceAll('\r\n', '\n'), comments: []}
posts[id].comments.push(p)
if(fake) {

View file

@ -137,7 +137,7 @@
`</div></div><post><div class="content"><form method="post">` +
`<h3>` +
`<input type="username" name="name" ${fake ? `value="${post.comments[post.comments.length - 1].author.replaceAll("&", "&amp;").replaceAll("\"", "&quot;")}"` : 'value="Anonymous"'} required>: ` +
`<input type="" name="title" placeholder="Title" ${fake ? `value="${post.comments[post.comments.length - 1].title.replaceAll("&", "&amp;").replaceAll("\"", "&quot;")}"` : ''} required>` +
`<input type="text" autocomplete="off" name="title" placeholder="Title" ${fake ? `value="${post.comments[post.comments.length - 1].title.replaceAll("&", "&amp;").replaceAll("\"", "&quot;")}"` : ''}>` +
`</h3>` +
`<textarea id=edit name="content" placeholder="So basically, ..." required>` +
(fake ? post.comments[post.comments.length - 1].content.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;") : '') +