diff options
author | Akshay <[email protected]> | 2024-10-31 14:41:31 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2024-10-31 14:41:31 +0000 |
commit | 5de14f99c9e9b0d20e8768b1373e172af595c648 (patch) | |
tree | 524752e17b807ce227d31810b082fcd738a1994f /src | |
parent | 9914e4bf6856c0c76e6ee1371f708be946797ad5 (diff) |
improve mobile ui, add pagination
Diffstat (limited to 'src')
-rw-r--r-- | src/geddit.js | 2 | ||||
-rw-r--r-- | src/mixins/post.pug | 4 | ||||
-rw-r--r-- | src/public/styles.css | 68 | ||||
-rw-r--r-- | src/routes/index.js | 3 | ||||
-rw-r--r-- | src/views/index.pug | 6 |
5 files changed, 61 insertions, 22 deletions
diff --git a/src/geddit.js b/src/geddit.js index 93477e7..902d859 100644 --- a/src/geddit.js +++ b/src/geddit.js | |||
@@ -218,8 +218,6 @@ class Geddit { | |||
218 | include_over_18: true | 218 | include_over_18: true |
219 | } | 219 | } |
220 | 220 | ||
221 | console.log(this.host + "/search.json?" + new URLSearchParams(Object.assign(params, options))); | ||
222 | |||
223 | return await fetch(this.host + "/search.json?" + new URLSearchParams(Object.assign(params, options))) | 221 | return await fetch(this.host + "/search.json?" + new URLSearchParams(Object.assign(params, options))) |
224 | .then(res => res.json()) | 222 | .then(res => res.json()) |
225 | .then(json => json.data) | 223 | .then(json => json.data) |
diff --git a/src/mixins/post.pug b/src/mixins/post.pug index fc765ab..6dbebec 100644 --- a/src/mixins/post.pug +++ b/src/mixins/post.pug | |||
@@ -20,10 +20,10 @@ mixin post(p) | |||
20 | if p.gallery_data.items | 20 | if p.gallery_data.items |
21 | - var item = p.gallery_data.items[0] | 21 | - var item = p.gallery_data.items[0] |
22 | - var url = `https://i.redd.it/${item.media_id}.jpg` | 22 | - var url = `https://i.redd.it/${item.media_id}.jpg` |
23 | img(src=url width='100px' height='100px' onclick=`toggleDetails('${p.id}')`) | 23 | img(src=url onclick=`toggleDetails('${p.id}')`) |
24 | else if p.post_hint == "image" || p.post_hint == "link" | 24 | else if p.post_hint == "image" || p.post_hint == "link" |
25 | if p.thumbnail && p.thumbnail != "self" || p.thumbnail != "default" | 25 | if p.thumbnail && p.thumbnail != "self" || p.thumbnail != "default" |
26 | img(src=p.thumbnail width='100px' height='100px' onclick=`toggleDetails('${p.id}')`) | 26 | img(src=p.thumbnail onclick=`toggleDetails('${p.id}')`) |
27 | else if p.post_hint == "hosted:video" | 27 | else if p.post_hint == "hosted:video" |
28 | - var url = p.secure_media.reddit_video.dash_url | 28 | - var url = p.secure_media.reddit_video.dash_url |
29 | video(src=url data-dashjs-player width='100px' height='100px' onclick=`toggleDetails('${p.id}')`) | 29 | video(src=url data-dashjs-player width='100px' height='100px' onclick=`toggleDetails('${p.id}')`) |
diff --git a/src/public/styles.css b/src/public/styles.css index 0d0998d..9616ac8 100644 --- a/src/public/styles.css +++ b/src/public/styles.css | |||
@@ -16,34 +16,43 @@ main { | |||
16 | flex-direction: row; | 16 | flex-direction: row; |
17 | } | 17 | } |
18 | 18 | ||
19 | .footer { | ||
20 | display: flex; | ||
21 | flex-direction: row; | ||
22 | } | ||
23 | |||
24 | .footer-item { | ||
25 | margin-left: auto; | ||
26 | } | ||
27 | |||
19 | nav { | 28 | nav { |
20 | display: flex; | 29 | display: flex; |
21 | align-items: stretch; | 30 | align-items: stretch; |
22 | } | 31 | } |
23 | 32 | ||
24 | .post, .comments-container, .hero, .header { | 33 | .post, .comments-container, .hero, .header, .footer { |
25 | padding: 0.3rem; | 34 | padding: 0.3rem; |
26 | flex: 1 1 100%; | 35 | flex: 1 1 95%; |
27 | font-size: 1rem; | 36 | font-size: 0.8rem; |
28 | width: 100%; | 37 | width: 100%; |
29 | } | 38 | } |
30 | 39 | ||
31 | .info-container, .comment-info-container { | 40 | .info-container, .comment-info-container { |
32 | color: #777; | 41 | color: #777; |
33 | font-size: 0.7rem; | 42 | font-size: 0.6rem; |
34 | display: flex; | 43 | display: flex; |
35 | } | 44 | } |
36 | 45 | ||
37 | .domain { | 46 | .domain { |
38 | color: #777; | 47 | color: #777; |
39 | font-size: 0.7rem; | 48 | font-size: 0.6rem; |
40 | } | 49 | } |
41 | 50 | ||
42 | .info-item, .header-item { | 51 | .info-item, .header-item, .footer-item { |
43 | margin-right: 14px; | 52 | margin-right: 14px; |
44 | } | 53 | } |
45 | 54 | ||
46 | .header-item { | 55 | .header-item, .footer-item { |
47 | position: relative; /* Needed for positioning the pseudo-element */ | 56 | position: relative; /* Needed for positioning the pseudo-element */ |
48 | } | 57 | } |
49 | 58 | ||
@@ -57,23 +66,47 @@ nav { | |||
57 | font-size: 20px; /* Adjust size of the separator */ | 66 | font-size: 20px; /* Adjust size of the separator */ |
58 | } | 67 | } |
59 | 68 | ||
69 | .media-preview img { | ||
70 | object-fit: cover; | ||
71 | width: 3rem; | ||
72 | height: 3rem; | ||
73 | } | ||
74 | |||
60 | @media (min-width: 768px) { | 75 | @media (min-width: 768px) { |
61 | .post, .comments-container, .hero, .header { | 76 | .post, .comments-container, .hero, .header, .footer { |
62 | flex: 1 1 65%; | 77 | flex: 1 1 90%; |
63 | width: 75%; | 78 | width: 90%; |
79 | font-size: 1rem; | ||
64 | } | 80 | } |
65 | .info-container, .comment-info-container { | 81 | .info-container, .comment-info-container { |
66 | font-size: 0.8rem; | 82 | font-size: 0.9rem; |
83 | } | ||
84 | .domain { | ||
85 | font-size: 0.9rem; | ||
86 | } | ||
87 | .media-preview img { | ||
88 | object-fit: cover; | ||
89 | width: 7rem; | ||
90 | height: 7rem; | ||
67 | } | 91 | } |
68 | } | 92 | } |
69 | 93 | ||
70 | @media (min-width: 1080px) { | 94 | @media (min-width: 1080px) { |
71 | .post, .comments-container, .hero, .header { | 95 | .post, .comments-container, .hero, .header, .footer { |
72 | flex: 1 1 50%; | 96 | flex: 1 1 50%; |
73 | width: 50%; | 97 | width: 50%; |
98 | font-size: 1rem; | ||
74 | } | 99 | } |
75 | .info-container, .comment-info-container { | 100 | .info-container, .comment-info-container { |
76 | font-size: 0.8rem; | 101 | font-size: 0.9rem; |
102 | } | ||
103 | .domain { | ||
104 | font-size: 0.9rem; | ||
105 | } | ||
106 | .media-preview img { | ||
107 | object-fit: cover; | ||
108 | width: 7rem; | ||
109 | height: 7rem; | ||
77 | } | 110 | } |
78 | } | 111 | } |
79 | 112 | ||
@@ -121,8 +154,9 @@ nav { | |||
121 | margin-left: auto; | 154 | margin-left: auto; |
122 | } | 155 | } |
123 | 156 | ||
124 | .media-preview img { | 157 | .bottom-links-container { |
125 | object-fit: cover; | 158 | display: flex; |
159 | flex-direction: row; | ||
126 | } | 160 | } |
127 | 161 | ||
128 | .post-media { | 162 | .post-media { |
@@ -183,3 +217,7 @@ p { | |||
183 | summary { | 217 | summary { |
184 | display: none; | 218 | display: none; |
185 | } | 219 | } |
220 | |||
221 | .footer { | ||
222 | padding-bottom: 40px; | ||
223 | } | ||
diff --git a/src/routes/index.js b/src/routes/index.js index 867a223..5f43764 100644 --- a/src/routes/index.js +++ b/src/routes/index.js | |||
@@ -17,11 +17,12 @@ router.get('/r/:subreddit/:sort?', async (req, res) => { | |||
17 | var sort = req.params.sort ? req.params.sort : 'hot'; | 17 | var sort = req.params.sort ? req.params.sort : 'hot'; |
18 | var options = req.query; | 18 | var options = req.query; |
19 | 19 | ||
20 | // var postsReq = G.getSubmissions(sort, `r/${subreddit}`, options); | ||
21 | var postsReq = G.getSubmissions(sort, `${subreddit}`, options); | 20 | var postsReq = G.getSubmissions(sort, `${subreddit}`, options); |
22 | var aboutReq = G.getSubreddit(`${subreddit}`); | 21 | var aboutReq = G.getSubreddit(`${subreddit}`); |
23 | 22 | ||
24 | var [posts, about] = await Promise.all([postsReq, aboutReq]); | 23 | var [posts, about] = await Promise.all([postsReq, aboutReq]); |
24 | console.log(`posts for ${subreddit}`); | ||
25 | console.log(posts.posts.length); | ||
25 | 26 | ||
26 | res.render('index', { subreddit, posts, about }); | 27 | res.render('index', { subreddit, posts, about }); |
27 | }); | 28 | }); |
diff --git a/src/views/index.pug b/src/views/index.pug index 9ac34a4..3df82f7 100644 --- a/src/views/index.pug +++ b/src/views/index.pug | |||
@@ -4,6 +4,7 @@ include ../mixins/sub | |||
4 | doctype html | 4 | doctype html |
5 | html | 5 | html |
6 | head | 6 | head |
7 | meta(name="viewport" content="width=device-width, initial-scale=1.0") | ||
7 | meta(charset='UTF-8') | 8 | meta(charset='UTF-8') |
8 | title reddit | 9 | title reddit |
9 | link(rel='stylesheet', href='/styles.css') | 10 | link(rel='stylesheet', href='/styles.css') |
@@ -56,5 +57,6 @@ html | |||
56 | if posts | 57 | if posts |
57 | each child in posts.posts | 58 | each child in posts.posts |
58 | +post(child.data) | 59 | +post(child.data) |
59 | 60 | div.footer | |
60 | script(src='https://unpkg.com/[email protected]') | 61 | div.footer-item |
62 | a(href=`/r/${subreddit}?after=${posts.after}`) next | ||