feature for saving posts

This commit is contained in:
teddit
2021-02-06 20:17:36 +01:00
parent 6cd00468e4
commit 5ae520b5ed
8 changed files with 356 additions and 16 deletions

View File

@@ -13,11 +13,13 @@ div#topbar
if user_preferences.subbed_subreddits && Array.isArray(user_preferences.subbed_subreddits)
a(href="/r/popular") Popular
a(href="/r/all") All
a(href="/saved") Saved
each subreddit in user_preferences.subbed_subreddits
a(href="/r/" + subreddit) #{subreddit}
else
a(href="/r/popular") Popular
a(href="/r/all") All
a(href="/saved") Saved
a(href="/r/AskReddit") AskReddit
a(href="/r/pics") pics
a(href="/r/news") news

View File

@@ -131,8 +131,22 @@ html
span ▶
.preview
img(src=""+ link.images.thumb +"", alt="")
a(href="" + link.permalink + "", class="comments")
| #{link.num_comments} comments
a(href="" + link.permalink + "", class="comments") #{link.num_comments} comments
-
let back_url = "/" + sortby + "§2t="+ (past ? past : '') +""
if(before && !subreddit_front)
back_url = "/" + sortby + "§2t="+ (past ? past : '') +"§1before=" + before + ""
if(after)
back_url = "/" + sortby + "§2t=" + (past ? past : '') + "§1after=" + after + ""
- let saved_post = false
if user_preferences.saved
each post_id in user_preferences.saved
if post_id === link.id
- saved_post = true
if saved_post
a(href="/unsave/" + link.id + "/?rk=" + redis_key + "&b=" + back_url + "") unsave
else
a(href="/save/" + link.id + "/?rk=" + redis_key + "&b=" + back_url + "") save
if json.info.before || json.info.after
.view-more-links
- var subreddit = 'all'

View File

@@ -45,6 +45,17 @@ html
.links
if post.over_18
span.tag.nsfw NSFW
-
let back_url = "/r/" + subreddit + "/comments/" + post.id
let saved_post = false
if user_preferences.saved
each post_id in user_preferences.saved
if post_id === post.id
- saved_post = true
if saved_post
a(href="/unsave/" + post.id + "/?rk=" + redis_key + "&b=" + back_url + "") unsave
else
a(href="/save/" + post.id + "/?rk=" + redis_key + "&b=" + back_url + "") save
if post.crosspost.is_crosspost === true
.crosspost
.title

98
views/saved.pug Normal file
View File

@@ -0,0 +1,98 @@
doctype html
html
head
title saved
include includes/head.pug
body(class=""+ user_preferences.theme +"")
include includes/topbar.pug
if json === null
h1 No saved posts
else
header
a(href="/", class="main")
h1 teddit
.bottom
a(href="/saved", class="subreddit")
h2 saved
#links.sr
if json.links.length === 0
p nothing here
else
each link in json.links
.link
.upvotes
.arrow
span #{kFormatter(link.ups)}
.arrow.down
.image
if link.images
if link.is_self_link
a(href="" + link.permalink + "")
img(src="" + link.images.thumb + "", alt="")
else
a(href=""+ link.url +"", rel="noopener noreferrer")
img(src="" + link.images.thumb + "", alt="")
else
a(href="" + link.permalink + "")
.no-image no image
.entry
.title
if link.is_self_link
a(href="" + link.permalink + "")
h2(class="" + (link.stickied ? 'green' : '') + "") #{cleanTitle(link.title)}
!= link.link_flair
span (#{link.domain})
else
a(href="" + link.url + "", rel="noopener noreferrer")
h2(class="" + (link.stickied ? 'green' : '') + "") #{cleanTitle(link.title)}
!= link.link_flair
span (#{link.domain})
.meta
p.submitted submitted
span(title="" + toUTCString(link.created) + "") #{timeDifference(link.created)} by
if link.author === '[deleted]'
span(class="deleted") [deleted]
else
a(href="/u/" + link.author + "")
| #{link.author}
!= link.user_flair
p.to to
a(href="/r/" + link.subreddit + "")
| #{link.subreddit}
if link.stickied
span(class="green") stickied
.links
if link.over_18
span.tag.nsfw NSFW
if link.selftext_html
details
summary
.line
.line
.line
.selftext
!= unescape(link.selftext_html)
if (link.images && link.images.preview)
style.
details.preview-container img {
width: 100% !important;
height: auto !important;
max-width: none !important;
max-height: none !important;
opacity: 0;
}
details.preview-container[open][data-url="#{link.images.preview}"] .preview {
width: 100%;
height: auto;
background-image: url('#{link.images.preview}');
background-repeat: no-repeat;
background-size: contain;
}
details.preview-container(data-url="" + link.images.preview + "")
summary
span ▶
.preview
img(src=""+ link.images.thumb +"", alt="")
a(href="" + link.permalink + "", class="comments") #{link.num_comments} comments
a(href="/unsave/" + link.id + "") unsave
include includes/footer.pug

View File

@@ -157,8 +157,22 @@ html
span ▶
.preview
img(src=""+ link.images.thumb +"", alt="")
a(href="" + link.permalink + "", class="comments")
| #{link.num_comments} comments
a(href="" + link.permalink + "", class="comments") #{link.num_comments} comments
-
let back_url = "/r/" + subreddit + "/" + sortby + "§2t="+ (past ? past : '') +""
if(before && !subreddit_front)
back_url = "/r/" + subreddit + "/" + sortby + "§2t="+ (past ? past : '') +"§1before=" + before + ""
if(after)
back_url = "/r/" + subreddit + "/" + sortby + "§2t=" + (past ? past : '') + "§1after=" + after + ""
- let saved_post = false
if user_preferences.saved
each post_id in user_preferences.saved
if post_id === link.id
- saved_post = true
if saved_post
a(href="/unsave/" + link.id + "/?rk=" + redis_key + "&b=" + back_url + "") unsave
else
a(href="/save/" + link.id + "/?rk=" + redis_key + "&b=" + back_url + "") save
if json.info.before || json.info.after
.view-more-links
if json.info.before && !subreddit_front