create basic quicklist functionality
This commit is contained in:
parent
e478575706
commit
9856b7fd47
@ -96,6 +96,10 @@ pub struct Config {
|
|||||||
#[serde(alias = "LIBREDDIT_DEFAULT_FILTERS")]
|
#[serde(alias = "LIBREDDIT_DEFAULT_FILTERS")]
|
||||||
pub(crate) default_filters: Option<String>,
|
pub(crate) default_filters: Option<String>,
|
||||||
|
|
||||||
|
#[serde(rename = "REDLIB_DEFAULT_QUICKLIST")]
|
||||||
|
#[serde(alias = "LIBREDDIT_DEFAULT_QUICKLIST")]
|
||||||
|
pub(crate) default_quicklist: Option<String>,
|
||||||
|
|
||||||
#[serde(rename = "REDLIB_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION")]
|
#[serde(rename = "REDLIB_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION")]
|
||||||
#[serde(alias = "LIBREDDIT_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION")]
|
#[serde(alias = "LIBREDDIT_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION")]
|
||||||
pub(crate) default_disable_visit_reddit_confirmation: Option<String>,
|
pub(crate) default_disable_visit_reddit_confirmation: Option<String>,
|
||||||
@ -160,6 +164,7 @@ impl Config {
|
|||||||
default_hide_score: parse("REDLIB_DEFAULT_HIDE_SCORE"),
|
default_hide_score: parse("REDLIB_DEFAULT_HIDE_SCORE"),
|
||||||
default_subscriptions: parse("REDLIB_DEFAULT_SUBSCRIPTIONS"),
|
default_subscriptions: parse("REDLIB_DEFAULT_SUBSCRIPTIONS"),
|
||||||
default_filters: parse("REDLIB_DEFAULT_FILTERS"),
|
default_filters: parse("REDLIB_DEFAULT_FILTERS"),
|
||||||
|
default_quicklist: parse("REDLIB_DEFAULT_QUICKLIST"),
|
||||||
default_disable_visit_reddit_confirmation: parse("REDLIB_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION"),
|
default_disable_visit_reddit_confirmation: parse("REDLIB_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION"),
|
||||||
banner: parse("REDLIB_BANNER"),
|
banner: parse("REDLIB_BANNER"),
|
||||||
robots_disable_indexing: parse("REDLIB_ROBOTS_DISABLE_INDEXING"),
|
robots_disable_indexing: parse("REDLIB_ROBOTS_DISABLE_INDEXING"),
|
||||||
@ -191,6 +196,7 @@ fn get_setting_from_config(name: &str, config: &Config) -> Option<String> {
|
|||||||
"REDLIB_DEFAULT_HIDE_SCORE" => config.default_hide_score.clone(),
|
"REDLIB_DEFAULT_HIDE_SCORE" => config.default_hide_score.clone(),
|
||||||
"REDLIB_DEFAULT_SUBSCRIPTIONS" => config.default_subscriptions.clone(),
|
"REDLIB_DEFAULT_SUBSCRIPTIONS" => config.default_subscriptions.clone(),
|
||||||
"REDLIB_DEFAULT_FILTERS" => config.default_filters.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_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION" => config.default_disable_visit_reddit_confirmation.clone(),
|
||||||
"REDLIB_BANNER" => config.banner.clone(),
|
"REDLIB_BANNER" => config.banner.clone(),
|
||||||
"REDLIB_ROBOTS_DISABLE_INDEXING" => config.robots_disable_indexing.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()));
|
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]
|
#[test]
|
||||||
#[sealed_test]
|
#[sealed_test]
|
||||||
fn test_pushshift() {
|
fn test_pushshift() {
|
||||||
|
@ -152,6 +152,7 @@ impl InstanceInfo {
|
|||||||
["Hide HLS notification", &convert(&self.config.default_hide_hls_notification)],
|
["Hide HLS notification", &convert(&self.config.default_hide_hls_notification)],
|
||||||
["Subscriptions", &convert(&self.config.default_subscriptions)],
|
["Subscriptions", &convert(&self.config.default_subscriptions)],
|
||||||
["Filters", &convert(&self.config.default_filters)],
|
["Filters", &convert(&self.config.default_filters)],
|
||||||
|
["Quick Access Feeds", &convert(&self.config.default_quicklist)],
|
||||||
])
|
])
|
||||||
.with_header_row(["Default preferences"]),
|
.with_header_row(["Default preferences"]),
|
||||||
);
|
);
|
||||||
@ -189,7 +190,8 @@ impl InstanceInfo {
|
|||||||
Default use FFmpeg: {:?}\n
|
Default use FFmpeg: {:?}\n
|
||||||
Default hide HLS notification: {:?}\n
|
Default hide HLS notification: {:?}\n
|
||||||
Default subscriptions: {:?}\n
|
Default subscriptions: {:?}\n
|
||||||
Default filters: {:?}\n",
|
Default filters: {:?}\n
|
||||||
|
Default quicklist: {:?}\n",
|
||||||
self.package_name,
|
self.package_name,
|
||||||
self.crate_version,
|
self.crate_version,
|
||||||
self.git_commit,
|
self.git_commit,
|
||||||
@ -218,6 +220,7 @@ impl InstanceInfo {
|
|||||||
self.config.default_hide_hls_notification,
|
self.config.default_hide_hls_notification,
|
||||||
self.config.default_subscriptions,
|
self.config.default_subscriptions,
|
||||||
self.config.default_filters,
|
self.config.default_filters,
|
||||||
|
self.config.default_quicklist,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
StringType::Html => self.to_table(),
|
StringType::Html => self.to_table(),
|
||||||
|
@ -121,7 +121,7 @@ fn set_cookies_method(req: Request<Body>, remove_cookies: bool) -> Response<Body
|
|||||||
|
|
||||||
let mut response = redirect(&path);
|
let mut response = redirect(&path);
|
||||||
|
|
||||||
for name in [PREFS.to_vec(), vec!["subscriptions", "filters"]].concat() {
|
for name in [PREFS.to_vec(), vec!["subscriptions", "filters", "quicklist"]].concat() {
|
||||||
match form.get(name) {
|
match form.get(name) {
|
||||||
Some(value) => response.insert_cookie(
|
Some(value) => response.insert_cookie(
|
||||||
Cookie::build((name.to_owned(), value.clone()))
|
Cookie::build((name.to_owned(), value.clone()))
|
||||||
|
@ -624,6 +624,7 @@ pub struct Preferences {
|
|||||||
pub comment_sort: String,
|
pub comment_sort: String,
|
||||||
pub post_sort: String,
|
pub post_sort: String,
|
||||||
pub subscriptions: Vec<String>,
|
pub subscriptions: Vec<String>,
|
||||||
|
pub quicklist: Vec<String>,
|
||||||
pub filters: Vec<String>,
|
pub filters: Vec<String>,
|
||||||
pub hide_awards: String,
|
pub hide_awards: String,
|
||||||
pub hide_score: String,
|
pub hide_score: String,
|
||||||
@ -679,6 +680,7 @@ impl Preferences {
|
|||||||
post_sort: setting(req, "post_sort"),
|
post_sort: setting(req, "post_sort"),
|
||||||
subscriptions: setting(req, "subscriptions").split('+').map(String::from).filter(|s| !s.is_empty()).collect(),
|
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(),
|
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_awards: setting(req, "hide_awards"),
|
||||||
hide_score: setting(req, "hide_score"),
|
hide_score: setting(req, "hide_score"),
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@
|
|||||||
</form>
|
</form>
|
||||||
<div id="settings_note">
|
<div id="settings_note">
|
||||||
<p><b>Note:</b> settings and subscriptions are saved in browser cookies. Clearing your cookies will reset them.</p><br>
|
<p><b>Note:</b> settings and subscriptions are saved in browser cookies. Clearing your cookies will reset them.</p><br>
|
||||||
<p>You can restore your current settings and subscriptions after clearing your cookies using <a href="/settings/restore/?theme={{ prefs.theme }}&mascot={{ prefs.mascot }}&front_page={{ prefs.front_page }}&layout={{ prefs.layout }}&wide={{ prefs.wide }}&post_sort={{ prefs.post_sort }}&comment_sort={{ prefs.comment_sort }}&show_nsfw={{ prefs.show_nsfw }}&use_hls={{ prefs.use_hls }}&ffmpeg_video_downloads={{ prefs.ffmpeg_video_downloads }}&hide_hls_notification={{ prefs.hide_hls_notification }}&hide_awards={{ prefs.hide_awards }}&fixed_navbar={{ prefs.fixed_navbar }}&hide_sidebar_and_summary={{ prefs.hide_sidebar_and_summary}}&subscriptions={{ prefs.subscriptions.join("%2B") }}&filters={{ prefs.filters.join("%2B") }}">this link</a>.</p>
|
<p>You can restore your current settings and subscriptions after clearing your cookies using <a href="/settings/restore/?theme={{ prefs.theme }}&mascot={{ prefs.mascot }}&front_page={{ prefs.front_page }}&layout={{ prefs.layout }}&wide={{ prefs.wide }}&post_sort={{ prefs.post_sort }}&comment_sort={{ prefs.comment_sort }}&show_nsfw={{ prefs.show_nsfw }}&use_hls={{ prefs.use_hls }}&ffmpeg_video_downloads={{ prefs.ffmpeg_video_downloads }}&hide_hls_notification={{ prefs.hide_hls_notification }}&hide_awards={{ prefs.hide_awards }}&fixed_navbar={{ prefs.fixed_navbar }}&hide_sidebar_and_summary={{ prefs.hide_sidebar_and_summary}}&subscriptions={{ prefs.subscriptions.join("%2B") }}&filters={{ prefs.filters.join("%2B") }}&quicklist={{ prefs.quicklist.join("%2B") }}">this link</a>.</p>
|
||||||
</div>
|
</div>
|
||||||
{% if prefs.subscriptions.len() > 0 %}
|
{% if prefs.subscriptions.len() > 0 %}
|
||||||
<div class="prefs" id="settings_subs">
|
<div class="prefs" id="settings_subs">
|
||||||
|
@ -41,6 +41,12 @@
|
|||||||
<details id="feeds">
|
<details id="feeds">
|
||||||
<summary>Feeds</summary>
|
<summary>Feeds</summary>
|
||||||
<div id="feed_list">
|
<div id="feed_list">
|
||||||
|
{% if prefs.quicklist.len() > 0 %}
|
||||||
|
<p>QUICK ACCESS FEEDS</p>
|
||||||
|
{% for sub in prefs.quicklist %}
|
||||||
|
<a href="/r/{{ sub }}" {% if sub == current %}class="selected"{% endif %}>{{ sub }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
<p>MAIN FEEDS</p>
|
<p>MAIN FEEDS</p>
|
||||||
<a href="/">Home</a>
|
<a href="/">Home</a>
|
||||||
<a href="/r/popular">Popular</a>
|
<a href="/r/popular">Popular</a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user