omitted images and reply count with thread previews

merge-requests/208/head
fatchan 5 years ago
parent c8f9814b38
commit 8e378bb160
  1. 62
      db/posts.js
  2. 2
      gulp/dist/css/style.css
  3. 12
      gulp/res/css/style.css
  4. 20
      models/forms/make-post.js
  5. 2
      server.js
  6. 433
      style.css
  7. 7
      views/mixins/post.pug

@ -19,7 +19,8 @@ module.exports = {
'salt': 0,
'password': 0,
'ip': 0,
'reports': 0
'reports': 0,
'globalreports': 0,
}
}).sort({
'bumped': -1
@ -35,14 +36,24 @@ module.exports = {
'salt': 0,
'password': 0,
'ip': 0,
'reports': 0
'reports': 0,
'globalreports': 0,
}
}).sort({
'_id': -1
}).limit(5).toArray();
//reverse order for board page
thread.replies = replies.reverse();
}));
//count omitted image and posts
const numPreviewImages = replies.reduce((acc, post) => {
return acc + post.files.length;
}, 0);
thread.omittedimages = thread.replyimages - numPreviewImages;
thread.omittedposts = thread.replyposts - replies.length;
}));
return threads;
},
@ -67,7 +78,8 @@ module.exports = {
'salt': 0,
'password': 0,
'ip': 0,
'reports': 0
'reports': 0,
'globalreports': 0,
}
}),
module.exports.getThreadPosts(board, id)
@ -94,7 +106,8 @@ module.exports = {
'salt': 0 ,
'password': 0,
'ip': 0,
'reports': 0
'reports': 0,
'globalreports': 0,
}
}).sort({
'_id': 1
@ -113,7 +126,8 @@ module.exports = {
'salt': 0,
'password': 0,
'ip': 0,
'reports': 0
'reports': 0,
'globalreports': 0,
}
}).toArray();
@ -137,7 +151,8 @@ module.exports = {
'salt': 0,
'password': 0,
'ip': 0,
'reports': 0
'reports': 0,
'globalreports': 0,
}
});
@ -165,7 +180,8 @@ module.exports = {
'salt': 0,
'password': 0,
'ip': 0,
'reports': 0
'reports': 0,
'globalreports': 0,
}
}).toArray();
@ -182,26 +198,33 @@ module.exports = {
insertOne: async (board, data) => {
// bump thread if name not sage
if (data.thread !== null && data.email !== 'sage') {
await db.updateOne({
if (data.thread !== null) {
//if not a thread, update reply and image count on op document;
const filter = {
'postId': data.thread,
'board': board
}, {
'$set': {
}
const query = {
'$inc': {
'replyposts': 1,
'replyimages': data.files.length
}
}
// bump thread if name not sage
if (data.email !== 'sage') {
query['$set'] = {
'bumped': Date.now()
}
})
}
await db.updateOne(filter, query);
} else {
//this is a new thread, so set the bump date
data.bumped = Date.now()
}
const postId = await Boards.getNextId(board);
data.postId = postId;
//this is a thread, so set the bump date so its pushed to the top
if (data.thread == null) {
data.bumped = Date.now()
}
await db.insertOne(data);
return postId;
@ -266,6 +289,7 @@ module.exports = {
'password': 0,
'ip': 0,
'reports': 0,
'globalreports': 0,
}
}).toArray();
},

@ -1 +1 @@
body{font-family:arial,helvetica,sans-serif;font-size:10pt;background:#eef2ff;flex:1;display:flex;flex-direction:column;min-height:100vh;margin:0}.code{border-left:10px solid #b7c5d9;display:block;padding-left:5px;font-family:monospace;margin:.5em 0}.pages{padding:10px;margin:10px 0}.pages a{text-decoration:none}object{object-fit:contain}.board-header{display:flex;flex-direction:column;align-items:center}.catalog-tile-button{width:100%;line-height:30px;float:left;background:#b7c5d9;text-decoration:none;color:#000}.catalog-tile-content{padding:5px}.catalog-tile{margin:2px;text-align:center;max-height:300px;width:250px;overflow:hidden;overflow-y:auto;border:2px solid #b7c5d9;box-sizing:border-box}.no-m-p{margin:0;padding:0}.catalog-thumb{box-shadow:0 0 3px #000;min-width:64px;min-height:64px;object-fit:cover}.catalog{display:flex;align-items:flex-start;justify-content:space-evenly;flex-flow:row wrap}.spoiler{background:#000}.spoiler:hover{color:#fff}.mode{background-color:red;color:#fff;font-weight:700;text-align:center}.reports{background:#fca!important;border-color:#c97!important;border-width:1px 0;border-style:solid none}.redtext{color:maroon}.greentext{color:green}blockquote a{color:#d00}blockquote{word-break:break-all;white-space:pre-wrap}span{margin-right:5px}.action-wrapper,.form-wrapper,.post-container,.thread{display:flex;flex-direction:column;align-items:flex-start}.form-wrapper{align-items:center;margin:10px 0}.actions,.pages,.post-container{background:#d6daf0;border-color:#b7c5d9;border-width:0 1px 1px 0;border-style:none solid solid none}.actions{max-width:100%;display:flex;flex-direction:column;margin:2px 0;padding:2px}.action-wrapper{display:flex;flex-direction:column;align-items:flex-start}.actions label{margin:2px 0}.toggle-label:hover{box-shadow:inset 0 0 100px 100px rgba(255,255,255,.25)}.toggle-label{background:#d6daf0;padding:10px;border-radius:3px;text-align:center;border:1px solid #d3d3d3;max-width:100%;box-sizing:border-box}.toggle{display:none}.toggle:checked+*{display:flex}.form-post{display:flex;flex-direction:column;max-width:100%;margin-top:10px}.togglable{display:none}.user-id{text-shadow:#000 0 0 1px,#000 0 0 1px,#000 0 0 1px,#000 0 0 1px,#000 0 0 1px,#000 0 0 1px;color:#fff;padding:0 2px}.post-check{position:relative;top:3px;margin:-3px 1px!important}.post-files{float:left;margin-right:10px}.post-data{margin-top:-10px;padding-top:10px}.post-file{display:inline-flex;flex-direction:column;margin:0 4px;padding:2px 0}.post-file-info{text-align:center;margin:2px;margin-top:0;max-width:128px;word-break:break-all}.post-file-src{margin:0 auto}input textarea{padding:8px}.no-resize{resize:none}.container{padding:10px}.board-title{color:#af0a0f;font:bolder 28px Tahoma,sans-serif;letter-spacing:-2px;text-align:center;margin:0}.no-decoration{text-decoration:none;color:#fff}.banner-check{display:flex;align-items:center}.board-banner{margin:10px;max-width:100%}.board-description{text-align:center;margin:0}.ban,.post-container{box-sizing:border-box;margin:2px 0;padding:2px;max-width:100%}.post-container:target{background-color:#d6bad0!important;border-color:#ba9dbf}.post-container.op{background:0 0;border:none}.post-subject{color:#0f0c5d;font-weight:700}.post-capcode{font-weight:700;color:red}.post-name,.post-tripcode{color:#117743}.post-name{font-weight:700}.catalog-tile-content .post-info,.post-container.op .post-info{background:0 0}.post-info{margin:-2px;padding:2px;padding-left:1px}.post-info *{margin-bottom:0;margin-top:-2px}.navbar{border-bottom:1px solid #d3d3d3}.nav-item{line-height:50px;text-decoration:none;float:left;background:#d6daf0;padding-left:10px;padding-right:10px;border-right:1px solid #d3d3d3}.right{float:right}.nav-item:hover{box-shadow:inset 0 0 100px 100px rgba(255,255,255,.25)}.footer{border-top:1px solid #d3d3d3;text-align:center;flex-shrink:0;margin-top:auto;line-height:50px}input[type=password],input[type=text],textarea{border:1px solid #a9a9a9;font-size:inherit;font-family:arial,helvetica,sans-serif;margin:0;flex-grow:1}.postform-section{display:flex;margin-bottom:1px}.postform-label{padding:3px;border:1px solid #000;min-width:80px;background:#98e;display:flex;justify-content:center;flex-direction:column;font-weight:700;margin-right:1px}.boards-table{margin:0 auto}hr{color:#d3d3d3}@media only screen and (max-width:800px){input{height:30px}.form-post{width:100%}.form-login{width:100%}blockquote{margin:1em}.post-check{top:2px;margin-left:2px!important;height:8px}.post-container{width:100%;border:none}.catalog-tile{overflow-y:hidden}.boards-table{width:100%}.post-info{background-color:#b7c5d9}}
body{font-family:arial,helvetica,sans-serif;font-size:10pt;background:#eef2ff;flex:1;display:flex;flex-direction:column;min-height:100vh;margin:0}.code{border-left:10px solid #b7c5d9;display:block;padding-left:5px;font-family:monospace;margin:.5em 0}.pages{padding:10px;margin:10px 0}.pages a{text-decoration:none}object{object-fit:contain}.board-header{display:flex;flex-direction:column;align-items:center}.catalog-tile-button{width:100%;line-height:30px;float:left;background:#b7c5d9;text-decoration:none;color:#000}.catalog-tile-content{padding:5px}.catalog-tile{margin:2px;text-align:center;max-height:300px;width:250px;overflow:hidden;overflow-y:auto;border:2px solid #b7c5d9;box-sizing:border-box}.no-m-p{margin:0;padding:0}.catalog-thumb{box-shadow:0 0 3px #000;min-width:64px;min-height:64px;object-fit:cover}.catalog{display:flex;align-items:flex-start;justify-content:space-evenly;flex-flow:row wrap}.spoiler{background:#000}.spoiler:hover{color:#fff}.mode{background-color:red;color:#fff;font-weight:700;text-align:center}.reports{background:#fca!important;border-color:#c97!important;border-width:1px 0;border-style:solid none}.redtext{color:maroon}.greentext{color:green}blockquote a{color:#d00}blockquote{word-break:break-all;white-space:pre-wrap}span{margin-right:5px}.action-wrapper,.form-wrapper,.thread{display:flex;flex-direction:column;align-items:flex-start}.form-wrapper{align-items:center;margin:10px 0}.actions,.pages,.post-container{background:#d6daf0;border-color:#b7c5d9;border-width:0 1px 1px 0;border-style:none solid solid none}.actions{max-width:100%;display:flex;flex-direction:column;margin:2px 0;padding:2px}.action-wrapper{display:flex;flex-direction:column;align-items:flex-start}.actions label{margin:2px 0}.toggle-label:hover{box-shadow:inset 0 0 100px 100px rgba(255,255,255,.25)}.toggle-label{background:#d6daf0;padding:10px;border-radius:3px;text-align:center;border:1px solid #d3d3d3;max-width:100%;box-sizing:border-box}.toggle{display:none}.toggle:checked+*{display:flex}.form-post{display:flex;flex-direction:column;max-width:100%;margin-top:10px}.togglable{display:none}.user-id{text-shadow:#000 0 0 1px,#000 0 0 1px,#000 0 0 1px,#000 0 0 1px,#000 0 0 1px,#000 0 0 1px;color:#fff;padding:0 2px}.post-check{position:relative;top:3px;margin:-3px 1px!important}.post-files{float:left;margin-right:10px}.post-data{margin-top:-10px;padding-top:10px}.post-file{display:inline-flex;flex-direction:column;margin:0 4px;padding:2px 0}.post-file-info{text-align:center;margin:2px;margin-top:0;max-width:128px;word-break:break-all}.post-file-src{margin:0 auto}input textarea{padding:8px}.no-resize{resize:none}.container{padding:10px}.board-title{color:#af0a0f;font:bolder 28px Tahoma,sans-serif;letter-spacing:-2px;text-align:center;margin:0}.no-decoration{text-decoration:none;color:#fff}.banner-check{display:flex;align-items:center}.board-banner{margin:10px;max-width:100%}.board-description{text-align:center;margin:0}.ban,.post-container{box-sizing:border-box;margin:2px 0;padding:2px;max-width:100%}.post-container:target{background-color:#d6bad0!important;border-color:#ba9dbf}.post-container.op{background:0 0;border:none;width:100%}.post-subject{color:#0f0c5d;font-weight:700}.post-capcode{font-weight:700;color:red}.post-name,.post-tripcode{color:#117743}.post-name{font-weight:700}.catalog-tile-content .post-info,.post-container.op .post-info{background:0 0}.post-info{margin:-2px;padding:2px;padding-left:1px}.post-info *{margin-bottom:0;margin-top:-2px}.navbar{border-bottom:1px solid #d3d3d3}.nav-item{line-height:50px;text-decoration:none;float:left;background:#d6daf0;padding-left:10px;padding-right:10px;border-right:1px solid #d3d3d3}.left{float:left}.clear-both{clear:both}.right{float:right}.nav-item:hover{box-shadow:inset 0 0 100px 100px rgba(255,255,255,.25)}.footer{border-top:1px solid #d3d3d3;text-align:center;flex-shrink:0;margin-top:auto;line-height:50px}input[type=password],input[type=text],textarea{border:1px solid #a9a9a9;font-size:inherit;font-family:arial,helvetica,sans-serif;margin:0;flex-grow:1}.postform-section{display:flex;margin-bottom:1px}.postform-label{padding:3px;border:1px solid #000;min-width:80px;background:#98e;display:flex;justify-content:center;flex-direction:column;font-weight:700;margin-right:1px}.boards-table{margin:0 auto}hr{color:#d3d3d3}@media only screen and (max-width:800px){input{height:30px}.form-post{width:100%}.form-login{width:100%}blockquote{margin:1em}.post-check{top:2px;margin-left:2px!important;height:8px}.post-container{width:100%;border:none}.catalog-tile{overflow-y:hidden}.boards-table{width:100%}.post-info{background-color:#b7c5d9;width:100%}}

@ -122,7 +122,7 @@ span {
margin-right: 5px;
}
.thread, .action-wrapper, .form-wrapper, .post-container {
.thread, .action-wrapper, .form-wrapper {
display: flex;
flex-direction: column;
align-items: flex-start;
@ -298,6 +298,7 @@ input textarea {
.post-container.op {
background: none;
border: none;
width: 100%
}
.post-subject {
@ -350,6 +351,14 @@ input textarea {
border-right: 1px solid lightgray;
}
.left {
float: left;
}
.clear-both {
clear: both;
}
.right {
float: right;
}
@ -440,6 +449,7 @@ hr {
.post-info {
background-color: #B7C5D9;
width: 100%;
}
}

@ -166,25 +166,27 @@ module.exports = async (req, res, next, numFiles) => {
message = sanitize(message, sanitizeOptions);
}
//add post to DB
//build post data for db
const data = {
'board': req.params.board,
'date': new Date(),
'name': name || 'Anonymous',
'board': req.params.board,
'tripcode': tripcode,
'capcode': capcode,
'subject': req.body.subject || '',
'date': new Date(),
'message': message || '',
'subject': req.body.subject || null,
'message': message || null,
'thread': req.body.thread || null,
'password': req.body.password || '',
'password': req.body.password || null,
'email': req.body.email || null,
'salt': !req.body.thread ? salt : null,
'spoiler': req.body.spoiler ? true : false,
'userId': userId,
'email': req.body.email || '',
'ip': ip,
'files': files,
'salt': !req.body.thread ? salt : '',
'reports': [],
'globalreports': [],
'spoiler': req.body.spoiler ? true : false,
'replyposts': 0,
'replyimages': 0,
};
let postId;

@ -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'))

@ -0,0 +1,433 @@
body {
font-family: arial, helvetica, sans-serif;
font-size: 10pt;
background: #EEF2FF;
flex: 1;
display: flex;
flex-direction: column;
min-height: 100vh;
margin: 0;
}
.code {
border-left: 10px solid #B7C5D9;
display: block;
padding-left: 5px;
font-family: monospace;
margin: 0.5em 0;
}
.pages a {
text-decoration: none;
}
object {
object-fit: contain;
}
.board-header {
display: flex;
flex-direction: column;
align-items: center;
}
.catalog-tile-button {
width: 100%;
line-height: 30px;
float: left;
background: #B7C5D9;
text-decoration: none;
color: black;
}
.catalog-tile-content {
padding: 5px;
}
.catalog-tile {
margin: 2px;
text-align: center;
max-height: 300px;
width: 250px;
overflow: hidden;
overflow-y: auto;
border: 2px solid #B7C5D9;
box-sizing: border-box;
}
.no-m-p {
margin: 0px;
padding: 0px;
}
.catalog-thumb {
box-shadow: 0 0 3px black;
min-width: 64px;
min-height: 64px;
object-fit: cover;
}
.catalog {
display:flex;
align-items:flex-start;
justify-content: space-evenly;
flex-flow: row wrap;
}
.spoiler {
background: black;
}
.spoiler:hover {
color: white;
}
.mode {
background-color: red;
color: white;
font-weight: bold;
text-align: center;
}
.reports {
background: #fca!important;
border-color: #c97!important;
border-width: 1px 0;
border-style: solid none;
}
.redtext {
color: maroon;
}
.greentext {
color: green;
}
blockquote a {
color: #d00;
}
blockquote {
word-break: break-all;
white-space: pre-wrap;
}
span {
margin-right: 5px;
}
section {
display: flex;
flex-direction: column;
align-items: flex-start;
}
input, textarea {
font-family: arial, helvetica, sans-serif;
font-size: 10pt;
border-radius: 3px;
max-width:100%;
border: none;
margin: 2px;
padding: 5px;
}
.form-wrapper {
align-items: center;
margin: 10px 0;
}
.actions {
background: #D6DAF0;
border-color: #B7C5D9;
border-width: 0 1px 1px 0;
border-style: none solid solid none;
max-width: 100%;
display: flex;
flex-direction: column;
margin: 2px 0;
padding: 2px;
}
.action-wrapper {
display: flex;
flex-direction: column;
align-items: flex-start;
}
.actions label {
margin: 2px 0;
}
.toggle-label:hover {
box-shadow: inset 0 0 100px 100px rgba(255,255,255,.25);
}
.toggle-label {
background: #D6DAF0;
padding: 10px;
border-radius: 3px;
text-align: center;
border: 1px solid lightgray;
max-width: 100%;
box-sizing: border-box;
/*-webkit-appearance: button;
-moz-appearance: button;
appearance: button;*/
}
.toggle {
display: none;
}
.toggle:checked + .form-post {
display: flex;
}
.form-post {
display: flex;
flex-direction: column;
max-width: 100%;
margin-top: 10px;
}
.togglable {
display: none;
}
.user-id {
text-shadow: #000 0px 0px 1px, #000 0px 0px 1px, #000 0px 0px 1px, #000 0px 0px 1px, #000 0px 0px 1px, #000 0px 0px 1px;
color: white;
padding: 0px 2px;
}
.post-check {
position: relative;
top: 3px;
margin: -3px 1px !important;
}
.post-files {
float: left;
margin-right: 10px;
}
.post-data {
margin-top: -10px;
padding-top: 10px;
}
.post-file {
display: inline-flex;
flex-direction: column;
margin: 0 4px;
padding: 2px 0;
}
.post-file-info {
text-align: center;
margin: 2px;
margin-top: 0px;
max-width: 128px;
word-break: break-all;
}
.post-file-src {
margin: 0 auto;
}
figure {
}
input textarea {
padding: 8px;
}
.container {
padding: 10px;
}
.board-title {
color: #af0a0f;
font: bolder 28px Tahoma;
letter-spacing: -2px;
text-align: center;
margin: 0;
}
.no-decoration {
text-decoration: none;
color: white;
}
.banner-check {
display: flex;
align-items: center;
}
.board-banner {
margin: 10px;
max-width: 100%;
}
.board-description {
text-align:center;
margin: 0;
}
.post-message {
/*overflow-y: auto;*/
/*float: left;*/
}
.post-container, .ban {
box-sizing: border-box;
margin: 2px 0;
padding: 2px;
background: #D6DAF0;
border-color: #B7C5D9;
border-width: 0 1px 1px 0;
border-style: none solid solid none;
max-width: 100%;
}
.post-container:target {
background-color: #d6bad0!important;
border-color: #ba9dbf;
}
.post-container.op {
background: none;
border: none;
width: 100%;
}
.post-subject {
color: #0F0C5D;
font-weight: bold;
}
.post-capcode {
font-weight: bold;
color: red;
}
.post-name {
color: #117743;
font-weight: bold;
}
.post-container.op .post-info, .catalog-tile-content .post-info {
background: none;
}
.post-info {
margin: -2px;
/*margin-left: -3px;*/
padding: 2px;
padding-left: 1px;
/*background-color: #B7C5D9;*/
}
.post-info * {
margin-bottom: 0;
margin-top: -2px;
}
.navbar {
border-bottom: 1px solid lightgray;
}
.nav-item {
line-height: 50px;
text-decoration: none;
float: left;
background: #D6DAF0;
padding-left: 10px;
padding-right: 10px;
border-right: 1px solid lightgray;
}
.right {
float: right;
}
.nav-item:hover {
box-shadow: inset 0 0 100px 100px rgba(255,255,255,.25);
}
.footer {
border-top: 1px solid lightgray;
text-align: center;
flex-shrink: 0;
margin-top: auto;
line-height: 50px;
}
table, th, td {
border-bottom: 1px solid lightgray;
border-collapse: collapse;
}
.boards-table {
margin: 0 auto;
}
th {
background: #D6DAF0;
}
th, td {
padding: 5px;
}
hr {
color: lightgray;
/*border-top: 1px solid black;
background: lightgray;*/
}
@media only screen and (max-width: 800px) {
input {
height: 30px;
}
.form-post {
width: 100%;
}
.form-login {
width: 100%;
}
blockquote {
margin: 1em;
}
.post-check {
top: 2px;
margin-left: 2px!important;
height: 8px;
}
.post-container {
width: 100%;
border: none;
}
.catalog-tile {
overflow-y: hidden;
}
.boards-table {
width: 100%;
}
.post-info {
background-color: #B7C5D9;
}
}

@ -1,5 +1,6 @@
mixin post(post, truncate, manage=false, globalmanage=false)
article(id=post.postId class='post-container '+(post.thread ? '' : 'op'))
- const postURL = `/${post.board}/thread/${post.thread || post.postId}#${post.postId}`;
header.post-info
span
label
@ -21,7 +22,7 @@ mixin post(post, truncate, manage=false, globalmanage=false)
span.post-capcode #{post.capcode}
span #{post.date.toLocaleString()}
span.user-id(style=`background: #${post.userId}`) #{post.userId}
span: a(href=`/${post.board}/thread/${post.thread || post.postId}#${post.postId}`) ##{post.postId}
span: a(href=postURL) ##{post.postId}
.post-data
if post.files.length > 0
.post-files
@ -50,11 +51,13 @@ mixin post(post, truncate, manage=false, globalmanage=false)
}
if truncated
blockquote.post-message !{truncatedMessage}
blockquote Message too long. #[a(href=`/${post.board}/thread/${post.thread || post.postId}#${post.postId}`) Click here] to view the full text.
blockquote.left Message too long. #[a(href=postURL) Click here] to view the full text.
else
blockquote.post-message !{post.message}
else
blockquote.post-message !{post.message}
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]
if manage === true
each report in post.reports

Loading…
Cancel
Save