improve new settings handling, more options, change manage page styling

merge-requests/208/head
fatchan 5 years ago
parent 281dba8819
commit 0e3c6ede2b
  1. 1
      controllers/forms.js
  2. 11
      gulp/res/css/style.css
  3. 1
      helpers/captchaverify.js
  4. 8
      models/forms/make-post.js
  5. 21
      views/includes/bannerform.pug
  6. 4
      views/includes/postform.pug
  7. 2
      views/pages/changepassword.pug
  8. 2
      views/pages/home.pug
  9. 2
      views/pages/login.pug
  10. 58
      views/pages/manage.pug
  11. 2
      views/pages/register.pug
  12. 6
      wipe.js

@ -171,6 +171,7 @@ router.post('/board/:board/post', Boards.exists, banCheck, paramConverter, verif
numFiles = req.files.file.size > 0 ? 1 : 0; numFiles = req.files.file.size > 0 ? 1 : 0;
req.files.file = [req.files.file]; req.files.file = [req.files.file];
} }
numFiles = Math.min(numFiles, res.locals.board.settings.maxFiles)
} }
const errors = []; const errors = [];

@ -34,6 +34,12 @@ body {
.mr-5 { .mr-5 {
margin-right: 5px; margin-right: 5px;
} }
.mv-10 {
margin: 10px 0;
}
.mb-10 {
margin-bottom: 10px;
}
.ph-5 { .ph-5 {
padding: 0 5px; padding: 0 5px;
} }
@ -194,9 +200,8 @@ td, th {
text-align: left; text-align: left;
} }
.form-wrapper, .table-container { .flex-center {
align-items: center; align-items: center;
margin: 10px 0;
} }
.post-container, .pages, .toggle-label { .post-container, .pages, .toggle-label {
@ -248,7 +253,7 @@ td, th {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
max-width: 100%; max-width: 100%;
margin-top: 10px; /*margin-top: 10px;*/
} }
.togglable { .togglable {

@ -27,7 +27,6 @@ module.exports = async (req, res, next) => {
}); });
} }
// try to get the captcha from the DB // try to get the captcha from the DB
let captcha; let captcha;
try { try {

@ -71,7 +71,7 @@ module.exports = async (req, res, next, numFiles) => {
// if we got a file // if we got a file
if (numFiles > 0) { if (numFiles > 0) {
// check all mime types befoer we try saving anything // check all mime types befoer we try saving anything
for (let i = 0; i < res.locals.board.settings.maxImages; i++) { for (let i = 0; i < numFiles; i++) {
if (!fileCheckMimeType(req.files.file[i].mimetype, {image: true, video: true})) { if (!fileCheckMimeType(req.files.file[i].mimetype, {image: true, video: true})) {
return res.status(400).render('message', { return res.status(400).render('message', {
'title': 'Bad request', 'title': 'Bad request',
@ -166,7 +166,7 @@ module.exports = async (req, res, next, numFiles) => {
//forceanon only allow sage email //forceanon only allow sage email
let email = hasPerms || !forceAnon || req.body.email === 'sage' ? req.body.email : null; let email = hasPerms || !forceAnon || req.body.email === 'sage' ? req.body.email : null;
let name = res.locals.board.settins.defaultName; let name = res.locals.board.settings.defaultName;
let tripcode = null; let tripcode = null;
let capcode = null; let capcode = null;
if ((hasPerms || !forceAnon) && req.body.name && req.body.name.length > 0) { if ((hasPerms || !forceAnon) && req.body.name && req.body.name.length > 0) {
@ -233,9 +233,9 @@ module.exports = async (req, res, next, numFiles) => {
let postId; let postId;
try { try {
postId = await Posts.insertOne(res.locals.board, data, thread); postId = await Posts.insertOne(req.params.board, data, thread);
if (!data.thread) { //if we just added a new thread, prune anyold ones if (!data.thread) { //if we just added a new thread, prune anyold ones
await module.exports.pruneOldThreads(req.params.board, res.locals.board.settings.threadLimit); await Posts.pruneOldThreads(req.params.board, res.locals.board.settings.threadLimit);
} }
} catch (err) { } catch (err) {
return next(err); return next(err);

@ -1,21 +0,0 @@
section.form-wrapper
label.toggle-label Add Banners
input.toggle(type='checkbox')
form.form-post.togglable(action=`/forms/board/${board._id}/addbanners`, enctype='multipart/form-data', method='POST')
input(type='hidden' name='_csrf' value=csrf)
section.postform-section
span.fileupload
input#file(type='file', name='file' multiple)
input(type='submit', value='submit')
section.form-wrapper
label.toggle-label Delete Banners
input.toggle(type='checkbox')
form.form-post.togglable(action=`/forms/board/${board._id}/deletebanners`, enctype='application/x-www-form-urlencoded', method='POST')
input(type='hidden' name='_csrf' value=csrf)
each banner in board.banners
label.banner-check
input(type='checkbox' name='checkedbanners[]' value=banner)
object.board-banner(data=`/banner/${banner}` width='300' height='100')
input(type='submit', value='submit')

@ -1,11 +1,11 @@
section.form-wrapper section.form-wrapper.flex-center.mv-10
form.form-post(action=`/forms/board/${board._id}/post`, enctype='multipart/form-data', method='POST') form.form-post(action=`/forms/board/${board._id}/post`, enctype='multipart/form-data', method='POST')
input(type='hidden' name='_csrf' value=csrf) input(type='hidden' name='_csrf' value=csrf)
input(type='hidden' name='thread' value=thread != null ? thread.postId : null) input(type='hidden' name='thread' value=thread != null ? thread.postId : null)
unless board.settings.forceAnon unless board.settings.forceAnon
section.postform-row section.postform-row
.postform-label Name .postform-label Name
input#name(type='text', name='name', placeholder='Anonymous' autocomplete='off' maxlength='50') input#name(type='text', name='name', placeholder=board.defaultName autocomplete='off' maxlength='50')
section.postform-row section.postform-row
.postform-label Subject .postform-label Subject
input#title(type='text', name='subject', autocomplete='off' maxlength='50') input#title(type='text', name='subject', autocomplete='off' maxlength='50')

@ -4,7 +4,7 @@ block head
title Change Password title Change Password
block content block content
section.form-wrapper section.form-wrapper.flex-center.mv-10
form.form-post(action='/forms/changepassword' method='POST') form.form-post(action='/forms/changepassword' method='POST')
input(type='hidden' name='_csrf' value=csrf) input(type='hidden' name='_csrf' value=csrf)
section.postform-row section.postform-row

@ -5,7 +5,7 @@ block head
block content block content
h1.board-title Board List h1.board-title Board List
.table-container .table-container.flex-center.mv-10
table.table-body table.table-body
tr.table-head tr.table-head
th Board th Board

@ -4,7 +4,7 @@ block head
title Login title Login
block content block content
section.form-wrapper section.form-wrapper.flex-center.mv-10
form.form-post(action='/forms/login' method='POST') form.form-post(action='/forms/login' method='POST')
input(type='hidden' name='_csrf' value=csrf) input(type='hidden' name='_csrf' value=csrf)
input(type='hidden' name='redirect' value=redirect) input(type='hidden' name='redirect' value=redirect)

@ -7,8 +7,8 @@ block head
block content block content
include ../includes/boardheader.pug include ../includes/boardheader.pug
h4 Settings: h4.no-m-p Settings:
section.form-wrapper section.form-wrapper.flexleft.mv-10
form.form-post(action=`/forms/board/${board._id}/settings` method='POST' enctype='application/x-www-form-urlencoded') form.form-post(action=`/forms/board/${board._id}/settings` method='POST' enctype='application/x-www-form-urlencoded')
input(type='hidden' name='_csrf' value=csrf) input(type='hidden' name='_csrf' value=csrf)
section.postform-row section.postform-row
@ -31,25 +31,45 @@ block content
.postform-label Reply Limit .postform-label Reply Limit
input(type='text' name='reply_limit' placeholder=board.settings.replyLimit) input(type='text' name='reply_limit' placeholder=board.settings.replyLimit)
section.postform-row section.postform-row
.postform-label Max Images .postform-label Max Files
input(type='text' name='max_images' placeholder=board.settings.maxImages) input(type='text' name='max_files' placeholder=board.settings.maxFiles)
input(type='submit', value='save settings') input(type='submit', value='save settings')
h4 Banners: hr(size=1)
include ../includes/bannerform.pug h4.no-m-p Add Banners:
h4 Reports: section.form-wrapper.flexleft.mv-10
form(action=`/forms/board/${board._id}/modactions` method='POST' enctype='application/x-www-form-urlencoded') form.form-post(action=`/forms/board/${board._id}/addbanners`, enctype='multipart/form-data', method='POST')
input(type='hidden' name='_csrf' value=csrf) input(type='hidden' name='_csrf' value=csrf)
if reports.length === 0 section.postform-row
p No reports. .postform-label Upload
hr(size=1) input#file(type='file', name='file' multiple)
else input(type='submit', value='submit')
for report in reports hr(size=1)
section.thread if board.banners.length > 0
+post(report, false, true) h4.no-m-p Delete Banners:
section.form-wrapper.flexleft.mv-10
form.form-post(action=`/forms/board/${board._id}/deletebanners`, enctype='application/x-www-form-urlencoded', method='POST')
input(type='hidden' name='_csrf' value=csrf)
each banner in board.banners
label.banner-check
input(type='checkbox' name='checkedbanners[]' value=banner)
object.board-banner(data=`/banner/${banner}` width='300' height='100')
input(type='submit', value='delete')
hr(size=1)
h4.no-m-p Reports:
.mv-10
form(action=`/forms/board/${board._id}/modactions` 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) hr(size=1)
include ../includes/actionfooter_manage.pug else
hr(size=1) for report in reports
h4 Bans: section.thread
+post(report, false, true)
hr(size=1)
include ../includes/actionfooter_manage.pug
hr(size=1)
h4.no-m-p Bans:
form(action=`/forms/board/${board._id}/unban` method='POST' enctype='application/x-www-form-urlencoded') form(action=`/forms/board/${board._id}/unban` method='POST' enctype='application/x-www-form-urlencoded')
input(type='hidden' name='_csrf' value=csrf) input(type='hidden' name='_csrf' value=csrf)
if bans.length === 0 if bans.length === 0

@ -4,7 +4,7 @@ block head
title Register title Register
block content block content
section.form-wrapper section.form-wrapper.flex-center.mv-10
form.form-post(action='/forms/register' method='POST') form.form-post(action='/forms/register' method='POST')
input(type='hidden' name='_csrf' value=csrf) input(type='hidden' name='_csrf' value=csrf)
section.postform-row section.postform-row

@ -44,7 +44,7 @@ const Mongo = require(__dirname+'/db/db.js')
ids: true, ids: true,
threadLimit: 100, threadLimit: 100,
replyLimit: 300, replyLimit: 300,
maxImages: 3, maxFiles: 3,
defaultName: 'Anonymous', defaultName: 'Anonymous',
} }
}) })
@ -60,8 +60,8 @@ const Mongo = require(__dirname+'/db/db.js')
ids: false, ids: false,
threadLimit: 100, threadLimit: 100,
replyLimit: 300, replyLimit: 300,
maxImages: 3, maxFiles: 3,
defaultNAme: 'Anonymous', defaultName: 'Anonymous',
} }
}) })
console.log('creating indexes') console.log('creating indexes')

Loading…
Cancel
Save