allow empty title
This commit is contained in:
parent
a724192fb0
commit
70ac7de23f
2 changed files with 5 additions and 3 deletions
6
index.js
6
index.js
|
@ -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) {
|
||||
|
|
|
@ -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("&", "&").replaceAll("\"", """)}"` : 'value="Anonymous"'} required>: ` +
|
||||
`<input type="" name="title" placeholder="Title" ${fake ? `value="${post.comments[post.comments.length - 1].title.replaceAll("&", "&").replaceAll("\"", """)}"` : ''} required>` +
|
||||
`<input type="text" autocomplete="off" name="title" placeholder="Title" ${fake ? `value="${post.comments[post.comments.length - 1].title.replaceAll("&", "&").replaceAll("\"", """)}"` : ''}>` +
|
||||
`</h3>` +
|
||||
`<textarea id=edit name="content" placeholder="So basically, ..." required>` +
|
||||
(fake ? post.comments[post.comments.length - 1].content.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">") : '') +
|
||||
|
|
Loading…
Add table
Reference in a new issue