diff --git a/controllers/forms.js b/controllers/forms.js index 1cabffee..a20546f1 100644 --- a/controllers/forms.js +++ b/controllers/forms.js @@ -369,10 +369,16 @@ router.post('/board/:board/actions', Boards.exists, banCheck, paramConverter, ve if (hasPerms) { // if getting global banned, board ban doesnt matter if (req.body.global_ban) { - const { message } = await banPoster(req, res, next, null, posts); + const { message, action, query } = await banPoster(req, res, next, null, posts); + if (action) { + combinedQuery[action] = { ...combinedQuery[action], ...query} + } messages.push(message); } else if (req.body.ban) { - const { message } = await banPoster(req, res, next, req.params.board, posts); + const { message, action, query } = await banPoster(req, res, next, req.params.board, posts); + if (action) { + combinedQuery[action] = { ...combinedQuery[action], ...query} + } messages.push(message); } } diff --git a/gulp/res/css/style.css b/gulp/res/css/style.css index 45e956da..8f0ba346 100644 --- a/gulp/res/css/style.css +++ b/gulp/res/css/style.css @@ -22,13 +22,33 @@ body { white-space: pre; } +.ml-1 { + margin-left: 1px; +} +.ml-5 { + margin-left: 5px; +} +.mr-1 { + margin-right: 1px; +} +.mr-5 { + margin-right: 5px; +} +.ph-5 { + padding: 0 5px; +} +.pv-5 { + padding: 5px 0; +} + .pages { - padding: 10px; margin: 10px 0; + padding: 10px; } -.pages a { +.pages a, a:visited { text-decoration: none; + color: black; } object { @@ -41,7 +61,9 @@ object { align-items: center; } - +.navbar { + border-bottom: 1px solid #a9a9a9; +} .catalog-tile-button { width: 100%; @@ -103,6 +125,11 @@ object { text-align: center; } +.banmessage { + color: red; + font-weight: bold; +} + .reports { background: #fca!important; border-color: #c97!important; @@ -118,8 +145,8 @@ object { color: green; } -blockquote a { - color: #d00; +blockquote a, a:hover { + color: #d00!important; } .op blockquote { @@ -127,14 +154,9 @@ blockquote a { } blockquote { - /*word-break: break-all;*/ white-space: pre-wrap; } -span { - /*margin-right: 5px;*/ -} - .thread, .action-wrapper, .form-wrapper { display: flex; flex-direction: column; @@ -223,7 +245,7 @@ span { margin-right: 10px; display: flex; flex-flow: row wrap; - align-items: end; + align-items: start; } .post-data { @@ -287,6 +309,7 @@ input textarea { .board-banner { margin: 10px; max-width: 100%; + border: 1px solid #a9a9a9; } .board-description { @@ -303,19 +326,19 @@ input textarea { .post-container, .ban { box-sizing: border-box; margin: 2px 0; - padding: 2px; + padding: 5px; max-width: 100%; } .post-container:target { - background-color: #d6bad0!important; + background-color: #d6bad0; border-color: #ba9dbf; } .post-container.op { background: none; border: none; - width: 100% + width: 100%; } .post-subject { @@ -342,11 +365,9 @@ input textarea { .post-info { - margin: -2px; - /*margin-left: -3px;*/ - padding: 2px; - padding-left: 1px; - /*background-color: #B7C5D9;*/ + margin: -5px; + padding: 5px; + padding-left: 3px; } .post-info * { @@ -383,6 +404,7 @@ input textarea { flex-shrink: 0; margin-top: auto; line-height: 30px; + border-top: 1px solid #a9a9a9; } input[type="text"], input[type="submit"], input[type="password"], input[type="file"], textarea { @@ -399,25 +421,38 @@ input[type="submit"] { } input[type="file"] { - border: none; + background: white; } -.postform-section { +.postform-row, .postform-col { display: flex; +} + +.postform-row { margin-bottom: 1px; overflow: hidden; max-width: 100%; } -.postform-data { - display: flex; +.postform-col { flex-direction: column; flex-grow: 1; } +.postform-style { + display: flex; + border: 1px solid #a9a9a9; + background: white; + align-items: center; +} + .captcha { - margin-bottom: 1px; border: 1px solid #a9a9a9; + background: white; + margin-bottom: 1px; + width: 100%; + box-sizing: border-box; + object-fit: contain; } .postform-label { @@ -442,8 +477,9 @@ hr { @media only screen and (max-width: 800px) { - input { + input, .postform-style { height: 30px; + box-sizing: border-box; } .form-post { @@ -459,7 +495,7 @@ hr { } .post-check { - top: 2px; + top: 1px; margin-left: 2px!important; height: 8px; } diff --git a/models/forms/ban-poster.js b/models/forms/ban-poster.js index 49617116..abc60af0 100644 --- a/models/forms/ban-poster.js +++ b/models/forms/ban-poster.js @@ -18,6 +18,12 @@ module.exports = async (req, res, next, board, posts) => { const bannedIps = await Bans.insertMany(bans).then(result => result.insertedCount); - return { message:`Banned ${bannedIps} ips` }; + return { + message:`Banned ${bannedIps} ips`, + action:'$set', + query: { + 'banmessage': req.body.ban_reason || '' + } + }; } diff --git a/models/forms/make-post.js b/models/forms/make-post.js index 1f29ceaa..18cb905b 100644 --- a/models/forms/make-post.js +++ b/models/forms/make-post.js @@ -197,6 +197,7 @@ module.exports = async (req, res, next, numFiles) => { 'email': req.body.email || null, 'salt': !req.body.thread ? salt : null, 'spoiler': req.body.spoiler ? true : false, + 'banmessage': null, 'userId': userId, 'ip': ip, 'files': files, diff --git a/server.js b/server.js index e9e16ac8..1bc79799 100644 --- a/server.js +++ b/server.js @@ -53,7 +53,7 @@ const express = require('express') // use pug view engine app.set('view engine', 'pug'); app.set('views', path.join(__dirname, 'views/pages')); -// app.enable('view cache'); + app.enable('view cache'); // routes app.use('/forms', require(__dirname+'/controllers/forms.js')) diff --git a/views/includes/bannerform.pug b/views/includes/bannerform.pug index 30d5b8b2..b2002e9c 100644 --- a/views/includes/bannerform.pug +++ b/views/includes/bannerform.pug @@ -3,7 +3,9 @@ section.form-wrapper 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) - input#file(type='file', name='file' multiple) + section.postform-section + span.fileupload + input#file(type='file', name='file' multiple) input(type='submit', value='submit') section.form-wrapper @@ -14,6 +16,6 @@ section.form-wrapper each banner in board.banners label.banner-check input(type='checkbox' name='checkedbanners[]' value=banner) - object.board-banner(data=`/img/${banner}` width='300' height='100') + object.board-banner(data=`/banner/${banner}` width='300' height='100') input(type='submit', value='submit') diff --git a/views/includes/boardheader.pug b/views/includes/boardheader.pug index 6f3d3492..b310a1ec 100644 --- a/views/includes/boardheader.pug +++ b/views/includes/boardheader.pug @@ -1,6 +1,6 @@ section.board-header if board.banners.length > 0 object.board-banner(data=`/banners?board=${board._id}` width='300' height='100') - a.no-decoration(href=`/${board._id}`) + a.no-decoration(href=`/${board._id}/`) h1.board-title /#{board._id}/ - #{board.name} h4.board-description #{board.description} diff --git a/views/includes/head.pug b/views/includes/head.pug index bb280b73..e8c05af9 100644 --- a/views/includes/head.pug +++ b/views/includes/head.pug @@ -1,4 +1,4 @@ meta(charset='utf-8') meta(name='viewport', content='width=device-width, initial-scale=1') link(rel='stylesheet' href='/css/style.css') -link(rel='shortcut icon' href='/img/favicon.ico' type='image/x-icon') +link(rel='shortcut icon' href='/favicon.ico' type='image/x-icon') diff --git a/views/includes/pages.pug b/views/includes/pages.pug index 7e472992..cafef9fa 100644 --- a/views/includes/pages.pug +++ b/views/includes/pages.pug @@ -1,8 +1,7 @@ -nav.pages Page: - - for(let i = 1; i <= pages; i++) - if i === page - span: a(href=`/${board._id}?p=${i}`) [#{i}] - else - span: a(href=`/${board._id}?p=${i}`) #{i} - | | - a(href=`/${board._id}/catalog`) [Catalog] +| Page: +- for(let i = 1; i <= pages; i++) + if i === page + span: a(href=`/${board._id}?p=${i}`) [#{i}] + else + span: a(href=`/${board._id}?p=${i}`) #{i} +| | diff --git a/views/includes/postform.pug b/views/includes/postform.pug index 56af0a6b..9d1e6888 100644 --- a/views/includes/postform.pug +++ b/views/includes/postform.pug @@ -2,33 +2,33 @@ section.form-wrapper 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='thread' value=thread != null ? thread.postId : null) - section.postform-section + section.postform-row .postform-label Name input#name(type='text', name='name', placeholder='Anonymous' autocomplete='off' maxlength='50') - section.postform-section + section.postform-row .postform-label Subject input#title(type='text', name='subject', autocomplete='off' maxlength='50') - section.postform-section + section.postform-row .postform-label Email input#name(type='text', name='email', autocomplete='off' maxlength='50') - section.postform-section + section.postform-row .postform-label Password input#password(type='password', name='password', autocomplete='off' maxlength='50') - section.postform-section + section.postform-row .postform-label Message textarea#message(name='message', rows='5', autocomplete='off' maxlength='2000') - section.postform-section + section.postform-row .postform-label Files - span - input#file(type='file', name='file' multiple='multiple') - label - input.post-check#spoiler(type='checkbox', name='spoiler', value='true') - | Spoiler - section.postform-section + input#file(type='file', name='file' multiple='multiple') + label.postform-style.ph-5.ml-1 + input#spoiler(type='checkbox', name='spoiler', value='true') + | Spoiler + section.postform-row .postform-label Captcha - span.postform-data + .postform-col img.captcha(src='/captcha' width=200 height=80) input#captcha(type='text', name='captcha', autocomplete='off' placeholder='captcha text' maxlength='6') input(type='submit', value='submit') + diff --git a/views/mixins/ban.pug b/views/mixins/ban.pug index c6043836..3baf4082 100644 --- a/views/mixins/ban.pug +++ b/views/mixins/ban.pug @@ -4,7 +4,7 @@ mixin ban(ban) .ban input.post-check(type='checkbox', name='checkedbans[]' value=ban._id) if ban.board - div Board: #[a(href=`/${ban.board}`) /#{ban.board}/] + div Board: #[a(href=`/${ban.board}/`) /#{ban.board}/] else div Global ban. div Reason: #{ban.reason} diff --git a/views/mixins/post.pug b/views/mixins/post.pug index c5df1deb..2fedfe2d 100644 --- a/views/mixins/post.pug +++ b/views/mixins/post.pug @@ -23,8 +23,10 @@ mixin post(post, truncate, manage=false, globalmanage=false) span.post-name #{post.name} else span.post-name #{post.name} + | if post.tripcode span.post-tripcode #{post.tripcode} + | if post.capcode span.post-capcode #{post.capcode} | @@ -57,19 +59,17 @@ mixin post(post, truncate, manage=false, globalmanage=false) - const splitPost = post.message.split('\n'); const messageLines = splitPost.length; - let truncatedMessage = post.mesage; - let truncated = false; + let truncatedMessage = post.message; if (messageLines > 10 || post.message.length > 1000) { truncatedMessage = splitPost.slice(0, 10).join('\n'); - truncated = true; } + blockquote.post-message !{truncatedMessage} if truncated - blockquote.post-message !{truncatedMessage} blockquote.left.clear-both Message too long. #[a(href=postURL) View the full text] - else - blockquote.post-message !{post.message} else blockquote.post-message !{post.message} + if post.banmessage + blockquote.left.clear-both.banmessage (USER WAS BANNED FOR THIS POST #{post.banmessage}) if post.omittedposts || post.omittedimages blockquote.left.clear-both #{post.omittedposts} post(s)#{post.omittedimages > 0 ? ' and '+post.omittedimages+' image(s)' : ''} omitted. #[a(href=postURL) View the full thread] diff --git a/views/pages/board.pug b/views/pages/board.pug index d6ecfdca..262afd95 100644 --- a/views/pages/board.pug +++ b/views/pages/board.pug @@ -8,7 +8,10 @@ block content include ../includes/boardheader.pug include ../includes/postform.pug .mode Posting mode: Thread - include ../includes/pages.pug + nav.pages#top + include ../includes/pages.pug + a(href='#bottom') [Bottom] + a(href=`/${board._id}/catalog`) [Catalog] hr(size=1) form(action='/forms/board/'+board._id+'/actions' method='POST' enctype='application/x-www-form-urlencoded') input(type='hidden' name='_csrf' value=csrf) @@ -21,4 +24,7 @@ block content for post in thread.replies +post(post, true) hr(size=1) + nav.pages#bottom + a(href='#top') [Top] + a(href=`/${board._id}/catalog`) [Catalog] include ../includes/actionfooter.pug diff --git a/views/pages/catalog.pug b/views/pages/catalog.pug index e2800109..e8e8e7b0 100644 --- a/views/pages/catalog.pug +++ b/views/pages/catalog.pug @@ -6,8 +6,9 @@ block head block content include ../includes/boardheader.pug - hr(size=1) - .mode Catalog View [#[a.no-decoration(href=`/${board._id}`) Go Back]] + nav.pages#top + a(href='#bottom') [Bottom] + a(href=`/${board._id}/`) [Return] hr(size=1) if threads.length === 0 p No posts. @@ -15,4 +16,7 @@ block content section.catalog for thread in threads +catalogtile(board, thread) - + hr(size=1) + nav.pages#bottom + a(href='#top') [Top] + a(href=`/${board._id}/`) [Return] diff --git a/views/pages/changepassword.pug b/views/pages/changepassword.pug index 85460e0b..8c080dc2 100644 --- a/views/pages/changepassword.pug +++ b/views/pages/changepassword.pug @@ -7,16 +7,16 @@ block content section.form-wrapper form.form-post(action='/forms/changepassword' method='POST') input(type='hidden' name='_csrf' value=csrf) - section.postform-section + section.postform-row .postform-label Username - input#username(type='text', name='username', placeholder='username' maxlength='50') - section.postform-section + input#username(type='text', name='username', maxlength='50') + section.postform-row .postform-label Existing Password input#password(type='password', name='password', maxlength='100') - section.postform-section + section.postform-row .postform-label New Password input#password(type='password', name='newpassword', maxlength='100') - section.postform-section + section.postform-row .postform-label Confirm New Password input#password(type='password', name='newpasswordconfirm', maxlength='100') input(type='submit', value='submit') diff --git a/views/pages/login.pug b/views/pages/login.pug index a10ae0a0..d3667add 100644 --- a/views/pages/login.pug +++ b/views/pages/login.pug @@ -8,12 +8,12 @@ block content form.form-post(action='/forms/login' method='POST') input(type='hidden' name='_csrf' value=csrf) input(type='hidden' name='redirect' value=redirect) - section.postform-section + section.postform-row .postform-label Username - input#username(type='text', name='username', placeholder='username' maxlength='50') - section.postform-section + input#username(type='text', name='username', maxlength='50') + section.postform-row .postform-label Password - input#password(type='password', name='password', placeholder='password' maxlength='100') + input#password(type='password', name='password', maxlength='100') input(type='submit', value='submit') p No account? #[a(href='/register') Register] diff --git a/views/pages/register.pug b/views/pages/register.pug index fd8359d2..ac9708cf 100644 --- a/views/pages/register.pug +++ b/views/pages/register.pug @@ -7,18 +7,18 @@ block content section.form-wrapper form.form-post(action='/forms/register' method='POST') input(type='hidden' name='_csrf' value=csrf) - section.postform-section + section.postform-row .postform-label Username - input#username(type='text', name='username', placeholder='username' maxlength='50') - section.postform-section + input#username(type='text', name='username', maxlength='50') + section.postform-row .postform-label Password - input#password(type='password', name='password', placeholder='password' maxlength='100') - section.postform-section + input#password(type='password', name='password', maxlength='100') + section.postform-row .postform-label Confirm Password - input#password(type='password', name='passwordconfirm', placeholder='confirm password' maxlength='100') - section.postform-section + input#password(type='password', name='passwordconfirm', maxlength='100') + section.postform-row .postform-label Captcha - span.postform-data + span.postform-col img.captcha(src='/captcha' width=200 height=80) input#captcha(type='text', name='captcha', autocomplete='off' placeholder='captcha text' maxlength='6') input(type='submit', value='submit') diff --git a/views/pages/thread.pug b/views/pages/thread.pug index f7dd7bb7..de0d9c59 100644 --- a/views/pages/thread.pug +++ b/views/pages/thread.pug @@ -2,7 +2,7 @@ extends ../layout.pug include ../mixins/post.pug block head - title /#{board._id}/ #{thread.subject||thread.postId} + title /#{board._id}/ - #{thread.subject||thread.postId} meta(property='og:site_name', value='fatchan') meta(property='og:title', content=thread.subject) meta(property='og:url', content='https://fatpeople.lol') @@ -12,7 +12,11 @@ block head block content include ../includes/boardheader.pug include ../includes/postform.pug - .mode Posting mode: Reply [#[a.no-decoration(href=`/${board._id}`) Go Back]] + .mode Posting mode: Reply + nav.pages#top + a(href='#bottom') [Bottom] + a(href=`/${board._id}/`) [Return] + a(href=`/${board._id}/catalog`) [Catalog] hr(size=1) form(action=`/forms/board/${board._id}/actions` method='POST' enctype='application/x-www-form-urlencoded') input(type='hidden' name='_csrf' value=csrf) @@ -21,4 +25,8 @@ block content for post in thread.replies +post(post) hr(size=1) + nav.pages#bottom + a(href='#top') [Top] + a(href=`/${board._id}/`) [Return] + a(href=`/${board._id}/catalog`) [Catalog] include ../includes/actionfooter.pug