add a feature for showing upvote ratio in posts #147
This commit is contained in:
parent
bd4bc75298
commit
465e599dee
6
app.js
6
app.js
|
@ -137,6 +137,12 @@ const preferencesMiddleware = (req, res, next) => {
|
||||||
res.cookie('collapse_child_comments', collapseChildComments, { maxAge: 31536000, httpOnly: true })
|
res.cookie('collapse_child_comments', collapseChildComments, { maxAge: 31536000, httpOnly: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let showUpvotedPercentage = req.query.show_upvoted_percentage
|
||||||
|
if(showUpvotedPercentage) {
|
||||||
|
req.cookies.show_upvoted_percentage = showUpvotedPercentage
|
||||||
|
res.cookie('show_upvoted_percentage', showUpvotedPercentage, { maxAge: 31536000, httpOnly: true })
|
||||||
|
}
|
||||||
|
|
||||||
next()
|
next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ module.exports = function(fetch) {
|
||||||
id: post.id,
|
id: post.id,
|
||||||
domain: post.domain,
|
domain: post.domain,
|
||||||
contest_mode: post.contest_mode,
|
contest_mode: post.contest_mode,
|
||||||
|
upvote_ratio: post.upvote_ratio,
|
||||||
comments: null,
|
comments: null,
|
||||||
has_media: false,
|
has_media: false,
|
||||||
media: null,
|
media: null,
|
||||||
|
|
|
@ -1582,6 +1582,7 @@ module.exports = (app, redis, fetch, RedditAPI) => {
|
||||||
let highlight_controversial = req.body.highlight_controversial
|
let highlight_controversial = req.body.highlight_controversial
|
||||||
let post_media_max_height = req.body.post_media_max_height
|
let post_media_max_height = req.body.post_media_max_height
|
||||||
let collapse_child_comments = req.body.collapse_child_comments
|
let collapse_child_comments = req.body.collapse_child_comments
|
||||||
|
let show_upvoted_percentage = req.body.show_upvoted_percentage
|
||||||
|
|
||||||
res.cookie('theme', theme, { maxAge: 365 * 24 * 60 * 60 * 1000, httpOnly: true })
|
res.cookie('theme', theme, { maxAge: 365 * 24 * 60 * 60 * 1000, httpOnly: true })
|
||||||
|
|
||||||
|
@ -1612,6 +1613,12 @@ module.exports = (app, redis, fetch, RedditAPI) => {
|
||||||
collapse_child_comments = 'false'
|
collapse_child_comments = 'false'
|
||||||
res.cookie('collapse_child_comments', collapse_child_comments, { maxAge: 365 * 24 * 60 * 60 * 1000, httpOnly: true })
|
res.cookie('collapse_child_comments', collapse_child_comments, { maxAge: 365 * 24 * 60 * 60 * 1000, httpOnly: true })
|
||||||
|
|
||||||
|
if(show_upvoted_percentage === 'on')
|
||||||
|
show_upvoted_percentage = 'true'
|
||||||
|
else
|
||||||
|
show_upvoted_percentage = 'false'
|
||||||
|
res.cookie('show_upvoted_percentage', show_upvoted_percentage, { maxAge: 365 * 24 * 60 * 60 * 1000, httpOnly: true })
|
||||||
|
|
||||||
return res.redirect('/preferences')
|
return res.redirect('/preferences')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -698,6 +698,11 @@ footer a {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: small;
|
font-size: small;
|
||||||
}
|
}
|
||||||
|
#post .ratio {
|
||||||
|
font-size: 0.6rem;
|
||||||
|
display: block;
|
||||||
|
padding: 4px 0px 5px 0px;
|
||||||
|
}
|
||||||
#post .title {
|
#post .title {
|
||||||
float: left;
|
float: left;
|
||||||
width: calc(100% - 60px);
|
width: calc(100% - 60px);
|
||||||
|
|
|
@ -41,6 +41,9 @@ html
|
||||||
.score
|
.score
|
||||||
div.arrow
|
div.arrow
|
||||||
span #{kFormatter(post.ups)}
|
span #{kFormatter(post.ups)}
|
||||||
|
if user_preferences.show_upvoted_percentage === 'true'
|
||||||
|
- let downvoted = parseInt(post.ups * (1 - post.upvote_ratio))
|
||||||
|
span.ratio(title="~"+ downvoted +" downvoted") #{post.upvote_ratio * 100}%
|
||||||
div.arrow.down
|
div.arrow.down
|
||||||
.title
|
.title
|
||||||
a(href="" + post.url + "", rel="noopener noreferrer")
|
a(href="" + post.url + "", rel="noopener noreferrer")
|
||||||
|
@ -80,6 +83,9 @@ html
|
||||||
.score
|
.score
|
||||||
div.arrow
|
div.arrow
|
||||||
span #{kFormatter(post.crosspost.ups)}
|
span #{kFormatter(post.crosspost.ups)}
|
||||||
|
if user_preferences.show_upvoted_percentage === 'true'
|
||||||
|
- let downvoted = parseInt(post.ups * (1 - post.upvote_ratio))
|
||||||
|
span.ratio(title="~"+ downvoted +" downvoted") #{post.upvote_ratio * 100}%
|
||||||
div.arrow.down
|
div.arrow.down
|
||||||
p.submitted
|
p.submitted
|
||||||
span(title="" + toUTCString(post.crosspost.created) + "") submitted #{timeDifference(post.crosspost.created)} by
|
span(title="" + toUTCString(post.crosspost.created) + "") submitted #{timeDifference(post.crosspost.created)} by
|
||||||
|
|
|
@ -71,6 +71,12 @@ html
|
||||||
input(type="checkbox", name="collapse_child_comments", id="collapse_child_comments", checked="checked")
|
input(type="checkbox", name="collapse_child_comments", id="collapse_child_comments", checked="checked")
|
||||||
else
|
else
|
||||||
input(type="checkbox", name="collapse_child_comments", id="collapse_child_comments")
|
input(type="checkbox", name="collapse_child_comments", id="collapse_child_comments")
|
||||||
|
.setting
|
||||||
|
label(for="show_upvoted_percentage") Show upvote ratio percentage in posts:
|
||||||
|
if(user_preferences.show_upvoted_percentage == 'true')
|
||||||
|
input(type="checkbox", name="show_upvoted_percentage", id="show_upvoted_percentage", checked="checked")
|
||||||
|
else
|
||||||
|
input(type="checkbox", name="show_upvoted_percentage", id="show_upvoted_percentage")
|
||||||
legend Subscribed subreddits
|
legend Subscribed subreddits
|
||||||
.setting
|
.setting
|
||||||
details
|
details
|
||||||
|
|
Loading…
Reference in New Issue