diff options
author | Akshay <[email protected]> | 2024-09-01 22:54:20 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2024-09-01 22:54:20 +0100 |
commit | 9547d3d6019fa14f8330bf89a705025c18525c30 (patch) | |
tree | 41f3e02b88cc33787814311b5ee0726d5e6e2c64 | |
parent | 8b5db5e1954de865933fd4de003fdd21d57add4a (diff) |
support video preview and playback with hls streams
-rw-r--r-- | src/mixins/comment.pug | 3 | ||||
-rw-r--r-- | src/mixins/post.pug | 13 | ||||
-rw-r--r-- | src/public/styles.css | 9 | ||||
-rw-r--r-- | src/views/comments.pug | 9 | ||||
-rw-r--r-- | src/views/index.pug | 3 |
5 files changed, 29 insertions, 8 deletions
diff --git a/src/mixins/comment.pug b/src/mixins/comment.pug index ec01dad..545ee59 100644 --- a/src/mixins/comment.pug +++ b/src/mixins/comment.pug | |||
@@ -10,6 +10,9 @@ mixin comment(com, isfirst) | |||
10 | div.comment-info-container | 10 | div.comment-info-container |
11 | div.info-item u/#{data.author} | 11 | div.info-item u/#{data.author} |
12 | div.info-item ↑ #{fmtnum(data.ups)} | 12 | div.info-item ↑ #{fmtnum(data.ups)} |
13 | if data.collapsed_reason_code == "DELETED" | ||
14 | div.info-item | ||
15 | a(href=`https://undelete.pullpush.io${data.permalink}`) search on undelete | ||
13 | div.comment-body | 16 | div.comment-body |
14 | != data.body_html | 17 | != data.body_html |
15 | div.replies | 18 | div.replies |
diff --git a/src/mixins/post.pug b/src/mixins/post.pug index f5819d4..cbe2365 100644 --- a/src/mixins/post.pug +++ b/src/mixins/post.pug | |||
@@ -4,7 +4,8 @@ mixin post(p) | |||
4 | div.post-container | 4 | div.post-container |
5 | div.post-text | 5 | div.post-text |
6 | div.title-container | 6 | div.title-container |
7 | != p.title | 7 | a(href=`/comments/${p.id}`) |
8 | != p.title | ||
8 | span.domain (#{p.domain}) | 9 | span.domain (#{p.domain}) |
9 | div.info-container | 10 | div.info-container |
10 | div.info-item ↑ #{fmtnum(p.ups)} | 11 | div.info-item ↑ #{fmtnum(p.ups)} |
@@ -17,9 +18,9 @@ mixin post(p) | |||
17 | if p.post_hint == "image" || p.post_hint == "link" | 18 | if p.post_hint == "image" || p.post_hint == "link" |
18 | if p.thumbnail && p.thumbnail != "self" || p.thumbnail != "default" | 19 | if p.thumbnail && p.thumbnail != "self" || p.thumbnail != "default" |
19 | a(href=p.url) | 20 | a(href=p.url) |
20 | img(src=p.thumbnail width='100px') | 21 | img(src=p.thumbnail width='100px' height='100px') |
21 | else if p.post_hint == "hosted:video" | 22 | else if p.post_hint == "hosted:video" |
22 | - var url = p.secure_media.reddit_video.fallback_url | 23 | - var url = p.secure_media.reddit_video.dash_url |
23 | a(href=url) | 24 | a(href=url) |
24 | video(src=url height='100px') | 25 | video(src=url controls data-dashjs-player="" width='100px' height='100px') |
25 | 26 | ||
diff --git a/src/public/styles.css b/src/public/styles.css index 60cd2c3..385b341 100644 --- a/src/public/styles.css +++ b/src/public/styles.css | |||
@@ -134,6 +134,15 @@ nav { | |||
134 | margin-bottom: 10px; | 134 | margin-bottom: 10px; |
135 | } | 135 | } |
136 | 136 | ||
137 | .title-container > a { | ||
138 | color: black; | ||
139 | text-decoration: none; | ||
140 | } | ||
141 | |||
142 | .title-container > a:visited { | ||
143 | color: #999; | ||
144 | } | ||
145 | |||
137 | .comment-info-container { | 146 | .comment-info-container { |
138 | margin-bottom: -12px; | 147 | margin-bottom: -12px; |
139 | } | 148 | } |
diff --git a/src/views/comments.pug b/src/views/comments.pug index 0539b27..2b2b76e 100644 --- a/src/views/comments.pug +++ b/src/views/comments.pug | |||
@@ -6,17 +6,22 @@ html | |||
6 | meta(charset='UTF-8') | 6 | meta(charset='UTF-8') |
7 | title reddit | 7 | title reddit |
8 | link(rel='stylesheet', href='/styles.css') | 8 | link(rel='stylesheet', href='/styles.css') |
9 | script(src="https://cdn.dashjs.org/latest/dash.all.min.js") | ||
9 | body | 10 | body |
10 | main#content | 11 | main#content |
11 | div.hero | 12 | div.hero |
12 | a(href=`/r/${post.subreddit}`) | 13 | a(href=`/r/${post.subreddit}`) |
13 | h4 ← r/#{post.subreddit} | 14 | h4 ← r/#{post.subreddit} |
14 | h2 #{post.title} | 15 | h2 #{post.title} |
16 | |||
15 | if post.post_hint == 'image' | 17 | if post.post_hint == 'image' |
16 | img(src=post.url).post-media | 18 | img(src=post.url).post-media |
17 | else if post.post_hint == 'hosted:video' | 19 | else if post.post_hint == 'hosted:video' |
18 | video(src=post.url).post-media | 20 | - var url = post.secure_media.reddit_video.dash_url |
19 | p.self-text !{post.selftext_html} | 21 | video(controls data-dashjs-player src=`${url}`).post-media |
22 | |||
23 | if post.selftext_html | ||
24 | p.self-text !{post.selftext_html} | ||
20 | 25 | ||
21 | div.comments-container | 26 | div.comments-container |
22 | each child in comments | 27 | each child in comments |
diff --git a/src/views/index.pug b/src/views/index.pug index 526d800..8bbef65 100644 --- a/src/views/index.pug +++ b/src/views/index.pug | |||
@@ -7,6 +7,7 @@ html | |||
7 | meta(charset='UTF-8') | 7 | meta(charset='UTF-8') |
8 | title reddit | 8 | title reddit |
9 | link(rel='stylesheet', href='/styles.css') | 9 | link(rel='stylesheet', href='/styles.css') |
10 | script(src="https://cdn.dashjs.org/latest/dash.all.min.js") | ||
10 | 11 | ||
11 | +subMgmt() | 12 | +subMgmt() |
12 | script. | 13 | script. |
@@ -34,6 +35,8 @@ html | |||
34 | a(href=`/`) home | 35 | a(href=`/`) home |
35 | div.header-item | 36 | div.header-item |
36 | a(href=`/subs`) subscriptions | 37 | a(href=`/subs`) subscriptions |
38 | div.header-item | ||
39 | a(href=`/r/popular`) popular | ||
37 | 40 | ||
38 | div.hero | 41 | div.hero |
39 | a(href=`/r/${subreddit}`) | 42 | a(href=`/r/${subreddit}`) |