Merge pull request #30 from moosingin3space/master

Add controversial sort order
This commit is contained in:
Spike 2021-01-03 21:15:27 -08:00 committed by GitHub
commit 5934e34ea0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -69,10 +69,10 @@ async fn main() -> std::io::Result<()> {
.route("/r/{sub}/wiki/{page}/", web::get().to(subreddit::wiki))
// SUBREDDIT SERVICES
.route("/r/{sub}/", web::get().to(subreddit::page))
.route("/r/{sub}/{sort:hot|new|top|rising}/", web::get().to(subreddit::page))
.route("/r/{sub}/{sort:hot|new|top|rising|controversial}/", web::get().to(subreddit::page))
// POPULAR SERVICES
.route("/", web::get().to(subreddit::page))
.route("/{sort:best|hot|new|top|rising}/", web::get().to(subreddit::page))
.route("/{sort:best|hot|new|top|rising|controversial}/", web::get().to(subreddit::page))
// POST SERVICES
.route("/{id:.{5,6}}/", web::get().to(post::item))
.route("/r/{sub}/comments/{id}/{title}/", web::get().to(post::item))

View file

@ -17,12 +17,12 @@
<form id="sort">
<div id="sort_options">
{% if sub.name.is_empty() %}
{% call utils::sort("", ["hot", "new", "top", "rising"], sort.0) %}
{% call utils::sort("", ["hot", "new", "top", "rising", "controversial"], sort.0) %}
{% else %}
{% call utils::sort(["/r/", sub.name.as_str()].concat(), ["hot", "new", "top", "rising"], sort.0) %}
{% call utils::sort(["/r/", sub.name.as_str()].concat(), ["hot", "new", "top", "rising", "controversial"], sort.0) %}
{% endif %}
</div>
{% if sort.0 == "top" %}<select id="timeframe" name="t">
{% if sort.0 == "top" || sort.0 == "controversial" %}<select id="timeframe" name="t">
{% call utils::options(sort.1, ["hour", "day", "week", "month", "year", "all"], "day") %}
<input id="sort_submit" type="submit" value="&rarr;">
</select>{% endif %}