fix routing order
This commit is contained in:
parent
67db416381
commit
36bee6ef19
90
routes.js
90
routes.js
|
@ -9,6 +9,51 @@ module.exports = (app, redis, fetch, RedditAPI) => {
|
||||||
let processSearches = require('./inc/processSearchResults.js')();
|
let processSearches = require('./inc/processSearchResults.js')();
|
||||||
let processSidebar = require('./inc/processSubredditSidebar.js')();
|
let processSidebar = require('./inc/processSubredditSidebar.js')();
|
||||||
|
|
||||||
|
app.get('/about', (req, res, next) => {
|
||||||
|
return res.render('about', { user_preferences: req.cookies })
|
||||||
|
})
|
||||||
|
|
||||||
|
app.get('/preferences', (req, res, next) => {
|
||||||
|
return res.render('preferences', { user_preferences: req.cookies })
|
||||||
|
})
|
||||||
|
|
||||||
|
app.get('/resetprefs', (req, res, next) => {
|
||||||
|
res.clearCookie('theme')
|
||||||
|
return res.redirect('/preferences')
|
||||||
|
})
|
||||||
|
|
||||||
|
app.get('/privacy', (req, res, next) => {
|
||||||
|
return res.render('privacypolicy', { user_preferences: req.cookies })
|
||||||
|
})
|
||||||
|
|
||||||
|
app.get('/search', (req, res, next) => {
|
||||||
|
let q = req.query.q
|
||||||
|
let restrict_sr = req.query.restrict_sr
|
||||||
|
let nsfw = req.query.nsfw
|
||||||
|
let sortby = req.query.sort
|
||||||
|
let past = req.query.t
|
||||||
|
let after = req.query.after
|
||||||
|
let before = req.query.before
|
||||||
|
if(!after) {
|
||||||
|
after = ''
|
||||||
|
}
|
||||||
|
if(!before) {
|
||||||
|
before = ''
|
||||||
|
}
|
||||||
|
if(restrict_sr !== 'on') {
|
||||||
|
restrict_sr = 'off'
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nsfw !== 'on') {
|
||||||
|
nsfw = 'off'
|
||||||
|
}
|
||||||
|
let d = `&after=${after}`
|
||||||
|
if(before) {
|
||||||
|
d = `&before=${before}`
|
||||||
|
}
|
||||||
|
return res.redirect(`/r/all/search?q=${q}&restrict_sr=${restrict_sr}&nsfw=${nsfw}&sort=${sortby}&t=${past}${d}`)
|
||||||
|
})
|
||||||
|
|
||||||
app.get('/:sort?', (req, res, next) => {
|
app.get('/:sort?', (req, res, next) => {
|
||||||
let past = req.query.t
|
let past = req.query.t
|
||||||
let before = req.query.before
|
let before = req.query.before
|
||||||
|
@ -100,51 +145,6 @@ module.exports = (app, redis, fetch, RedditAPI) => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get('/about', (req, res, next) => {
|
|
||||||
return res.render('about', { user_preferences: req.cookies })
|
|
||||||
})
|
|
||||||
|
|
||||||
app.get('/preferences', (req, res, next) => {
|
|
||||||
return res.render('preferences', { user_preferences: req.cookies })
|
|
||||||
})
|
|
||||||
|
|
||||||
app.get('/resetprefs', (req, res, next) => {
|
|
||||||
res.clearCookie('theme')
|
|
||||||
return res.redirect('/preferences')
|
|
||||||
})
|
|
||||||
|
|
||||||
app.get('/privacy', (req, res, next) => {
|
|
||||||
return res.render('privacypolicy', { user_preferences: req.cookies })
|
|
||||||
})
|
|
||||||
|
|
||||||
app.get('/search', (req, res, next) => {
|
|
||||||
let q = req.query.q
|
|
||||||
let restrict_sr = req.query.restrict_sr
|
|
||||||
let nsfw = req.query.nsfw
|
|
||||||
let sortby = req.query.sort
|
|
||||||
let past = req.query.t
|
|
||||||
let after = req.query.after
|
|
||||||
let before = req.query.before
|
|
||||||
if(!after) {
|
|
||||||
after = ''
|
|
||||||
}
|
|
||||||
if(!before) {
|
|
||||||
before = ''
|
|
||||||
}
|
|
||||||
if(restrict_sr !== 'on') {
|
|
||||||
restrict_sr = 'off'
|
|
||||||
}
|
|
||||||
|
|
||||||
if(nsfw !== 'on') {
|
|
||||||
nsfw = 'off'
|
|
||||||
}
|
|
||||||
let d = `&after=${after}`
|
|
||||||
if(before) {
|
|
||||||
d = `&before=${before}`
|
|
||||||
}
|
|
||||||
return res.redirect(`/r/all/search?q=${q}&restrict_sr=${restrict_sr}&nsfw=${nsfw}&sort=${sortby}&t=${past}${d}`)
|
|
||||||
})
|
|
||||||
|
|
||||||
app.get('/comments/:post_id/:comment?/:comment_id?', (req, res, next) => {
|
app.get('/comments/:post_id/:comment?/:comment_id?', (req, res, next) => {
|
||||||
let post_id = req.params.post_id
|
let post_id = req.params.post_id
|
||||||
let comment = req.params.comment
|
let comment = req.params.comment
|
||||||
|
|
Loading…
Reference in New Issue