make the wikipagelisting logic a bit cleanier

This commit is contained in:
teddit 2021-04-11 12:13:22 +02:00
parent b5fe2e1c1f
commit 933a70cc83

View File

@ -965,19 +965,11 @@ module.exports = (app, redis, fetch, RedditAPI) => {
if(json) {
console.log(`Got /r/${subreddit} wiki key from redis.`)
json = JSON.parse(json)
if(page !== 'pages') {
return res.render('subreddit_wiki', {
content_html: unescape(json.data.content_html),
subreddit: subreddit,
user_preferences: req.cookies
})
} else {
return res.render('subreddit_wiki', {
content_html: formatWikipagelisting(json, subreddit),
subreddit: subreddit,
user_preferences: req.cookies
})
}
return res.render('subreddit_wiki', {
content_html: (page !== 'pages' ? unescape(json.data.content_html) : formatWikipagelisting(json, subreddit)),
subreddit: subreddit,
user_preferences: req.cookies
})
} else {
let url = ''
if(config.use_reddit_oauth)
@ -995,19 +987,11 @@ module.exports = (app, redis, fetch, RedditAPI) => {
return res.render('subreddit', { json: null, user_preferences: req.cookies })
} else {
console.log(`Fetched the JSON from reddit.com/r/${subreddit}/wiki.`)
if(page !== 'pages') {
return res.render('subreddit_wiki', {
content_html: unescape(json.data.content_html),
subreddit: subreddit,
user_preferences: req.cookies
})
} else {
return res.render('subreddit_wiki', {
content_html: formatWikipagelisting(json, subreddit),
subreddit: subreddit,
user_preferences: req.cookies
})
}
return res.render('subreddit_wiki', {
content_html: (page !== 'pages' ? unescape(json.data.content_html) : formatWikipagelisting(json, subreddit)),
subreddit: subreddit,
user_preferences: req.cookies
})
}
})
})