From 269bb0bfb64e49ffb7d201c942c92117b860eb33 Mon Sep 17 00:00:00 2001 From: spikecodes <19519553+spikecodes@users.noreply.github.com> Date: Sat, 30 Jan 2021 21:21:46 -0800 Subject: [PATCH] Convert subscription requests to POST --- Cargo.lock | 16 ++++---- src/main.rs | 2 +- static/style.css | 15 +++---- templates/settings.html | 86 +++++++++++++++++++++------------------- templates/subreddit.html | 8 ++-- 5 files changed, 64 insertions(+), 63 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c5e272..e0c0b8c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -480,9 +480,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.5.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f07aa6688c702439a1be0307b6a94dffe1168569e45b9500c1372bc580740d59" +checksum = "099e596ef14349721d9016f6b80dd3419ea1bf289ab9b44df8e4dfd3a005d5d9" [[package]] name = "byteorder" @@ -531,9 +531,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chunked_transfer" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7477065d45a8fe57167bf3cf8bcd3729b54cfcb81cca49bda2d038ea89ae82ca" +checksum = "fff857943da45f546682664a79488be82e69e43c1a7a2307679ab9afb3a66d2e" [[package]] name = "const_fn" @@ -628,9 +628,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7411863d55df97a419aa64cb4d2f167103ea9d767e2c54a1868b7ac3f6b47129" +checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" dependencies = [ "cfg-if 1.0.0", "crc32fast", @@ -988,9 +988,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0c4e9c72ee9d69b767adebc5f4788462a3b45624acd919475c92597bcaf4f" +checksum = "1cca32fa0182e8c0989459524dc356b8f2b5c10f1b9eb521b7d182c03cf8c5ff" [[package]] name = "libreddit" diff --git a/src/main.rs b/src/main.rs index a2b853d..bc05041 100644 --- a/src/main.rs +++ b/src/main.rs @@ -105,7 +105,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::get().to(subreddit::subscriptions)) + .route("/{action:subscribe|unsubscribe}/", web::post().to(subreddit::subscriptions)) // View post on subreddit .service( web::scope("/comments/{id}/{title}") diff --git a/static/style.css b/static/style.css index 5bf8dce..12d74c1 100644 --- a/static/style.css +++ b/static/style.css @@ -250,18 +250,18 @@ aside { margin-top: 20px; } -#sub_subscription button { +.subscribe, .unsubscribe { padding: 10px 20px; border-radius: 5px; cursor: pointer; } -#subscribe { +.subscribe { color: var(--foreground); background-color: var(--accent); } -#unsubscribe { +.unsubscribe { color: var(--text); background-color: var(--highlighted); } @@ -862,7 +862,7 @@ a.search_subreddit:hover { /* Settings */ -#settings { +#settings, #settings > form { display: flex; flex-direction: column; align-items: center; @@ -937,11 +937,8 @@ input[type="submit"] { margin-right: auto; } -#settings_subs > li > a { +#settings_subs .unsubscribe { margin-left: 30px; - padding: 10px 20px; - border-radius: 5px; - background-color: var(--highlighted); } /* Markdown */ @@ -1018,7 +1015,7 @@ td, th { @media screen and (max-width: 480px) { #version { display: none; } - + .post { grid-template: "post_header post_header post_thumbnail" auto "post_title post_title post_thumbnail" 1fr diff --git a/templates/settings.html b/templates/settings.html index a6d8470..1da5cce 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -8,46 +8,48 @@ {% endblock %} {% block content %} -