diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/index.js | 1 | ||||
-rw-r--r-- | src/mixins/post.pug | 9 | ||||
-rw-r--r-- | src/public/styles.css | 34 | ||||
-rw-r--r-- | src/routes/index.js | 4 | ||||
-rw-r--r-- | src/views/comments.pug | 5 | ||||
-rw-r--r-- | src/views/index.pug | 31 |
6 files changed, 61 insertions, 23 deletions
diff --git a/src/index.js b/src/index.js index b59cb53..deccc61 100644 --- a/src/index.js +++ b/src/index.js | |||
@@ -1,7 +1,6 @@ | |||
1 | const express = require("express"); | 1 | const express = require("express"); |
2 | const rateLimit = require("express-rate-limit"); | 2 | const rateLimit = require("express-rate-limit"); |
3 | const path = require("node:path"); | 3 | const path = require("node:path"); |
4 | const geddit = require("./geddit.js"); | ||
5 | const cookieParser = require("cookie-parser"); | 4 | const cookieParser = require("cookie-parser"); |
6 | const app = express(); | 5 | const app = express(); |
7 | const hasher = new Bun.CryptoHasher("sha256", "secret-key"); | 6 | const hasher = new Bun.CryptoHasher("sha256", "secret-key"); |
diff --git a/src/mixins/post.pug b/src/mixins/post.pug index 027e42f..b182e0d 100644 --- a/src/mixins/post.pug +++ b/src/mixins/post.pug | |||
@@ -1,11 +1,12 @@ | |||
1 | include ../utils | 1 | include ../utils |
2 | include postUtils | 2 | include postUtils |
3 | mixin post(p) | 3 | mixin post(p, currentUrl) |
4 | - var from = encodeURIComponent(currentUrl) | ||
4 | article.post | 5 | article.post |
5 | div.post-container | 6 | div(id=`${p.id}`).post-container |
6 | div.post-text | 7 | div.post-text |
7 | div.title-container | 8 | div.title-container |
8 | a(href=`/comments/${p.id}`) | 9 | a(href=`/comments/${p.id}?from=${from}`) |
9 | != p.title | 10 | != p.title |
10 | span.domain (#{p.domain}) | 11 | span.domain (#{p.domain}) |
11 | div.info-container | 12 | div.info-container |
@@ -19,7 +20,7 @@ mixin post(p) | |||
19 | | · | 20 | | · |
20 | a(href=`/r/${p.subreddit}`) r/#{p.subreddit} | 21 | a(href=`/r/${p.subreddit}`) r/#{p.subreddit} |
21 | | · | 22 | | · |
22 | a(href=`/comments/${p.id}`) #{fmtnum (p.num_comments)} ↩ | 23 | a(href=`/comments/${p.id}?from=${from}`) #{fmtnum (p.num_comments)} ↩ |
23 | div.media-preview | 24 | div.media-preview |
24 | if isPostGallery(p) | 25 | if isPostGallery(p) |
25 | - var item = postGalleryItems(p)[0] | 26 | - var item = postGalleryItems(p)[0] |
diff --git a/src/public/styles.css b/src/public/styles.css index d401fc7..754eb54 100644 --- a/src/public/styles.css +++ b/src/public/styles.css | |||
@@ -93,14 +93,14 @@ a:visited { | |||
93 | } | 93 | } |
94 | 94 | ||
95 | .sort-opts { | 95 | .sort-opts { |
96 | display: flex; | 96 | display: grid; |
97 | flex-direction: row; | 97 | margin: 10px; |
98 | flex-wrap: wrap; | ||
99 | justify-content: space-between; | ||
100 | } | 98 | } |
101 | 99 | ||
102 | .sort-opts a { | 100 | .sort-opts { |
103 | margin: 10px; | 101 | grid-template-columns: repeat(2, 1fr); |
102 | grid-template-rows: repeat(5, 1fr); | ||
103 | grid-auto-flow: column; | ||
104 | } | 104 | } |
105 | 105 | ||
106 | .footer { | 106 | .footer { |
@@ -234,6 +234,11 @@ form { | |||
234 | form { | 234 | form { |
235 | width: 40%; | 235 | width: 40%; |
236 | } | 236 | } |
237 | .sort-opts { | ||
238 | grid-template-columns: repeat(9, 1fr); | ||
239 | grid-template-rows: repeat(1, 1fr); | ||
240 | grid-auto-flow: row; | ||
241 | } | ||
237 | } | 242 | } |
238 | 243 | ||
239 | @media (min-width: 1080px) { | 244 | @media (min-width: 1080px) { |
@@ -260,6 +265,11 @@ form { | |||
260 | form { | 265 | form { |
261 | width: 20%; | 266 | width: 20%; |
262 | } | 267 | } |
268 | .sort-opts { | ||
269 | grid-template-columns: repeat(9, 1fr); | ||
270 | grid-template-rows: repeat(1, 1fr); | ||
271 | grid-auto-flow: row; | ||
272 | } | ||
263 | } | 273 | } |
264 | 274 | ||
265 | @media (min-width: 2560px) { | 275 | @media (min-width: 2560px) { |
@@ -267,6 +277,11 @@ form { | |||
267 | flex: 1 1 40%; | 277 | flex: 1 1 40%; |
268 | width: 40%; | 278 | width: 40%; |
269 | } | 279 | } |
280 | .sort-opts { | ||
281 | grid-template-columns: repeat(9, 1fr); | ||
282 | grid-template-rows: repeat(1, 1fr); | ||
283 | grid-auto-flow: row; | ||
284 | } | ||
270 | } | 285 | } |
271 | 286 | ||
272 | .comment, .more { | 287 | .comment, .more { |
@@ -583,3 +598,10 @@ a.nav-link { | |||
583 | .comment-info-container > p { | 598 | .comment-info-container > p { |
584 | margin-top: 0px; | 599 | margin-top: 0px; |
585 | } | 600 | } |
601 | |||
602 | select { | ||
603 | -webkit-appearance: none; | ||
604 | -moz-appearance: none; | ||
605 | text-indent: 1px; | ||
606 | text-overflow: ''; | ||
607 | } | ||
diff --git a/src/routes/index.js b/src/routes/index.js index ef395ed..3e2f04d 100644 --- a/src/routes/index.js +++ b/src/routes/index.js | |||
@@ -6,6 +6,7 @@ const { JWT_KEY } = require("../"); | |||
6 | const { db } = require("../db"); | 6 | const { db } = require("../db"); |
7 | const { authenticateToken, authenticateAdmin } = require("../auth"); | 7 | const { authenticateToken, authenticateAdmin } = require("../auth"); |
8 | const { validateInviteToken } = require("../invite"); | 8 | const { validateInviteToken } = require("../invite"); |
9 | const url = require("url"); | ||
9 | 10 | ||
10 | const router = express.Router(); | 11 | const router = express.Router(); |
11 | const G = new geddit.Geddit(); | 12 | const G = new geddit.Geddit(); |
@@ -54,6 +55,7 @@ router.get("/r/:subreddit", authenticateToken, async (req, res) => { | |||
54 | isMulti, | 55 | isMulti, |
55 | user: req.user, | 56 | user: req.user, |
56 | isSubbed, | 57 | isSubbed, |
58 | currentUrl: req.url, | ||
57 | }); | 59 | }); |
58 | }); | 60 | }); |
59 | 61 | ||
@@ -65,10 +67,10 @@ router.get("/comments/:id", authenticateToken, async (req, res) => { | |||
65 | limit: 50, | 67 | limit: 50, |
66 | }; | 68 | }; |
67 | response = await G.getSubmissionComments(id, params); | 69 | response = await G.getSubmissionComments(id, params); |
68 | |||
69 | res.render("comments", { | 70 | res.render("comments", { |
70 | data: unescape_submission(response), | 71 | data: unescape_submission(response), |
71 | user: req.user, | 72 | user: req.user, |
73 | from: req.query.from, | ||
72 | }); | 74 | }); |
73 | }); | 75 | }); |
74 | 76 | ||
diff --git a/src/views/comments.pug b/src/views/comments.pug index b006d03..17af45a 100644 --- a/src/views/comments.pug +++ b/src/views/comments.pug | |||
@@ -22,6 +22,11 @@ html | |||
22 | +header(user) | 22 | +header(user) |
23 | div.hero | 23 | div.hero |
24 | h3.sub-title | 24 | h3.sub-title |
25 | if from | ||
26 | a(href=`${from}#${post.id}`) <- back | ||
27 | | | ||
28 | | · | ||
29 | | | ||
25 | a(href=`/r/${post.subreddit}`) r/#{post.subreddit} | 30 | a(href=`/r/${post.subreddit}`) r/#{post.subreddit} |
26 | 31 | ||
27 | div.info-container | 32 | div.info-container |
diff --git a/src/views/index.pug b/src/views/index.pug index 9f5a774..0f00efe 100644 --- a/src/views/index.pug +++ b/src/views/index.pug | |||
@@ -35,20 +35,29 @@ html | |||
35 | details | 35 | details |
36 | summary.sorting sorting by #{query.sort + (query.t?' '+query.t:'')} | 36 | summary.sorting sorting by #{query.sort + (query.t?' '+query.t:'')} |
37 | div.sort-opts | 37 | div.sort-opts |
38 | a(href=`/r/${subreddit}?sort=hot`) hot | 38 | div |
39 | a(href=`/r/${subreddit}?sort=new`) new | 39 | a(href=`/r/${subreddit}?sort=hot`) hot |
40 | a(href=`/r/${subreddit}?sort=rising`) rising | 40 | div |
41 | a(href=`/r/${subreddit}?sort=top`) top | 41 | a(href=`/r/${subreddit}?sort=new`) new |
42 | a(href=`/r/${subreddit}?sort=top&t=day`) top day | 42 | div |
43 | a(href=`/r/${subreddit}?sort=top&t=week`) top week | 43 | a(href=`/r/${subreddit}?sort=rising`) rising |
44 | a(href=`/r/${subreddit}?sort=top&t=month`) top month | 44 | div |
45 | a(href=`/r/${subreddit}?sort=top&t=year`) top year | 45 | a(href=`/r/${subreddit}?sort=top`) top |
46 | a(href=`/r/${subreddit}?sort=top&t=all`) top all | 46 | div |
47 | a(href=`/r/${subreddit}?sort=top&t=day`) top day | ||
48 | div | ||
49 | a(href=`/r/${subreddit}?sort=top&t=week`) top week | ||
50 | div | ||
51 | a(href=`/r/${subreddit}?sort=top&t=month`) top month | ||
52 | div | ||
53 | a(href=`/r/${subreddit}?sort=top&t=year`) top year | ||
54 | div | ||
55 | a(href=`/r/${subreddit}?sort=top&t=all`) top all | ||
47 | 56 | ||
48 | if posts | 57 | if posts |
49 | each child in posts.posts | 58 | each child in posts.posts |
50 | +post(child.data) | 59 | +post(child.data, currentUrl) |
51 | 60 | ||
52 | if posts.after | 61 | if posts.after |
53 | div.footer | 62 | div.footer |
54 | div.footer-item | 63 | div.footer-item |