aboutsummaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
Diffstat (limited to 'src/views')
-rw-r--r--src/views/comment.pug3
-rw-r--r--src/views/comments.pug2
-rw-r--r--src/views/index.pug42
-rw-r--r--src/views/post.pug9
4 files changed, 50 insertions, 6 deletions
diff --git a/src/views/comment.pug b/src/views/comment.pug
index 24e1a9b..8a60590 100644
--- a/src/views/comment.pug
+++ b/src/views/comment.pug
@@ -6,7 +6,8 @@ mixin comment(com, isfirst)
6 div.more #{data.count} more comments 6 div.more #{data.count} more comments
7 else 7 else
8 div(class=`comment ${isfirst?'first':''}`) 8 div(class=`comment ${isfirst?'first':''}`)
9 div.comment-body !{data.body} 9 div.comment-body
10 != data.body_html
10 div.info-container 11 div.info-container
11 div.info-item by u/#{data.author} 12 div.info-item by u/#{data.author}
12 div.info-item ↑ #{fmtnum(data.ups)} 13 div.info-item ↑ #{fmtnum(data.ups)}
diff --git a/src/views/comments.pug b/src/views/comments.pug
index f7964a3..ff90554 100644
--- a/src/views/comments.pug
+++ b/src/views/comments.pug
@@ -14,7 +14,7 @@ html
14 img(src=post.url).post-media 14 img(src=post.url).post-media
15 else if post.post_hint == 'hosted:video' 15 else if post.post_hint == 'hosted:video'
16 video(src=post.url).post-media 16 video(src=post.url).post-media
17 p.self-text !{post.selftext} 17 p.self-text !{post.selftext_html}
18 hr 18 hr
19 19
20 div.comments-container 20 div.comments-container
diff --git a/src/views/index.pug b/src/views/index.pug
index d017570..f23405f 100644
--- a/src/views/index.pug
+++ b/src/views/index.pug
@@ -1,16 +1,56 @@
1- var subs = []
1doctype html 2doctype html
2html 3html
3 head 4 head
4 meta(charset='UTF-8') 5 meta(charset='UTF-8')
5 title reddit 6 title reddit
6 link(rel='stylesheet', href='/styles.css') 7 link(rel='stylesheet', href='/styles.css')
8 script.
9 function getSubs() {
10 var store = localStorage.getItem('subs');
11 if (store) {
12 return store.split(',').map((n)=>n.replace(/\/?r\//,''));
13 } else {
14 return [];
15 }
16 }
17
18 function subscribe(newsub) {
19 var subs = getSubs();
20 if (!subs.includes(newsub)) {
21 localStorage.setItem('subs',[...subs,newsub]);
22 }
23 }
24
25 function newSubItem(newsub) {
26 var p = document.createElement("p");
27 var text = document.createTextNode(newsub);
28 p.appendChild(text);
29 return p;
30 }
31
32 function genSubListing() {
33 const body = document.body;
34 const subbar = document.createElement('div');
35 subbar.id = 'subscriptions';
36 body.insertBefore(subbar, body.firstChild);
37 getSubs().forEach((item) => {
38 subbar.appendChild(newSubItem(item));
39 });
40 }
41
42 document.addEventListener('DOMContentLoaded', function() {
43 genSubListing();
44 });
7 body 45 body
46
8 main#content 47 main#content
9 div.header 48 div.header
10 a(href=`/r/#{subreddit}`) 49 a(href=`/r/${subreddit}`)
11 h1 r/#{subreddit} 50 h1 r/#{subreddit}
12 if about 51 if about
13 p #{about.public_description} 52 p #{about.public_description}
53 button(onclick=`subscribe("${subreddit}")`) subscribe
14 54
15 each child in posts.posts 55 each child in posts.posts
16 include post 56 include post
diff --git a/src/views/post.pug b/src/views/post.pug
index 183f33f..960ad53 100644
--- a/src/views/post.pug
+++ b/src/views/post.pug
@@ -7,8 +7,8 @@ mixin post(p)
7 != p.title 7 != p.title
8 span.domain (#{p.domain}) 8 span.domain (#{p.domain})
9 div.info-container 9 div.info-container
10 div.info-item by u/#{p.author}
11 div.info-item ↑ #{fmtnum(p.ups)} 10 div.info-item ↑ #{fmtnum(p.ups)}
11 div.info-item by u/#{p.author}
12 div.info-item 12 div.info-item
13 a(href=`/r/${p.subreddit}`) r/#{p.subreddit} 13 a(href=`/r/${p.subreddit}`) r/#{p.subreddit}
14 div.info-item 14 div.info-item
@@ -18,5 +18,8 @@ mixin post(p)
18 if p.thumbnail && p.thumbnail != "self" || p.thumbnail != "default" 18 if p.thumbnail && p.thumbnail != "self" || p.thumbnail != "default"
19 a(href=p.url) 19 a(href=p.url)
20 img(src=p.thumbnail width='100px') 20 img(src=p.thumbnail width='100px')
21 else if p.post_hint == "hosted:video" 21 else if p.post_hint == "hosted:video"
22 video(src=p.secure_media.reddit_video.scrubber_media_url width='100px') 22 - var url = p.secure_media.reddit_video.fallback_url
23 a(href=url)
24 video(src=url height='100px')
25