wall context

This commit is contained in:
biglyderv 2025-02-26 16:37:48 -05:00
parent d65c737a6e
commit f0782b0472
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5
8 changed files with 33 additions and 11 deletions

View file

@ -4,7 +4,6 @@ import { doInit } from "./routes/init.js";
const app = express() const app = express()
const port = 3000; const port = 3000;
app.use(express.static('public'));
app.set('view engine', 'ejs'); app.set('view engine', 'ejs');
app.enable('view cache'); app.enable('view cache');

View file

@ -190,4 +190,8 @@ form .header-big,
h1 { h1 {
font-size: 1.4em; font-size: 1.4em;
}
.link {
color: inherit;
} }

View file

@ -29,6 +29,7 @@ router.get('/:id', async (req, res, next) => {
continue; continue;
} }
reply.comment = dat[0]; reply.comment = dat[0];
reply.comment.idOriginal = reply.comment.id;
reply.comment.id = reply.childId; reply.comment.id = reply.childId;
reply.comment.type = reply.childType; reply.comment.type = reply.childType;
} }

View file

@ -2,6 +2,7 @@ import { importRouters } from "../lib.js";
import multer from "multer"; import multer from "multer";
import cookieParser from "cookie-parser"; import cookieParser from "cookie-parser";
import { initDb } from "../db.js"; import { initDb } from "../db.js";
import express from "express";
let db = await initDb(); let db = await initDb();
@ -89,8 +90,9 @@ async function doInit(app) {
doAliases(app); doAliases(app);
app.use(express.static('public'));
app.use('/uploads', express.static('uploads'));
app.use(auther) app.use(auther)
app.use(initr) app.use(initr)
app.use('/api/form', upload.none()); app.use('/api/form', upload.none());

View file

@ -38,21 +38,31 @@ router.get('/get/:type/:id/:num', async (req, res, next) => {
]); ]);
replies.splice(0, 0, { replies.splice(0, 0, {
childType: 'comment', childType: req.params.type,
childId: req.params.id childId: req.params.id
}) })
//TODO: make iterator
for (let reply of replies) { for (let reply of replies) {
if (reply.childType == 'hub') {
reply.comment = { type: reply.childType, id: reply.childId, content: `The ${reply.childId} hub.`, username: false, date: undefined };
continue;
} else if (reply.childType == 'users') {
reply.comment = { type: reply.childType, id: reply.childId, content: `User ${reply.childId}'s wall.`, username: false, date: undefined };
continue;
}
let dat = await db.all('SELECT * FROM comment WHERE id = ?', [ let dat = await db.all('SELECT * FROM comment WHERE id = ?', [
reply.childId reply.childId
]); ]);
if (reply.childType != 'comment' || dat.length < 1) { if (reply.childType != 'comment' || dat.length < 1) {
reply.comment = 'fail'; reply.comment = 'fail';
continue; continue;
} }
reply.comment = dat[0]; reply.comment = dat[0];
reply.comment.type = reply.childType; reply.comment.type = reply.childType;
reply.comment.id = reply.childId; //reply.comment.id = reply.childId;
} }
let comment = replies.splice(0, 1)[0]; let comment = replies.splice(0, 1)[0];

View file

@ -1,7 +1,15 @@
<div class='main'> <div class='main'>
<h1 class="header-big"><%= username %></h1> <h1 class="header-big">
<% if (username) { %>
<a class='link' href='/users/<%= username %>'><%= username %></a>
<% } else { %>
Context
<% } %>
</h1>
<div><%= content %></div> <div><%= content %></div>
<% if (!isNaN(date * 1)) { %>
<div class='sub'><b>Posted on</b> <%= new Date(date).toISOString() %> </div> <div class='sub'><b>Posted on</b> <%= new Date(date).toISOString() %> </div>
<% } %>
<%- include ('vblock.ejs', {link: `/${type}/${id}`, icon: '/icon.svg', name: 'Original'}) %> <%- include ('vblock.ejs', {link: `/${type}/${id}`, icon: '/icon.svg', name: 'Original'}) %>
<%- include ('vblock.ejs', {link: `/walls/get/${type}/${id}/0`, icon: '/icon.svg', name: 'Replies'}) %> <%- include ('vblock.ejs', {link: `/walls/get/${type}/${id}/0`, icon: '/icon.svg', name: 'Replies'}) %>
</div> </div>

View file

@ -10,9 +10,7 @@
<%= kv.key %> <%= kv.key %>
</span> </span>
<% if (kv.type=='textarea' ) { %> <% if (kv.type=='textarea' ) { %>
<textarea class='form-input' type="<%= kv.type %>" name="<%= kv.name %>"> <textarea class='form-input' type="<%= kv.type %>" name="<%= kv.name %>"><%= kv.default %></textarea>
<%= kv.default %>
</textarea>
<% } else { %> <% } else { %>
<input class='form-input' type="<%= kv.type %>" name="<%= kv.name %>" <%- kv.type=='hidden' ? 'hidden' : '' %> <input class='form-input' type="<%= kv.type %>" name="<%= kv.name %>" <%- kv.type=='hidden' ? 'hidden' : '' %>
value="<%= kv.default %>"> value="<%= kv.default %>">

View file

@ -4,7 +4,7 @@
<div class='main'> <div class='main'>
<h1 class="header-big">Replies</h1> <h1 class="header-big">Replies</h1>
<%- include ('vblock.ejs', {link: `${page - 1}`, icon: '/icon.svg', name: 'Previous'}) %> <%- include ('vblock.ejs', {link: `${Math.max(page - 1,0)}`, icon: '/icon.svg', name: 'Previous'}) %>
<%- include ('vblock.ejs', {link: `${page * 1 + 1}`, icon: '/icon.svg', name: 'Next'}) %> <%- include ('vblock.ejs', {link: `${page * 1 + 1}`, icon: '/icon.svg', name: 'Next'}) %>
</div> </div>
<% if (page == 0) { %> <% if (page == 0) { %>
@ -18,11 +18,11 @@
"type": "textarea", "type": "textarea",
"name": "post", "name": "post",
"default": "" "default": ""
}, },
{ {
"key": "Attachments", "key": "Attachments",
"type": "file", "type": "file",
"name": "post", "name": "file",
"default": "" "default": ""
}, },
{ {