Search fixes (#384)

* Default to searching within subreddit

* Redirect to subreddit from search
This commit is contained in:
Andrew Kaufman 2022-01-05 14:06:41 -08:00 committed by GitHub
parent e9038f4fe2
commit 9c325c2cbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -54,6 +54,10 @@ pub async fn find(req: Request<Body>) -> Result<Response<Body>, String> {
return Ok(redirect("/".to_string()));
}
if query.starts_with("r/") {
return Ok(redirect(format!("/{}", query)));
}
let sub = req.param("sub").unwrap_or_default();
let quarantined = can_access_quarantine(&req, &sub);
// Handle random subreddits

View File

@ -19,7 +19,7 @@
<input id="search" type="text" name="q" placeholder="Search" title="Search libreddit" value="{{ search }}">
{% if root != "/r/" && !root.is_empty() %}
<div id="inside">
<input type="checkbox" name="restrict_sr" id="restrict_sr">
<input type="checkbox" name="restrict_sr" id="restrict_sr" checked>
<label for="restrict_sr" class="search_label" title="Restrict search to this subreddit">in {{ root }}</label>
</div>
{% endif %}