diff --git a/src/main.rs b/src/main.rs
index 101b2b1..a5ced89 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -327,6 +327,8 @@ async fn main() {
app.at("/r/:sub/unsubscribe").post(|r| subreddit::subscriptions_filters(r).boxed());
app.at("/r/:sub/filter").post(|r| subreddit::subscriptions_filters(r).boxed());
app.at("/r/:sub/unfilter").post(|r| subreddit::subscriptions_filters(r).boxed());
+ app.at("/r/:sub/quicklist").post(|r| subreddit::subscriptions_filters(r).boxed());
+ app.at("/r/:sub/unquicklist").post(|r| subreddit::subscriptions_filters(r).boxed());
app.at("/r/:sub/comments/:id").get(|r| post::item(r).boxed());
app.at("/r/:sub/comments/:id/:title").get(|r| post::item(r).boxed());
diff --git a/src/subreddit.rs b/src/subreddit.rs
index 3a07bdc..759aaea 100644
--- a/src/subreddit.rs
+++ b/src/subreddit.rs
@@ -229,6 +229,7 @@ pub async fn subscriptions_filters(req: Request
) -> Result,
let preferences = Preferences::new(&req);
let mut sub_list = preferences.subscriptions;
let mut filters = preferences.filters;
+ let mut quicklist = preferences.quicklist;
// Retrieve list of posts for these subreddits to extract display names
@@ -290,7 +291,14 @@ pub async fn subscriptions_filters(req: Request) -> Result,
} else if action.contains(&"unfilter".to_string()) {
// Remove sub name from filtered list
filters.retain(|s| s.to_lowercase() != part.to_lowercase());
- }
+ } else if action.contains(&"quicklist".to_string()) && !quicklist.contains(&part.to_owned()) {
+ // Add each sub name to the filtered list
+ quicklist.push(part.to_owned());
+ } else if action.contains(&"unquicklist".to_string()) {
+ // Remove sub name from filtered list
+ quicklist.retain(|s| s.to_lowercase() != part.to_lowercase());
+ }
+
}
// Redirect back to subreddit
@@ -326,6 +334,17 @@ pub async fn subscriptions_filters(req: Request) -> Result,
.into(),
);
}
+ if quicklist.is_empty() {
+ response.remove_cookie("quicklist".to_string());
+ } else {
+ response.insert_cookie(
+ Cookie::build(("quicklist", quicklist.join("+")))
+ .path("/")
+ .http_only(true)
+ .expires(OffsetDateTime::now_utc() + Duration::weeks(52))
+ .into(),
+ );
+ }
Ok(response)
}
diff --git a/static/style.css b/static/style.css
index 990ddf4..77e2caa 100644
--- a/static/style.css
+++ b/static/style.css
@@ -429,7 +429,7 @@ a:hover {
}
svg {
- stroke: var(--text);
+ color: var(--text);
}
img[src=""] {
@@ -523,9 +523,16 @@ aside {
margin-bottom: 20px;
}
+#sub_actions {
+ display: grid;
+ grid-template-columns: auto 2fr 1fr;
+ grid-template-rows: 1fr;
+ grid-column-gap: 0px;
+ grid-row-gap: 0px;
+}
+
#user_details,
#sub_details,
-#sub_actions,
#user_actions {
display: grid;
grid-template-columns: repeat(2, 1fr);
@@ -545,6 +552,8 @@ aside {
#user_subscription,
#sub_filter,
#user_filter,
+#sub_quicklist,
+#user_quicklist,
#sub_rss,
#user_rss {
margin-top: 20px;
@@ -554,9 +563,15 @@ aside {
margin-bottom: 20px;
}
+#sub_quicklist button {
+ padding: 0px;
+}
+
.subscribe,
.unsubscribe,
.filter,
+.unquick,
+.quick,
.unfilter {
padding: 10px 20px;
border-radius: 5px;
@@ -568,12 +583,22 @@ aside {
color: var(--foreground);
background-color: var(--accent);
}
+.quick {
+ color: var(--foreground);
+ background-color: var(--accent);
+ height: 18px;
+}
.unsubscribe,
.unfilter {
color: var(--text);
background-color: var(--highlighted);
}
+.unquick {
+ color: var(--text);
+ background-color: var(--highlighted);
+ height: 18px;
+}
/* Feeds */
@@ -2283,4 +2308,4 @@ th {
.download:active {
background-color: var(--background);
-}
\ No newline at end of file
+}
diff --git a/templates/subreddit.html b/templates/subreddit.html
index 4bda993..5d4b2dd 100644
--- a/templates/subreddit.html
+++ b/templates/subreddit.html
@@ -134,6 +134,31 @@
{% endif %}
+
+ {% if prefs.quicklist.contains(sub.name) %}
+
+ {% else %}
+
+ {% endif %}
+
{% if crate::utils::enable_rss() %}