aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkshay <[email protected]>2024-11-01 11:28:28 +0000
committerAkshay <[email protected]>2024-11-01 11:28:28 +0000
commit46608309c21aa9fda90fcc6ceadfbbdce2faab5f (patch)
treea65abdb4eb9774fe9b8ed131b00d32f5b59f76a9 /src
parentdff02621742483ddf14ee4bbc6b8555b8a67298f (diff)
even better galleries, fix font sizes everywhere
Diffstat (limited to 'src')
-rw-r--r--src/geddit.js2
-rw-r--r--src/mixins/comment.pug4
-rw-r--r--src/mixins/header.pug9
-rw-r--r--src/mixins/post.pug24
-rw-r--r--src/public/styles.css74
-rw-r--r--src/routes/index.js2
-rw-r--r--src/views/comments.pug12
-rw-r--r--src/views/index.pug19
-rw-r--r--src/views/subs.pug7
9 files changed, 104 insertions, 49 deletions
diff --git a/src/geddit.js b/src/geddit.js
index 902d859..64e1564 100644
--- a/src/geddit.js
+++ b/src/geddit.js
@@ -14,7 +14,7 @@ class Geddit {
14 14
15 async getSubmissions(sort = null, subreddit = null, options = {}) { 15 async getSubmissions(sort = null, subreddit = null, options = {}) {
16 let params = { 16 let params = {
17 limit: 50, 17 limit: 20,
18 include_over_18: true, 18 include_over_18: true,
19 } 19 }
20 20
diff --git a/src/mixins/comment.pug b/src/mixins/comment.pug
index 545ee59..8d341c9 100644
--- a/src/mixins/comment.pug
+++ b/src/mixins/comment.pug
@@ -8,8 +8,8 @@ mixin comment(com, isfirst)
8 else 8 else
9 div(class=`comment ${isfirst?'first':''}`) 9 div(class=`comment ${isfirst?'first':''}`)
10 div.comment-info-container 10 div.comment-info-container
11 div.info-item u/#{data.author} 11 div.info-item #{fmtnum(data.ups)}
12 div.info-item #{fmtnum(data.ups)} 12 div.info-item u/#{data.author} #{data.is_submitter?'(OP)':''}
13 if data.collapsed_reason_code == "DELETED" 13 if data.collapsed_reason_code == "DELETED"
14 div.info-item 14 div.info-item
15 a(href=`https://undelete.pullpush.io${data.permalink}`) search on undelete 15 a(href=`https://undelete.pullpush.io${data.permalink}`) search on undelete
diff --git a/src/mixins/header.pug b/src/mixins/header.pug
new file mode 100644
index 0000000..e3b3870
--- /dev/null
+++ b/src/mixins/header.pug
@@ -0,0 +1,9 @@
1mixin header()
2 div.header
3 div.header-item
4 a(href=`/`) home
5 div.header-item
6 a(href=`/subs`) subscriptions
7 div.header-item
8 a(href=`/r/popular`) popular
9
diff --git a/src/mixins/post.pug b/src/mixins/post.pug
index 8a66d53..20ec7c8 100644
--- a/src/mixins/post.pug
+++ b/src/mixins/post.pug
@@ -9,9 +9,9 @@ mixin post(p)
9 span.domain (#{p.domain}) 9 span.domain (#{p.domain})
10 div.info-container 10 div.info-container
11 p 11 p
12 | #{fmtnum(p.ups)} 12 | #{fmtnum(p.ups)}
13 | &nbsp;·&nbsp; 13 | &nbsp;·&nbsp;
14 a(href=`/comments/${p.id}`) #{fmtnum (p.num_comments)} replies 14 a(href=`/comments/${p.id}`) #{fmtnum (p.num_comments)}
15 | &nbsp;·&nbsp; 15 | &nbsp;·&nbsp;
16 a(href=`/r/${p.subreddit}`) r/#{p.subreddit} 16 a(href=`/r/${p.subreddit}`) r/#{p.subreddit}
17 span.post-author 17 span.post-author
@@ -36,12 +36,14 @@ mixin post(p)
36 if p.gallery_data.items 36 if p.gallery_data.items
37 details(id=`${p.id}`) 37 details(id=`${p.id}`)
38 summary expand gallery 38 summary expand gallery
39 each item in p.gallery_data.items 39 div.gallery
40 - var url = `https://i.redd.it/${item.media_id}.jpg` 40 each item in p.gallery_data.items
41 a(href=`/media/${url}`) 41 - var url = `https://i.redd.it/${item.media_id}.jpg`
42 img(src=url).post-media 42 div.gallery-item
43 a(href=`/media/${url}`)
44 img(src=url)
43 button(onclick=`toggleDetails('${p.id}')`) close 45 button(onclick=`toggleDetails('${p.id}')`) close
44 if (p.post_hint == "image" || p.post_hint == "link") && p.thumbnail && p.thumbnail != "self" && p.thumbnail != "default" 46 if p.post_hint == "image" && p.thumbnail && p.thumbnail != "self" && p.thumbnail != "default"
45 details(id=`${p.id}`) 47 details(id=`${p.id}`)
46 summary expand image 48 summary expand image
47 a(href=`/media/${p.url}`) 49 a(href=`/media/${p.url}`)
@@ -53,4 +55,10 @@ mixin post(p)
53 - var url = p.secure_media.reddit_video.dash_url 55 - var url = p.secure_media.reddit_video.dash_url
54 video(src=url controls data-dashjs-player).post-media 56 video(src=url controls data-dashjs-player).post-media
55 button(onclick=`toggleDetails('${p.id}')`) close 57 button(onclick=`toggleDetails('${p.id}')`) close
56 58 else if p.post_hint == "link" && p.thumbnail && p.thumbnail != "self" && p.thumbnail != "default"
59 details(id=`${p.id}`)
60 summary expand link
61 a(href=`${p.url}`)
62 | #{p.url}
63 br
64 button(onclick=`toggleDetails('${p.id}')`) close
diff --git a/src/public/styles.css b/src/public/styles.css
index 7a27e82..aa2fff1 100644
--- a/src/public/styles.css
+++ b/src/public/styles.css
@@ -2,6 +2,7 @@
2 2
3body { 3body {
4 font-family: 'Inter', sans-serif; 4 font-family: 'Inter', sans-serif;
5 overflow-x: hidden;
5} 6}
6 7
7main { 8main {
@@ -14,6 +15,7 @@ main {
14.header { 15.header {
15 display: flex; 16 display: flex;
16 flex-direction: row; 17 flex-direction: row;
18 justify-content: center;
17} 19}
18 20
19.footer { 21.footer {
@@ -33,10 +35,17 @@ nav {
33.post, .comments-container, .hero, .header, .footer { 35.post, .comments-container, .hero, .header, .footer {
34 padding: 0.3rem; 36 padding: 0.3rem;
35 flex: 1 1 95%; 37 flex: 1 1 95%;
36 font-size: 1rem;
37 width: 100%; 38 width: 100%;
38} 39}
39 40
41.post {
42 font-size: 1rem;
43}
44
45.comments-container {
46 font-size: 0.8rem;
47}
48
40.info-container, .comment-info-container, .more { 49.info-container, .comment-info-container, .more {
41 color: #777; 50 color: #777;
42 font-size: 0.8rem; 51 font-size: 0.8rem;
@@ -45,26 +54,13 @@ nav {
45 54
46.domain { 55.domain {
47 color: #777; 56 color: #777;
48 font-size: 0.6rem; 57 font-size: 0.8rem;
49} 58}
50 59
51.info-item, .header-item, .footer-item { 60.info-item, .header-item, .footer-item {
52 margin-right: 14px; 61 margin-right: 14px;
53} 62}
54 63
55.header-item, .footer-item {
56 position: relative; /* Needed for positioning the pseudo-element */
57}
58
59.header-item:not(:last-child)::after {
60 content: "·"; /* Middle dot as the separator */
61 position: absolute;
62 right: -10px; /* Adjust position as needed */
63 top: 50%;
64 transform: translateY(-50%); /* Center vertically */
65 color: #888; /* Separator color */
66 font-size: 20px; /* Adjust size of the separator */
67}
68 64
69.media-preview img { 65.media-preview img {
70 object-fit: cover; 66 object-fit: cover;
@@ -84,13 +80,18 @@ nav {
84 .post, .comments-container, .hero, .header, .footer { 80 .post, .comments-container, .hero, .header, .footer {
85 flex: 1 1 90%; 81 flex: 1 1 90%;
86 width: 90%; 82 width: 90%;
87 font-size: 1rem; 83 }
84 .post {
85 font-size: 1.3rem;
86 }
87 .comments-container {
88 font-size: 1.1rem;
88 } 89 }
89 .info-container, .comment-info-container, .more { 90 .info-container, .comment-info-container, .more {
90 font-size: 0.9rem; 91 font-size: 1rem;
91 } 92 }
92 .domain { 93 .domain {
93 font-size: 0.9rem; 94 font-size: 1rem;
94 } 95 }
95 .media-preview img, 96 .media-preview img,
96 .media-preview video 97 .media-preview video
@@ -107,13 +108,18 @@ nav {
107 .post, .comments-container, .hero, .header, .footer { 108 .post, .comments-container, .hero, .header, .footer {
108 flex: 1 1 50%; 109 flex: 1 1 50%;
109 width: 50%; 110 width: 50%;
110 font-size: 1rem; 111 }
112 .post {
113 font-size: 1.3rem;
114 }
115 .comments-container {
116 font-size: 1.1rem;
111 } 117 }
112 .info-container, .comment-info-container, .more { 118 .info-container, .comment-info-container, .more {
113 font-size: 0.9rem; 119 font-size: 1rem;
114 } 120 }
115 .domain { 121 .domain {
116 font-size: 0.9rem; 122 font-size: 1rem;
117 } 123 }
118 .media-preview img, 124 .media-preview img,
119 .media-preview video 125 .media-preview video
@@ -154,14 +160,16 @@ nav {
154} 160}
155 161
156.post-container { 162.post-container {
157 align-self: stretch;
158 display: flex; 163 display: flex;
164 flex-direction: row;
165 align-items: center;
159} 166}
160 167
161.post-text { 168.post-text {
169 display: flex;
162 flex-direction: column; 170 flex-direction: column;
163 align-items: stretch; 171 align-items: stretch;
164 justify-content: space-between; 172 justify-content: space-evenly;
165} 173}
166 174
167.media-preview { 175.media-preview {
@@ -178,6 +186,7 @@ nav {
178 display: block; 186 display: block;
179 margin: 0 auto; 187 margin: 0 auto;
180 max-width: 85%; 188 max-width: 85%;
189 padding: 5px;
181} 190}
182 191
183.title-container,.info-container, .comment-info-container { 192.title-container,.info-container, .comment-info-container {
@@ -211,7 +220,7 @@ pre, code {
211} 220}
212 221
213pre { 222pre {
214 padding: 10px; 223 padding: 10px 0px 10px 10px;
215 width: 100%; 224 width: 100%;
216 overflow: auto; 225 overflow: auto;
217} 226}
@@ -242,3 +251,20 @@ a {
242 overflow-wrap: break-word; 251 overflow-wrap: break-word;
243} 252}
244 253
254.gallery {
255 display: flex;
256 overflow-x: auto;
257 scroll-snap-type: x mandatory;
258 padding: 5px;
259}
260
261.gallery-item {
262 flex: 0 0 auto;
263 scroll-snap-align: start;
264 margin-right: 10px;
265}
266
267.gallery img {
268 width: auto;
269 height: 300px;
270}
diff --git a/src/routes/index.js b/src/routes/index.js
index 5f43764..cef05da 100644
--- a/src/routes/index.js
+++ b/src/routes/index.js
@@ -21,8 +21,6 @@ router.get('/r/:subreddit/:sort?', async (req, res) => {
21 var aboutReq = G.getSubreddit(`${subreddit}`); 21 var aboutReq = G.getSubreddit(`${subreddit}`);
22 22
23 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);
26 24
27 res.render('index', { subreddit, posts, about }); 25 res.render('index', { subreddit, posts, about });
28}); 26});
diff --git a/src/views/comments.pug b/src/views/comments.pug
index e335cae..d7a8ab4 100644
--- a/src/views/comments.pug
+++ b/src/views/comments.pug
@@ -1,4 +1,5 @@
1include ../mixins/comment 1include ../mixins/comment
2include ../mixins/header
2 3
3doctype html 4doctype html
4html 5html
@@ -10,8 +11,11 @@ html
10 script(src="https://cdn.dashjs.org/latest/dash.all.min.js") 11 script(src="https://cdn.dashjs.org/latest/dash.all.min.js")
11 body 12 body
12 main#content 13 main#content
14 +header()
13 div.hero 15 div.hero
14 h4 r/#{post.subreddit} 16 h3
17 a(href=`/r/${post.subreddit}`) r/#{post.subreddit}
18
15 h2 #{post.title} 19 h2 #{post.title}
16 20
17 if post.is_gallery && post.is_gallery == true 21 if post.is_gallery && post.is_gallery == true
@@ -28,6 +32,12 @@ html
28 32
29 if post.selftext_html 33 if post.selftext_html
30 p.self-text !{post.selftext_html} 34 p.self-text !{post.selftext_html}
35 div.info-container
36 p
37 | #{fmtnum(post.ups)} ↑
38 | &nbsp;·&nbsp; by u/#{post.author}
39
40 hr
31 41
32 div.comments-container 42 div.comments-container
33 each child in comments 43 each child in comments
diff --git a/src/views/index.pug b/src/views/index.pug
index 3df82f7..3f284f3 100644
--- a/src/views/index.pug
+++ b/src/views/index.pug
@@ -1,5 +1,6 @@
1include ../mixins/post 1include ../mixins/post
2include ../mixins/sub 2include ../mixins/sub
3include ../mixins/header
3- var subs = [] 4- var subs = []
4doctype html 5doctype html
5html 6html
@@ -38,13 +39,7 @@ html
38 document.addEventListener('DOMContentLoaded', ()=>updateButton("#{subreddit}")); 39 document.addEventListener('DOMContentLoaded', ()=>updateButton("#{subreddit}"));
39 body 40 body
40 main#content 41 main#content
41 div.header 42 +header()
42 div.header-item
43 a(href=`/`) home
44 div.header-item
45 a(href=`/subs`) subscriptions
46 div.header-item
47 a(href=`/r/popular`) popular
48 43
49 div.hero 44 div.hero
50 a(href=`/r/${subreddit}`) 45 a(href=`/r/${subreddit}`)
@@ -52,11 +47,17 @@ html
52 if about 47 if about
53 p #{about.public_description} 48 p #{about.public_description}
54 div#button-container 49 div#button-container
55 a(href=`/r/${subreddit}`) 50 ul
51 li
52 a(href=`/r/${subreddit}/hot`) hot
53 li
54 a(href=`/r/${subreddit}/top`) top
55 li
56 a(href=`/r/${subreddit}/top?t=all`) top all
56 57
57 if posts 58 if posts
58 each child in posts.posts 59 each child in posts.posts
59 +post(child.data) 60 +post(child.data)
60 div.footer 61 div.footer
61 div.footer-item 62 div.footer-item
62 a(href=`/r/${subreddit}?after=${posts.after}`) next 63 a(href=`/r/${subreddit}?after=${posts.after}`) next
diff --git a/src/views/subs.pug b/src/views/subs.pug
index a6bbb7b..2d2ee4f 100644
--- a/src/views/subs.pug
+++ b/src/views/subs.pug
@@ -1,4 +1,5 @@
1include ../mixins/sub 1include ../mixins/sub
2include ../mixins/header
2 3
3doctype html 4doctype html
4html 5html
@@ -29,5 +30,7 @@ html
29 document.addEventListener('DOMContentLoaded', buildSubList); 30 document.addEventListener('DOMContentLoaded', buildSubList);
30 body 31 body
31 main#content 32 main#content
32 h1 subscriptions 33 +header()
33 div#subList 34 div.hero
35 h1 subscriptions
36 div#subList