diff --git a/controllers/forms.js b/controllers/forms.js index aedf8596..3ecf844c 100644 --- a/controllers/forms.js +++ b/controllers/forms.js @@ -210,8 +210,41 @@ router.post('/board/:board/post', Boards.exists, banCheck, paramConverter, verif }); +//board settings +router.post('/board/:board/settings', Boards.exists, checkPermsMiddleware, paramConverter, async (req, res, next) => { + + const errors = []; + + if (req.body.default_name && req.body.default_name.length > 20) { + errors.push('Must provide a message or file'); + } + if (typeof req.body.reply_limit === 'number' && (req.body.reply_limit < 1 || req.body.reply_limit > 1000)) { + errors.push('Reply Limit must be from 1-1000'); + } + if (typeof req.body.thread_limit === 'number' && (req.body.thread_limit < 1 || req.body.thread_limit > 250)) { + errors.push('Threads Limit must be 1-250'); + } + if (typeof req.body.max_files === 'number' && (req.body.max_files < 1 || req.body.max_files > 3)) { + errors.push('Max files must be 1-3'); + } + + if (errors.length > 0) { + return res.status(400).render('message', { + 'title': 'Bad request', + 'errors': errors, + 'redirect': `/${req.params.board}/manage` + }) + } + + return res.status(501).render('message', { + 'title': 'Not implemented', + 'redirect': `/${req.params.board}/manage` + }) + +}); + //upload banners -router.post('/board/:board/addbanners', Boards.exists, banCheck, checkPermsMiddleware, paramConverter, async (req, res, next) => { +router.post('/board/:board/addbanners', Boards.exists, checkPermsMiddleware, paramConverter, async (req, res, next) => { let numFiles = 0; if (req.files && req.files.file) { @@ -247,7 +280,7 @@ router.post('/board/:board/addbanners', Boards.exists, banCheck, checkPermsMiddl }); //delete banners -router.post('/board/:board/deletebanners', Boards.exists, banCheck, checkPermsMiddleware, paramConverter, async (req, res, next) => { +router.post('/board/:board/deletebanners', Boards.exists, checkPermsMiddleware, paramConverter, async (req, res, next) => { const errors = []; @@ -522,7 +555,7 @@ router.post('/board/:board/actions', Boards.exists, banCheck, paramConverter, ve router.post('/board/:board/modactions', Boards.exists, checkPermsMiddleware, paramConverter, actions); //unban -router.post('/board/:board/unban', Boards.exists, banCheck, checkPermsMiddleware, paramConverter, async (req, res, next) => { +router.post('/board/:board/unban', Boards.exists, checkPermsMiddleware, paramConverter, async (req, res, next) => { //keep this for later in case i add other options to unbans const errors = []; diff --git a/gulp/res/css/style.css b/gulp/res/css/style.css index bc8ebed4..4b00f618 100644 --- a/gulp/res/css/style.css +++ b/gulp/res/css/style.css @@ -301,6 +301,7 @@ td, th { overflow: hidden; max-width: 160px; text-overflow: ellipsis; + word-break: keep-all; } .post-file-src { @@ -352,8 +353,6 @@ input textarea { } .post-message { - /*overflow-y: auto;*/ - /*float: left;*/ text-align: left; } diff --git a/helpers/paramconverter.js b/helpers/paramconverter.js index 795cf377..1df6a26a 100644 --- a/helpers/paramconverter.js +++ b/helpers/paramconverter.js @@ -4,36 +4,57 @@ const Mongo = require(__dirname+'/../db/db.js'); module.exports = (req, res, next) => { - //for body - if (req.body.thread) { - req.body.thread = +req.body.thread; - } + //convert to numbers of mongoIds for action routes if (req.body.checkedposts) { - //syntax tries to convert all string to number req.body.checkedposts = req.body.checkedposts.map(Number); } if (req.body.globalcheckedposts) { req.body.globalcheckedposts = req.body.globalcheckedposts.map(Mongo.ObjectId) } - //and for params + //thread in post form if (req.params.id) { req.params.id = +req.params.id; } - if (req.params.page) { - req.params.page = +req.params.page; + if (req.body.thread) { + req.body.thread = +req.body.thread; } - //and query + //page number if (req.query.p) { - const pnum = +req.query.p; - if (Number.isSafeInteger(pnum)) { - req.query.p = +req.query.p; + const num = parseInt(req.query.p); + if (Number.isSafeInteger(num)) { + req.query.p = num; } else { req.query.p = null; } } + //board settings + if (req.body.reply_limit != null) { + const num = parseInt(req.body.reply_limit); + if (Number.isSafeInteger(num)) { + req.body.reply_limit = num; + } else { + req.body.reply_limit = null; + } + } + if (req.body.max_files != null) { + const num = parseInt(req.body.max_files); + if (Number.isSafeInteger(num)) { + req.body.max_files = num; + } else { + req.body.max_files = null; + } + } + if (req.body.thread_limit != null) { + const num = +parseInt(req.body.thread_limit); + if (Number.isSafeInteger(num)) { + req.body.thread_limit = num; + } else { + req.body.thread_limit = null; + } + } next(); } diff --git a/views/pages/globalmanage.pug b/views/pages/globalmanage.pug index faedc003..20ce3b41 100644 --- a/views/pages/globalmanage.pug +++ b/views/pages/globalmanage.pug @@ -7,20 +7,21 @@ block head block content h1.board-title Global Management - h4 All Reports: - form(action=`/forms/global/actions` method='POST' enctype='application/x-www-form-urlencoded') - input(type='hidden' name='_csrf' value=csrf) - if reports.length === 0 - p No reports. - hr(size=1) - else - for report in reports - section.thread - +post(report, false, false, true) + h4.no-m-p Reports: + .mv-10 + form(action=`/forms/global/actions` method='POST' enctype='application/x-www-form-urlencoded') + input(type='hidden' name='_csrf' value=csrf) + if reports.length === 0 + p No reports. hr(size=1) - include ../includes/actionfooter_globalmanage.pug - hr(size=1) - h4 All Bans: + else + for report in reports + section.thread + +post(report, false, false, true) + hr(size=1) + include ../includes/actionfooter_globalmanage.pug + hr(size=1) + h4.no-m-p Bans: form(action=`/forms/global/unban` method='POST' enctype='application/x-www-form-urlencoded') input(type='hidden' name='_csrf' value=csrf) if bans.length === 0 @@ -33,3 +34,5 @@ block content hr(size=1) section.action-wrapper input(type='submit', value='unban') + +