view improvements and enforce URL format

merge-requests/208/head
fatchan 5 years ago
parent b113210b47
commit 8c858ba018
  1. 2
      controllers/api.js
  2. 9
      controllers/frontend.js
  3. 9
      views/mixins/post.pug
  4. 13
      views/pages/board.pug
  5. 15
      views/pages/thread.pug

@ -47,7 +47,7 @@ router.get('/api/board/:board/recent/:page', Posts.checkBoard, async (req, res,
});
// get a thread
router.get('/api/board/:board/thread/:thread', Posts.checkBoard, async (req, res, next) => {
router.get('/api/board/:board/thread/:thread([a-f\d]{24})', Posts.checkBoard, async (req, res, next) => {
//get the recently bumped thread & preview posts
let thread;

@ -38,7 +38,7 @@ router.get('/:board/:page?', Posts.checkBoard, async (req, res, next) => {
});
// thread view page
router.get('/:board/thread/:thread', Posts.checkBoard, async (req, res, next) => {
router.get('/:board/thread/:thread([a-f\\d]{24})', Posts.checkBoard, async (req, res, next) => {
//get the recently bumped thread & preview posts
let thread;
@ -48,15 +48,18 @@ router.get('/:board/thread/:thread', Posts.checkBoard, async (req, res, next) =>
return next(err);
}
if (!thread) {
return res.status(404).render('404');
}
//render the page
res.render('thread', {
csrf: req.csrfToken(),
board: req.params.board,
threads: [thread] || []
thread: thread
});
});
module.exports = router;

@ -0,0 +1,9 @@
mixin post(board, post)
.post-container
if post.thread == null
a(href=`/${board}/thread/${post._id}`) #{post._id}
else
a(href=`/${board}/thread/${post.thread}#${post._id}`) #{post._id}
span , #{post.author}
span , #{post.date}
p #{post.content}

@ -1,20 +1,15 @@
extends ../layout.pug
include ../mixins/post.pug
block head
title /#{board}/
block content
hr
for thread in threads
h1 OP:
div #{thread._id}
div #{thread.author}
div #{thread.date}
div #{thread.content}
+post(board, thread)
h1 Replies:
for post in thread.replies
div #{post._id}
div #{post.author}
div #{post.date}
div #{post.content}
br
+post(board, post)
hr

@ -1,20 +1,13 @@
extends ../layout.pug
include ../mixins/post.pug
block head
title /#{board}/
title /#{board}/ - title placeholder
block content
for thread in threads
h1 OP:
div #{thread._id}
div #{thread.author}
div #{thread.date}
div #{thread.content}
+post(board, thread)
h1 Replies:
for post in thread.replies
div #{post._id}
div #{post.author}
div #{post.date}
div #{post.content}
br
+post(board, post)
hr

Loading…
Cancel
Save