mirror of
https://codeberg.org/tacerus/teddit.git
synced 2024-11-22 06:49:26 +01:00
make the wikipagelisting logic a bit cleanier
This commit is contained in:
parent
b5fe2e1c1f
commit
933a70cc83
36
routes.js
36
routes.js
@ -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
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user