add board tags, and limits to tags, moderators and filters (#49)

added board tags (not searching with them or indexing them yet)
    added limits to number of tags, moderators and filters in board settings
merge-requests/208/head
Tom 5 years ago committed by GitHub
parent 5b56b9f0e7
commit ab27114f71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      controllers/forms/boardsettings.js
  2. 1
      gulpfile.js
  3. 2
      helpers/paramconverter.js
  4. 5
      models/forms/changeboardsettings.js
  5. 7
      models/forms/create.js
  6. 3
      views/pages/create.pug
  7. 7
      views/pages/manage.pug

@ -12,6 +12,15 @@ module.exports = async (req, res, next) => {
if (req.body.announcements && (req.body.announcements.length < 1 || req.body.announcements.length > 2000)) {
errors.push('Board announcements must be 1-2000 characters');
}
if (req.body.tags && req.body.tags.length > 2000) {
errors.push('Tags length must be less than 2000 characters');
}
if (req.body.filters && req.body.filters.length > 2000) {
errors.push('Filters length must be less than 2000 characters');
}
if (req.body.moderators && req.body.moderators.length > 500) {
errors.push('Moderators length must be less than 500 characters');
}
if (req.body.name && (req.body.name.length < 1 || req.body.name.length > 50)) {
errors.push('Board name must be 1-50 characters');
}

@ -59,6 +59,7 @@ async function wipe() {
'settings': {
'name': 'test',
'description': 'testing board',
'tags': [],
'moderators': [],
'captchaMode': 0,
'locked': false,

@ -2,7 +2,7 @@
const { ObjectId } = require(__dirname+'/../db/db.js')
, allowedArrays = new Set(['checkednews', 'checkedposts', 'globalcheckedposts', 'checkedbans', 'checkedbanners']) //only these can be arrays, since express bodyparser will output arrays
, trimFields = ['uri', 'moderators', 'filters', 'announcement', 'description', 'message',
, trimFields = ['tags', 'uri', 'moderators', 'filters', 'announcement', 'description', 'message',
'name', 'subject', 'email', 'password', 'default_name', 'report_reason', 'ban_reason'] //trim if we dont want filed with whitespace
, numberFields = ['filter_mode', 'captcha_mode', 'tph_trigger', 'tph_trigger_action', 'reply_limit',
'max_files', 'thread_limit', 'thread', 'min_thread_message_length', 'min_reply_message_length'] //convert these to numbers before they hit our routes

@ -25,7 +25,7 @@ module.exports = async (req, res, next) => {
markdownAnnouncement = sanitized;
}
let moderators = req.body.moderators !== null ? req.body.moderators.split('\n').filter(n => n) : oldSettings.moderators
let moderators = req.body.moderators != null ? req.body.moderators.split('\n').filter(n => n).slice(0,10) : oldSettings.moderators
if (moderators !== oldSettings.moderators) {
//make sure moderators actually have existing accounts
if (moderators.length > 0) {
@ -65,7 +65,8 @@ module.exports = async (req, res, next) => {
raw: req.body.announcement !== null ? req.body.announcement : oldSettings.announcement.raw,
markdown: markdownAnnouncement || oldSettings.announcement.markdown
},
filters: req.body.filters !== null ? req.body.filters.split('\n').filter(n => n) /*prevents empty*/ : oldSettings.filters,
tags: req.body.tags !== null ? req.body.tags.split('\n').filter(n => n).slice(0,10) : oldSettings.tags,
filters: req.body.filters !== null ? req.body.filters.split('\n').filter(n => n).slice(0,50) : oldSettings.filters,
filterMode: typeof req.body.filter_mode === 'number' && req.body.filter_mode !== oldSettings.filterMode ? req.body.filter_mode : oldSettings.filterMode,
filterBanDuration: typeof req.body.ban_duration === 'number' && req.body.ban_duration !== oldSettings.filterBanDuration ? req.body.ban_duration : oldSettings.filterBanDuration
};

@ -5,9 +5,9 @@ const { Boards } = require(__dirname+'/../../db/');
module.exports = async (req, res, next) => {
const { name, description } = req.body
, uri = req.body.uri.toLowerCase();
const board = await Boards.findOne(uri);
, uri = req.body.uri.toLowerCase()
, tags = req.body.tags.split('\n')
, board = await Boards.findOne(uri);
// if board exists reject
if (board != null) {
@ -28,6 +28,7 @@ module.exports = async (req, res, next) => {
'settings': {
name,
description,
tags,
'moderators': [],
'locked': false,
'captchaMode': 0,

@ -17,6 +17,9 @@ block content
section.row
.label Description
input(type='text', name='description', maxlength='50' required)
section.row
.label Tags
textarea(name='tags' placeholder='newline separated, max 10')
section.row
.label Captcha
span.col

@ -18,6 +18,9 @@ block content
section.row
.label Board Description
input(type='text' name='description' value=board.settings.description)
section.row
.label Tags
textarea(name='tags' placeholder='newline separated, max 10') #{board.settings.tags.join('\n')}
section.row
.label Announcement
textarea(name='announcement' placeholder='supports post styling') #{board.settings.announcement.raw}
@ -94,7 +97,7 @@ block content
br
section.row
.label Moderators
textarea(name='moderators' placeholder='newline separated') #{board.settings.moderators.join('\n')}
textarea(name='moderators' placeholder='newline separated, max 10') #{board.settings.moderators.join('\n')}
section.row
.label Board Locked
label.postform-style.ph-5
@ -117,7 +120,7 @@ block content
option(value='3', selected=board.settings.tphTriggerAction === 3) Lock Board
section.row
.label Filters
textarea(name='filters' placeholder='newline separated') #{board.settings.filters.join('\n')}
textarea(name='filters' placeholder='newline separated, max 50') #{board.settings.filters.join('\n')}
section.row
.label Filter Mode
select(name='filter_mode' checked=board.settings.filterMode)

Loading…
Cancel
Save