diff --git a/src/main.rs b/src/main.rs index aa47b91..7690c11 100644 --- a/src/main.rs +++ b/src/main.rs @@ -100,8 +100,7 @@ async fn main() -> std::io::Result<()> { .route("/", web::get().to(subreddit::page)) .route("/{sort:hot|new|top|rising|controversial}/", web::get().to(subreddit::page)) // Handle subscribe/unsubscribe - .route("/{action:subscribe|unsubscribe}/", web::post().to(subreddit::set)) - //.route("/unsubscribe/", web::post().to(subreddit::unsubscribe)) + .route("/{action:subscribe|unsubscribe}/", web::post().to(subreddit::subscriptions)) // View post on subreddit .service( web::scope("/comments/{id}/{title}") diff --git a/src/subreddit.rs b/src/subreddit.rs index 2499fa4..8cd46a2 100644 --- a/src/subreddit.rs +++ b/src/subreddit.rs @@ -65,7 +65,7 @@ pub async fn page(req: HttpRequest) -> HttpResponse { } // Sub or unsub by setting subscription cookie using response "Set-Cookie" header -pub async fn set(req: HttpRequest) -> HttpResponse { +pub async fn subscriptions(req: HttpRequest) -> HttpResponse { let mut res = HttpResponse::Found(); let default = cookie(&req, "front_page"); let sub = req diff --git a/src/utils.rs b/src/utils.rs index a8c8373..f8ad46e 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -145,7 +145,7 @@ pub fn prefs(req: HttpRequest) -> Preferences { wide: cookie(&req, "wide"), hide_nsfw: cookie(&req, "hide_nsfw"), comment_sort: cookie(&req, "comment_sort"), - subs: cookie(&req, "subscriptions").split(",").map(|s| s.to_string()).filter(|s| s != "").collect(), + subs: cookie(&req, "subscriptions").split(",").map(String::from).filter(|s| s != "").collect(), } } diff --git a/static/style.css b/static/style.css index 228a33b..9e57140 100644 --- a/static/style.css +++ b/static/style.css @@ -233,7 +233,7 @@ aside { color: var(--accent); } -/* Subscriptions/Favorites */ +/* Subscriptions */ #sub_subscription { margin-top: 20px; @@ -242,20 +242,33 @@ aside { #sub_subscription > input { padding: 10px 20px; border-radius: 5px; - color: var(--foreground); } -#sub_subscription > .add { color: var(--foreground); background-color: var(--accent); } -#sub_subscription > .remove { color: var(--text); background-color: var(--highlighted); } +#sub_subscription > .add { + color: var(--foreground); + background-color: var(--accent); +} -#sub_list { +#sub_subscription > .remove { + color: var(--text); + background-color: var(--highlighted); +} + +/* Subscribed subreddit list */ + +#subscriptions { display: flex; + max-width: 1000px; + margin: 0 auto; align-items: center; - justify-content: center; padding: 10px 20px; } -#subs { +.wide #subscriptions { + max-width: calc(100% - 40px); +} + +#sub_list { border-radius: 5px; box-shadow: var(--shadow); background: var(--outside); @@ -263,11 +276,11 @@ aside { overflow: auto; } -#subs a { +#sub_list > a { padding: 10px 20px; } -#subs > .selected { +#sub_list > .selected { background-color: var(--accent); color: var(--foreground); } @@ -1009,7 +1022,10 @@ td, th { width: calc(100% - 20px); } - #sub_list { padding: 10px; } + #sub_list { + padding: 10px; + max-width: 100%; + } aside, #subreddit, #user { margin: 0; diff --git a/templates/base.html b/templates/base.html index 2451508..2c20be8 100644 --- a/templates/base.html +++ b/templates/base.html @@ -26,8 +26,7 @@ {% block search %}{% endblock %} code - - + {% block sub_list %} {% endblock %} diff --git a/templates/utils.html b/templates/utils.html index 255831d..cbba4ab 100644 --- a/templates/utils.html +++ b/templates/utils.html @@ -42,8 +42,8 @@ {% macro sub_list(current) -%} {% if prefs.subs.len() > 0 %} -