From dd72ab05da17309fd5ee6005cdc1fae686b5fa9e Mon Sep 17 00:00:00 2001 From: julian laplace Date: Wed, 26 Oct 2022 17:05:14 +0200 Subject: filter by keyword, thread, or username --- bucky/app/api.js | 11 +++++++++++ bucky/app/bucky.js | 19 +++++++++++-------- bucky/app/pages.js | 16 ++++++++++++++++ 3 files changed, 38 insertions(+), 8 deletions(-) (limited to 'bucky/app') diff --git a/bucky/app/api.js b/bucky/app/api.js index a2f85d0..0645145 100644 --- a/bucky/app/api.js +++ b/bucky/app/api.js @@ -120,6 +120,7 @@ function route(app) { bucky.checkMail, function (req, res) { res.json({ + query: res.query, threads: res.threads, files: res.files, comments: res.comments, @@ -129,6 +130,16 @@ function route(app) { }); } ); + app.post( + "/api/keyword/new", + bucky.ensureLastlog, + middleware.ensureAuthenticated, + bucky.createKeyword, + function (req, res) { + res.json({ keyword: res.keyword }); + } + ); + app.post( "/api/keyword/new", bucky.ensureLastlog, diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index 03a8b87..86982f8 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -67,17 +67,20 @@ var bucky = (module.exports = { }); }, ensureHootstream: function (req, res, next) { + const query = { + thread: parseInt(req.query?.thread) || null, + keyword: req.query?.keyword || null, + username: req.query?.username || null, + limit: req.query?.limit || 20, + offset: req.query?.offset || 0, + }; + query.has_query = query.thread || query.keyword || query.username; Promise.all([ - db.getHootstreamFiles({ - limit: req.query.limit || 20, - offset: req.query.offset || 0, - }), - db.getHootstreamComments({ - limit: req.query.limit || 20, - offset: req.query.offset || 0, - }), + db.getHootstreamFiles(query), + db.getHootstreamComments(query), ]).then(([files, comments]) => { db.getHootstreamThreads({ files, comments }).then((threads) => { + res.query = query; res.files = files; res.comments = comments.map((comment) => { comment.comment = comment.comment.toString(); diff --git a/bucky/app/pages.js b/bucky/app/pages.js index 94ae46e..0967b9b 100644 --- a/bucky/app/pages.js +++ b/bucky/app/pages.js @@ -31,6 +31,22 @@ function route(app) { hoot_text: fortune("hoots"), }); }); + app.get("/stream/:type", middleware.ensureAuthenticated, function (req, res) { + res.render("pages/stream", { + title: fortune("titles"), + hoot_text: fortune("hoots"), + }); + }); + app.get( + "/stream/:type/:id", + middleware.ensureAuthenticated, + function (req, res) { + res.render("pages/stream", { + title: fortune("titles"), + hoot_text: fortune("hoots"), + }); + } + ); app.get("/keywords", middleware.ensureAuthenticated, function (req, res) { res.render("pages/keywords", { title: "Bucky's keywords" }); }); -- cgit v1.2.3-70-g09d2