board name and description can be changed in manage page

merge-requests/208/head
fatchan 5 years ago
parent 5172ffc251
commit e54e30c586
  1. 6
      controllers/forms.js
  2. 10
      models/forms/changeboardsettings.js
  3. 1
      models/forms/makepost.js
  4. 4
      views/includes/boardheader.pug
  5. 6
      views/pages/manage.pug
  6. 14
      wipe.js

@ -259,6 +259,12 @@ router.post('/board/:board/settings', csrf, Boards.exists, checkPermsMiddleware,
const errors = [];
if (req.body.description && (req.body.description.length < 1 || req.body.description.length > 50)) {
errors.push('Board description must be 1-50 characters');
}
if (req.body.name && (req.body.name.length < 1 || req.body.name.length > 50)) {
errors.push('Board name must be 1-50 characters');
}
if (req.body.default_name && (req.body.default_name.length < 1 || req.body.default_name.length > 50)) {
errors.push('Anon name must be 1-50 characters');
}

@ -3,7 +3,7 @@
const Boards = require(__dirname+'/../../db/boards.js')
, Posts = require(__dirname+'/../../db/posts.js')
, uploadDirectory = require(__dirname+'/../../helpers/uploadDirectory.js')
, { buildCatalog, buildBoardMultiple } = require(__dirname+'/../../build.js')
, { buildHomepage, buildCatalog, buildBoardMultiple } = require(__dirname+'/../../build.js')
, remove = require('fs-extra').remove
module.exports = async (req, res, next) => {
@ -11,9 +11,11 @@ module.exports = async (req, res, next) => {
const oldSettings = res.locals.board.settings;
const newSettings = {
name: req.body.name && req.body.name.trim().length > 0 ? req.body.name : oldSettings.name,
description: req.body.description && req.body.description.trim().length > 0 ? req.body.description : oldSettings.description,
ids: req.body.ids ? true : false,
captcha: req.body.captcha ? true : false,
forceAnon: req.body.force_anon ? true : false,
ids: req.body.ids ? true : false,
userPostDelete: req.body.user_post_delete ? true : false,
userPostSpoiler: req.body.user_post_spoiler ? true : false,
userPostUnlink: req.body.user_post_unlink ? true : false,
@ -73,6 +75,10 @@ module.exports = async (req, res, next) => {
promises.push(remove(`${uploadDirectory}html/${req.params.board}/`));
}
if (oldSettings.name !== newSettings.name || oldSettings.description !== newSettings.description) {
promises.push(buildHomepage())
}
if (promises.length > 0) {
await Promise.all(promises);
}

@ -241,6 +241,7 @@ module.exports = async (req, res, next) => {
capcode,
subject,
'message': message || null,
'nomarkup': req.body.message || null,
'thread': req.body.thread || null,
'password': req.body.password || null,
email,

@ -2,5 +2,5 @@ section.board-header
img.board-banner(src=`/randombanner?board=${board._id}` width='300' height='100')
br
a.no-decoration(href=`/${board._id}/index.html`)
h1.board-title /#{board._id}/ - #{board.name}
h4.board-description #{board.description}
h1.board-title /#{board._id}/ - #{board.settings.name}
h4.board-description #{board.settings.description}

@ -12,6 +12,12 @@ block content
section.form-wrapper.flexleft.mv-10
form.form-post(action=`/forms/board/${board._id}/settings` method='POST' enctype='application/x-www-form-urlencoded')
input(type='hidden' name='_csrf' value=csrf)
section.postform-row
.postform-label Board name
input(type='text' name='name' placeholder=board.settings.name)
section.postform-row
.postform-label Board Description
input(type='text' name='description' placeholder=board.settings.description)
section.postform-row
.postform-label IDs
label.postform-style.ph-5

@ -33,13 +33,13 @@ const Mongo = require(__dirname+'/db/db.js')
await Bans.deleteAll();
console.log('adding boards')
await Boards.insertOne({
_id: 'pol',
name: 'Politically Incorrect',
description: 'Political posts go here.',
_id: 'pol',
owner: '',
moderators: [],
banners: [],
settings: {
name: 'politically incorrect',
description: 'posts about politics',
captcha: true,
forceAnon: true,
ids: true,
@ -57,13 +57,13 @@ const Mongo = require(__dirname+'/db/db.js')
}
})
await Boards.insertOne({
_id: 'b',
name: 'Random',
description: 'post anything here',
_id: 'b',
owner: '',
moderators: [],
banners: [],
settings: {
name: 'random',
description: 'anything and everything',
captcha: false,
forceAnon: false,
ids: false,
@ -83,7 +83,7 @@ const Mongo = require(__dirname+'/db/db.js')
await Boards.insertOne({
_id: 't',
name: 'text',
description: 'text only board',
description: 'no images allowed',
owner: '',
moderators: [],
banners: [],

Loading…
Cancel
Save