mirror of
https://codeberg.org/tacerus/teddit.git
synced 2024-11-25 16:49:26 +01:00
Merge pull request 'search_fix' (#164) from StevenNMeza/teddit:search_fix into main
Reviewed-on: https://codeberg.org/teddit/teddit/pulls/164
This commit is contained in:
commit
dd47ee9e74
15
routes.js
15
routes.js
@ -719,6 +719,21 @@ module.exports = (app, redis, fetch, RedditAPI) => {
|
||||
app.get('/r/:subreddit/search', (req, res, next) => {
|
||||
let subreddit = req.params.subreddit
|
||||
let q = req.query.q
|
||||
|
||||
if (typeof q === "undefined") {
|
||||
return res.render('search', {
|
||||
json: { posts: [] },
|
||||
no_query: true,
|
||||
q: '',
|
||||
restrict_sr: undefined,
|
||||
nsfw: undefined,
|
||||
subreddit: subreddit,
|
||||
sortby: undefined,
|
||||
past: undefined,
|
||||
user_preferences: req.cookies
|
||||
})
|
||||
}
|
||||
|
||||
let restrict_sr = req.query.restrict_sr
|
||||
let nsfw = req.query.nsfw
|
||||
let sortby = req.query.sort
|
||||
|
@ -15,13 +15,13 @@ html
|
||||
input(type="text", name="q", id="q", placeholder="search", value=""+ q +"")
|
||||
div
|
||||
label(for="restrict_sr") limit my search to r/#{subreddit}
|
||||
if restrict_sr === 'on'
|
||||
if !restrict_sr || restrict_sr === 'on'
|
||||
input(type="checkbox", name="restrict_sr", id="restrict_sr", checked="checked")
|
||||
else
|
||||
input(type="checkbox", name="restrict_sr", id="restrict_sr")
|
||||
div
|
||||
label(for="nsfw") include NSFW results
|
||||
if nsfw === 'on'
|
||||
if !nsfw || nsfw === 'on'
|
||||
input(type="checkbox", name="nsfw", id="nsfw", checked="checked")
|
||||
else
|
||||
input(type="checkbox", name="nsfw", id="nsfw")
|
||||
|
Loading…
Reference in New Issue
Block a user