diff --git a/index.js b/index.js index 062f74c..faf80c9 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,6 @@ import { doInit } from "./routes/init.js"; const app = express() const port = 3000; -app.use(express.static('public')); app.set('view engine', 'ejs'); app.enable('view cache'); diff --git a/public/index.css b/public/index.css index 3acd284..6fff367 100644 --- a/public/index.css +++ b/public/index.css @@ -190,4 +190,8 @@ form .header-big, h1 { font-size: 1.4em; +} + +.link { + color: inherit; } \ No newline at end of file diff --git a/routes/comment.js b/routes/comment.js index 967511e..77f885e 100644 --- a/routes/comment.js +++ b/routes/comment.js @@ -29,6 +29,7 @@ router.get('/:id', async (req, res, next) => { continue; } reply.comment = dat[0]; + reply.comment.idOriginal = reply.comment.id; reply.comment.id = reply.childId; reply.comment.type = reply.childType; } diff --git a/routes/init.js b/routes/init.js index 5aff352..003940e 100644 --- a/routes/init.js +++ b/routes/init.js @@ -2,6 +2,7 @@ import { importRouters } from "../lib.js"; import multer from "multer"; import cookieParser from "cookie-parser"; import { initDb } from "../db.js"; +import express from "express"; let db = await initDb(); @@ -89,8 +90,9 @@ async function doInit(app) { doAliases(app); + app.use(express.static('public')); + app.use('/uploads', express.static('uploads')); app.use(auther) - app.use(initr) app.use('/api/form', upload.none()); diff --git a/routes/walls.js b/routes/walls.js index 0284bc6..9324f1c 100644 --- a/routes/walls.js +++ b/routes/walls.js @@ -38,21 +38,31 @@ router.get('/get/:type/:id/:num', async (req, res, next) => { ]); replies.splice(0, 0, { - childType: 'comment', + childType: req.params.type, childId: req.params.id }) + //TODO: make iterator 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 = ?', [ reply.childId ]); + if (reply.childType != 'comment' || dat.length < 1) { reply.comment = 'fail'; continue; } reply.comment = dat[0]; reply.comment.type = reply.childType; - reply.comment.id = reply.childId; + //reply.comment.id = reply.childId; } let comment = replies.splice(0, 1)[0]; diff --git a/views/comment.ejs b/views/comment.ejs index 4fecc84..3e35267 100644 --- a/views/comment.ejs +++ b/views/comment.ejs @@ -1,7 +1,15 @@
-

<%= username %>

+

+ <% if (username) { %> + <%= username %> + <% } else { %> + Context + <% } %> +

<%= content %>
+ <% if (!isNaN(date * 1)) { %>
Posted on <%= new Date(date).toISOString() %>
+ <% } %> <%- 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'}) %>
\ No newline at end of file diff --git a/views/form.ejs b/views/form.ejs index e41e9b5..b79ba45 100644 --- a/views/form.ejs +++ b/views/form.ejs @@ -10,9 +10,7 @@ <%= kv.key %> <% if (kv.type=='textarea' ) { %> - + <% } else { %> value="<%= kv.default %>"> diff --git a/views/replies.ejs b/views/replies.ejs index 518d3f0..556e2eb 100644 --- a/views/replies.ejs +++ b/views/replies.ejs @@ -4,7 +4,7 @@

Replies

- <%- 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'}) %>
<% if (page == 0) { %> @@ -18,11 +18,11 @@ "type": "textarea", "name": "post", "default": "" - }, + }, { "key": "Attachments", "type": "file", - "name": "post", + "name": "file", "default": "" }, {