diff --git a/src/config.rs b/src/config.rs index a7319d0..1c1adbe 100644 --- a/src/config.rs +++ b/src/config.rs @@ -96,6 +96,10 @@ pub struct Config { #[serde(alias = "LIBREDDIT_DEFAULT_FILTERS")] pub(crate) default_filters: Option, + #[serde(rename = "REDLIB_DEFAULT_QUICKLIST")] + #[serde(alias = "LIBREDDIT_DEFAULT_QUICKLIST")] + pub(crate) default_quicklist: Option, + #[serde(rename = "REDLIB_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION")] #[serde(alias = "LIBREDDIT_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION")] pub(crate) default_disable_visit_reddit_confirmation: Option, @@ -160,6 +164,7 @@ impl Config { default_hide_score: parse("REDLIB_DEFAULT_HIDE_SCORE"), default_subscriptions: parse("REDLIB_DEFAULT_SUBSCRIPTIONS"), default_filters: parse("REDLIB_DEFAULT_FILTERS"), + default_quicklist: parse("REDLIB_DEFAULT_QUICKLIST"), default_disable_visit_reddit_confirmation: parse("REDLIB_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION"), banner: parse("REDLIB_BANNER"), robots_disable_indexing: parse("REDLIB_ROBOTS_DISABLE_INDEXING"), @@ -191,6 +196,7 @@ fn get_setting_from_config(name: &str, config: &Config) -> Option { "REDLIB_DEFAULT_HIDE_SCORE" => config.default_hide_score.clone(), "REDLIB_DEFAULT_SUBSCRIPTIONS" => config.default_subscriptions.clone(), "REDLIB_DEFAULT_FILTERS" => config.default_filters.clone(), + "REDLIB_DEFAULT_QUICKLIST" => config.default_quicklist.clone(), "REDLIB_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION" => config.default_disable_visit_reddit_confirmation.clone(), "REDLIB_BANNER" => config.banner.clone(), "REDLIB_ROBOTS_DISABLE_INDEXING" => config.robots_disable_indexing.clone(), @@ -271,6 +277,12 @@ fn test_default_filters() { assert_eq!(get_setting("REDLIB_DEFAULT_FILTERS"), Some("news+bestof".into())); } +#[test] +#[sealed_test(env = [("REDLIB_DEFAULT_QUICKLIST", "news+popular")])] +fn test_default_quicklist() { + assert_eq!(get_setting("REDLIB_DEFAULT_QUICKLIST"), Some("news+popular".into())); +} + #[test] #[sealed_test] fn test_pushshift() { diff --git a/src/instance_info.rs b/src/instance_info.rs index f73a468..a3bf32d 100644 --- a/src/instance_info.rs +++ b/src/instance_info.rs @@ -152,6 +152,7 @@ impl InstanceInfo { ["Hide HLS notification", &convert(&self.config.default_hide_hls_notification)], ["Subscriptions", &convert(&self.config.default_subscriptions)], ["Filters", &convert(&self.config.default_filters)], + ["Quick Access Feeds", &convert(&self.config.default_quicklist)], ]) .with_header_row(["Default preferences"]), ); @@ -189,7 +190,8 @@ impl InstanceInfo { Default use FFmpeg: {:?}\n Default hide HLS notification: {:?}\n Default subscriptions: {:?}\n - Default filters: {:?}\n", + Default filters: {:?}\n + Default quicklist: {:?}\n", self.package_name, self.crate_version, self.git_commit, @@ -218,6 +220,7 @@ impl InstanceInfo { self.config.default_hide_hls_notification, self.config.default_subscriptions, self.config.default_filters, + self.config.default_quicklist, ) } StringType::Html => self.to_table(), diff --git a/src/settings.rs b/src/settings.rs index c7882a1..0ee2f6f 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -121,7 +121,7 @@ fn set_cookies_method(req: Request, remove_cookies: bool) -> Response response.insert_cookie( Cookie::build((name.to_owned(), value.clone())) diff --git a/src/utils.rs b/src/utils.rs index 5b72a89..68d2ccf 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -624,6 +624,7 @@ pub struct Preferences { pub comment_sort: String, pub post_sort: String, pub subscriptions: Vec, + pub quicklist: Vec, pub filters: Vec, pub hide_awards: String, pub hide_score: String, @@ -679,6 +680,7 @@ impl Preferences { post_sort: setting(req, "post_sort"), subscriptions: setting(req, "subscriptions").split('+').map(String::from).filter(|s| !s.is_empty()).collect(), filters: setting(req, "filters").split('+').map(String::from).filter(|s| !s.is_empty()).collect(), + quicklist: setting(req, "quicklist").split('+').map(String::from).filter(|s| !s.is_empty()).collect(), hide_awards: setting(req, "hide_awards"), hide_score: setting(req, "hide_score"), } diff --git a/templates/settings.html b/templates/settings.html index 00b2220..f61a548 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -153,7 +153,7 @@

Note: settings and subscriptions are saved in browser cookies. Clearing your cookies will reset them.


-

You can restore your current settings and subscriptions after clearing your cookies using this link.

+

You can restore your current settings and subscriptions after clearing your cookies using this link.

{% if prefs.subscriptions.len() > 0 %}
diff --git a/templates/utils.html b/templates/utils.html index d526e7e..44bea0a 100644 --- a/templates/utils.html +++ b/templates/utils.html @@ -41,6 +41,12 @@
Feeds
+ {% if prefs.quicklist.len() > 0 %} +

QUICK ACCESS FEEDS

+ {% for sub in prefs.quicklist %} + {{ sub }} + {% endfor %} + {% endif %}

MAIN FEEDS

Home Popular