diff options
| author | julian laplace <julescarbon@gmail.com> | 2022-10-26 17:05:14 +0200 |
|---|---|---|
| committer | julian laplace <julescarbon@gmail.com> | 2022-10-26 17:05:14 +0200 |
| commit | dd72ab05da17309fd5ee6005cdc1fae686b5fa9e (patch) | |
| tree | 9edc695fffa73a85d94e571f44c7d4c97de71654 /bucky/app | |
| parent | 3de2a5872fd0481568e918a1ea798b3f75ace610 (diff) | |
filter by keyword, thread, or username
Diffstat (limited to 'bucky/app')
| -rw-r--r-- | bucky/app/api.js | 11 | ||||
| -rw-r--r-- | bucky/app/bucky.js | 19 | ||||
| -rw-r--r-- | bucky/app/pages.js | 16 |
3 files changed, 38 insertions, 8 deletions
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, @@ -138,6 +139,16 @@ function route(app) { res.json({ keyword: res.keyword }); } ); + + app.post( + "/api/keyword/new", + bucky.ensureLastlog, + middleware.ensureAuthenticated, + bucky.createKeyword, + function (req, res) { + res.json({ keyword: res.keyword }); + } + ); app.get( "/api/keyword/:keyword", 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" }); }); |
