Merge remote-tracking branch 'origin/pull/768'
This commit is contained in:
commit
82fdcf7443
@ -225,7 +225,7 @@ Assign a default value for each instance-specific setting by passing environment
|
|||||||
Assign a default value for each user-modifiable setting by passing environment variables to Libreddit in the format `LIBREDDIT_DEFAULT_{Y}`. Replace `{Y}` with the setting name (see list below) in capital letters.
|
Assign a default value for each user-modifiable setting by passing environment variables to Libreddit in the format `LIBREDDIT_DEFAULT_{Y}`. Replace `{Y}` with the setting name (see list below) in capital letters.
|
||||||
|
|
||||||
| Name | Possible values | Default value |
|
| Name | Possible values | Default value |
|
||||||
|-------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|---------------|
|
|-------------------------|-----------------------------------------------------------------------------------------------------|---------------|
|
||||||
| `THEME` | `["system", "light", "dark", "black", "dracula", "nord", "laserwave", "violet", "gold", "rosebox", "gruvboxdark", "gruvboxlight"]` | `system` |
|
| `THEME` | `["system", "light", "dark", "black", "dracula", "nord", "laserwave", "violet", "gold", "rosebox", "gruvboxdark", "gruvboxlight"]` | `system` |
|
||||||
| `FRONT_PAGE` | `["default", "popular", "all"]` | `default` |
|
| `FRONT_PAGE` | `["default", "popular", "all"]` | `default` |
|
||||||
| `LAYOUT` | `["card", "clean", "compact"]` | `card` |
|
| `LAYOUT` | `["card", "clean", "compact"]` | `card` |
|
||||||
@ -238,9 +238,9 @@ Assign a default value for each user-modifiable setting by passing environment v
|
|||||||
| `HIDE_HLS_NOTIFICATION` | `["on", "off"]` | `off` |
|
| `HIDE_HLS_NOTIFICATION` | `["on", "off"]` | `off` |
|
||||||
| `AUTOPLAY_VIDEOS` | `["on", "off"]` | `off` |
|
| `AUTOPLAY_VIDEOS` | `["on", "off"]` | `off` |
|
||||||
| `SUBSCRIPTIONS` | `+`-delimited list of subreddits (`sub1+sub2+sub3+...`) | _(none)_ |
|
| `SUBSCRIPTIONS` | `+`-delimited list of subreddits (`sub1+sub2+sub3+...`) | _(none)_ |
|
||||||
| `HIDE_AWARDS` | `["on", "off"]` | `off` |
|
| `HIDE_AWARDS` | `["on", "off"]` | `off`
|
||||||
|
| `HIDE_SCORE` | `["on", "off"]` | `off`
|
||||||
| `DISABLE_VISIT_REDDIT_CONFIRMATION` | `["on", "off"]` | `off` |
|
| `DISABLE_VISIT_REDDIT_CONFIRMATION` | `["on", "off"]` | `off` |
|
||||||
| `DISABLE_STATS_COLLECTION | Any string to disable | _(none)_ |
|
|
||||||
|
|
||||||
You can also configure Libreddit with a configuration file. An example `libreddit.toml` can be found below:
|
You can also configure Libreddit with a configuration file. An example `libreddit.toml` can be found below:
|
||||||
|
|
||||||
|
3
app.json
3
app.json
@ -47,6 +47,9 @@
|
|||||||
"LIBREDDIT_DEFAULT_HIDE_AWARDS": {
|
"LIBREDDIT_DEFAULT_HIDE_AWARDS": {
|
||||||
"required": false
|
"required": false
|
||||||
},
|
},
|
||||||
|
"LIBREDDIT_DEFAULT_HIDE_SCORE": {
|
||||||
|
"required": false
|
||||||
|
},
|
||||||
"LIBREDDIT_BANNER": {
|
"LIBREDDIT_BANNER": {
|
||||||
"required": false
|
"required": false
|
||||||
},
|
},
|
||||||
|
@ -56,6 +56,9 @@ pub struct Config {
|
|||||||
#[serde(rename = "LIBREDDIT_DEFAULT_HIDE_AWARDS")]
|
#[serde(rename = "LIBREDDIT_DEFAULT_HIDE_AWARDS")]
|
||||||
pub(crate) default_hide_awards: Option<String>,
|
pub(crate) default_hide_awards: Option<String>,
|
||||||
|
|
||||||
|
#[serde(rename = "LIBREDDIT_DEFAULT_HIDE_SCORE")]
|
||||||
|
pub(crate) default_hide_score: Option<String>,
|
||||||
|
|
||||||
#[serde(rename = "LIBREDDIT_DEFAULT_SUBSCRIPTIONS")]
|
#[serde(rename = "LIBREDDIT_DEFAULT_SUBSCRIPTIONS")]
|
||||||
pub(crate) default_subscriptions: Option<String>,
|
pub(crate) default_subscriptions: Option<String>,
|
||||||
|
|
||||||
@ -101,6 +104,7 @@ impl Config {
|
|||||||
default_use_hls: parse("LIBREDDIT_DEFAULT_USE_HLS"),
|
default_use_hls: parse("LIBREDDIT_DEFAULT_USE_HLS"),
|
||||||
default_hide_hls_notification: parse("LIBREDDIT_DEFAULT_HIDE_HLS"),
|
default_hide_hls_notification: parse("LIBREDDIT_DEFAULT_HIDE_HLS"),
|
||||||
default_hide_awards: parse("LIBREDDIT_DEFAULT_HIDE_AWARDS"),
|
default_hide_awards: parse("LIBREDDIT_DEFAULT_HIDE_AWARDS"),
|
||||||
|
default_hide_score: parse("LIBREDDIT_DEFAULT_HIDE_SCORE"),
|
||||||
default_subscriptions: parse("LIBREDDIT_DEFAULT_SUBSCRIPTIONS"),
|
default_subscriptions: parse("LIBREDDIT_DEFAULT_SUBSCRIPTIONS"),
|
||||||
default_disable_visit_reddit_confirmation: parse("LIBREDDIT_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION"),
|
default_disable_visit_reddit_confirmation: parse("LIBREDDIT_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION"),
|
||||||
banner: parse("LIBREDDIT_BANNER"),
|
banner: parse("LIBREDDIT_BANNER"),
|
||||||
@ -125,6 +129,7 @@ fn get_setting_from_config(name: &str, config: &Config) -> Option<String> {
|
|||||||
"LIBREDDIT_DEFAULT_HIDE_HLS_NOTIFICATION" => config.default_hide_hls_notification.clone(),
|
"LIBREDDIT_DEFAULT_HIDE_HLS_NOTIFICATION" => config.default_hide_hls_notification.clone(),
|
||||||
"LIBREDDIT_DEFAULT_WIDE" => config.default_wide.clone(),
|
"LIBREDDIT_DEFAULT_WIDE" => config.default_wide.clone(),
|
||||||
"LIBREDDIT_DEFAULT_HIDE_AWARDS" => config.default_hide_awards.clone(),
|
"LIBREDDIT_DEFAULT_HIDE_AWARDS" => config.default_hide_awards.clone(),
|
||||||
|
"LIBREDDIT_DEFAULT_HIDE_SCORE" => config.default_hide_score.clone(),
|
||||||
"LIBREDDIT_DEFAULT_SUBSCRIPTIONS" => config.default_subscriptions.clone(),
|
"LIBREDDIT_DEFAULT_SUBSCRIPTIONS" => config.default_subscriptions.clone(),
|
||||||
"LIBREDDIT_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION" => config.default_disable_visit_reddit_confirmation.clone(),
|
"LIBREDDIT_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION" => config.default_disable_visit_reddit_confirmation.clone(),
|
||||||
"LIBREDDIT_BANNER" => config.banner.clone(),
|
"LIBREDDIT_BANNER" => config.banner.clone(),
|
||||||
|
@ -140,6 +140,7 @@ impl InstanceInfo {
|
|||||||
container.add_table(
|
container.add_table(
|
||||||
Table::from([
|
Table::from([
|
||||||
["Hide awards", &convert(&self.config.default_hide_awards)],
|
["Hide awards", &convert(&self.config.default_hide_awards)],
|
||||||
|
["Hide score", &convert(&self.config.default_hide_score)],
|
||||||
["Theme", &convert(&self.config.default_theme)],
|
["Theme", &convert(&self.config.default_theme)],
|
||||||
["Front page", &convert(&self.config.default_front_page)],
|
["Front page", &convert(&self.config.default_front_page)],
|
||||||
["Layout", &convert(&self.config.default_layout)],
|
["Layout", &convert(&self.config.default_layout)],
|
||||||
@ -173,6 +174,7 @@ impl InstanceInfo {
|
|||||||
Config:\n
|
Config:\n
|
||||||
Banner: {:?}\n
|
Banner: {:?}\n
|
||||||
Hide awards: {:?}\n
|
Hide awards: {:?}\n
|
||||||
|
Hide score: {:?}\n
|
||||||
Default theme: {:?}\n
|
Default theme: {:?}\n
|
||||||
Default front page: {:?}\n
|
Default front page: {:?}\n
|
||||||
Default layout: {:?}\n
|
Default layout: {:?}\n
|
||||||
@ -196,6 +198,7 @@ impl InstanceInfo {
|
|||||||
self.config.pushshift,
|
self.config.pushshift,
|
||||||
self.config.banner,
|
self.config.banner,
|
||||||
self.config.default_hide_awards,
|
self.config.default_hide_awards,
|
||||||
|
self.config.default_hide_score,
|
||||||
self.config.default_theme,
|
self.config.default_theme,
|
||||||
self.config.default_front_page,
|
self.config.default_front_page,
|
||||||
self.config.default_layout,
|
self.config.default_layout,
|
||||||
|
@ -19,7 +19,7 @@ struct SettingsTemplate {
|
|||||||
|
|
||||||
// CONSTANTS
|
// CONSTANTS
|
||||||
|
|
||||||
const PREFS: [&str; 13] = [
|
const PREFS: [&str; 14] = [
|
||||||
"theme",
|
"theme",
|
||||||
"front_page",
|
"front_page",
|
||||||
"layout",
|
"layout",
|
||||||
@ -32,6 +32,7 @@ const PREFS: [&str; 13] = [
|
|||||||
"hide_hls_notification",
|
"hide_hls_notification",
|
||||||
"autoplay_videos",
|
"autoplay_videos",
|
||||||
"hide_awards",
|
"hide_awards",
|
||||||
|
"hide_score",
|
||||||
"disable_visit_reddit_confirmation",
|
"disable_visit_reddit_confirmation",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
32
src/utils.rs
32
src/utils.rs
@ -578,6 +578,7 @@ pub struct Preferences {
|
|||||||
pub subscriptions: Vec<String>,
|
pub subscriptions: Vec<String>,
|
||||||
pub filters: Vec<String>,
|
pub filters: Vec<String>,
|
||||||
pub hide_awards: String,
|
pub hide_awards: String,
|
||||||
|
pub hide_score: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustEmbed)]
|
#[derive(RustEmbed)]
|
||||||
@ -597,21 +598,22 @@ impl Preferences {
|
|||||||
}
|
}
|
||||||
Self {
|
Self {
|
||||||
available_themes: themes,
|
available_themes: themes,
|
||||||
theme: setting(req, "theme"),
|
theme: setting(&req, "theme"),
|
||||||
front_page: setting(req, "front_page"),
|
front_page: setting(&req, "front_page"),
|
||||||
layout: setting(req, "layout"),
|
layout: setting(&req, "layout"),
|
||||||
wide: setting(req, "wide"),
|
wide: setting(&req, "wide"),
|
||||||
show_nsfw: setting(req, "show_nsfw"),
|
show_nsfw: setting(&req, "show_nsfw"),
|
||||||
blur_nsfw: setting(req, "blur_nsfw"),
|
blur_nsfw: setting(&req, "blur_nsfw"),
|
||||||
use_hls: setting(req, "use_hls"),
|
use_hls: setting(&req, "use_hls"),
|
||||||
hide_hls_notification: setting(req, "hide_hls_notification"),
|
hide_hls_notification: setting(&req, "hide_hls_notification"),
|
||||||
autoplay_videos: setting(req, "autoplay_videos"),
|
autoplay_videos: setting(&req, "autoplay_videos"),
|
||||||
disable_visit_reddit_confirmation: setting(req, "disable_visit_reddit_confirmation"),
|
disable_visit_reddit_confirmation: setting(&req, "disable_visit_reddit_confirmation"),
|
||||||
comment_sort: setting(req, "comment_sort"),
|
comment_sort: setting(&req, "comment_sort"),
|
||||||
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(),
|
||||||
hide_awards: setting(req, "hide_awards"),
|
hide_awards: setting(&req, "hide_awards"),
|
||||||
|
hide_score: setting(&req, "hide_score"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,13 @@
|
|||||||
{% else if kind == "t1" %}
|
{% else if kind == "t1" %}
|
||||||
<div id="{{ id }}" class="comment">
|
<div id="{{ id }}" class="comment">
|
||||||
<div class="comment_left">
|
<div class="comment_left">
|
||||||
<p class="comment_score" title="{{ score.1 }}">{{ score.0 }}</p>
|
<p class="comment_score" title="{{ score.1 }}">
|
||||||
|
{% if prefs.hide_score != "on" %}
|
||||||
|
{{ score.0 }}
|
||||||
|
{% else %}
|
||||||
|
•
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
<div class="line"></div>
|
<div class="line"></div>
|
||||||
</div>
|
</div>
|
||||||
<details class="comment_right" {% if !collapsed || highlighted %}open{% endif %}>
|
<details class="comment_right" {% if !collapsed || highlighted %}open{% endif %}>
|
||||||
|
@ -83,7 +83,13 @@
|
|||||||
<a href="{{ post.permalink }}">{{ post.title }}</a>{% if post.flags.nsfw %} <small class="nsfw">NSFW</small>{% endif %}
|
<a href="{{ post.permalink }}">{{ post.title }}</a>{% if post.flags.nsfw %} <small class="nsfw">NSFW</small>{% endif %}
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<div class="post_score" title="{{ post.score.1 }}">{{ post.score.0 }}<span class="label"> Upvotes</span></div>
|
<div class="post_score" title="{{ post.score.1 }}">
|
||||||
|
{% if prefs.hide_score != "on" %}
|
||||||
|
{{ post.score.0 }}
|
||||||
|
{% else %}
|
||||||
|
•
|
||||||
|
{% endif %}
|
||||||
|
<span class="label"> Upvotes</span></div>
|
||||||
<div class="post_footer">
|
<div class="post_footer">
|
||||||
<a href="{{ post.permalink }}" class="post_comments" title="{{ post.comments.1 }} comments">{{ post.comments.0 }} comments</a>
|
<a href="{{ post.permalink }}" class="post_comments" title="{{ post.comments.1 }} comments">{{ post.comments.0 }} comments</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -77,7 +77,13 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<div class="comment">
|
<div class="comment">
|
||||||
<div class="comment_left">
|
<div class="comment_left">
|
||||||
<p class="comment_score" title="{{ post.score.1 }}">{{ post.score.0 }}</p>
|
<p class="comment_score" title="{{ post.score.1 }}">
|
||||||
|
{% if prefs.hide_score != "on" %}
|
||||||
|
{{ post.score.0 }}
|
||||||
|
{% else %}
|
||||||
|
•
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
<div class="line"></div>
|
<div class="line"></div>
|
||||||
</div>
|
</div>
|
||||||
<details class="comment_right" open>
|
<details class="comment_right" open>
|
||||||
|
@ -90,6 +90,11 @@
|
|||||||
<input type="hidden" value="off" name="hide_awards">
|
<input type="hidden" value="off" name="hide_awards">
|
||||||
<input type="checkbox" name="hide_awards" id="hide_awards" {% if prefs.hide_awards == "on" %}checked{% endif %}>
|
<input type="checkbox" name="hide_awards" id="hide_awards" {% if prefs.hide_awards == "on" %}checked{% endif %}>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="prefs-group">
|
||||||
|
<label for="hide_score">Hide score</label>
|
||||||
|
<input type="hidden" value="off" name="hide_score">
|
||||||
|
<input type="checkbox" name="hide_score" id="hide_score" {% if prefs.hide_score == "on" %}checked{% endif %}>
|
||||||
|
</div>
|
||||||
<div class="prefs-group">
|
<div class="prefs-group">
|
||||||
<label for="disable_visit_reddit_confirmation">Do not confirm before visiting content on Reddit</label>
|
<label for="disable_visit_reddit_confirmation">Do not confirm before visiting content on Reddit</label>
|
||||||
<input type="hidden" value="off" name="disable_visit_reddit_confirmation">
|
<input type="hidden" value="off" name="disable_visit_reddit_confirmation">
|
||||||
@ -132,7 +137,7 @@
|
|||||||
|
|
||||||
<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 }}&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 }}&blur_nsfw={{ prefs.blur_nsfw }}&use_hls={{ prefs.use_hls }}&hide_hls_notification={{ prefs.hide_hls_notification }}&hide_awards={{ prefs.hide_awards }}&disable_visit_reddit_confirmation={{ prefs.disable_visit_reddit_confirmation }}&subscriptions={{ prefs.subscriptions.join("%2B") }}&autoplay_videos={{ prefs.autoplay_videos }}&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 }}&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 }}&blur_nsfw={{ prefs.blur_nsfw }}&use_hls={{ prefs.use_hls }}&hide_hls_notification={{ prefs.hide_hls_notification }}&hide_awards={{ prefs.hide_awards }}&hide_score={{ prefs.hide_score }}&disable_visit_reddit_confirmation={{ prefs.disable_visit_reddit_confirmation }}&subscriptions={{ prefs.subscriptions.join("%2B") }}&autoplay_videos={{ prefs.autoplay_videos }}&filters={{ prefs.filters.join("%2B") }}">this link</a>.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -52,7 +52,13 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<div class="comment">
|
<div class="comment">
|
||||||
<div class="comment_left">
|
<div class="comment_left">
|
||||||
<p class="comment_score" title="{{ post.score.1 }}">{{ post.score.0 }}</p>
|
<p class="comment_score" title="{{ post.score.1 }}">
|
||||||
|
{% if prefs.hide_score != "on" %}
|
||||||
|
{{ post.score.0 }}
|
||||||
|
{% else %}
|
||||||
|
•
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
<div class="line"></div>
|
<div class="line"></div>
|
||||||
</div>
|
</div>
|
||||||
<details class="comment_right" open>
|
<details class="comment_right" open>
|
||||||
|
@ -147,10 +147,13 @@
|
|||||||
|
|
||||||
<!-- POST BODY -->
|
<!-- POST BODY -->
|
||||||
<div class="post_body">{{ post.body|safe }}</div>
|
<div class="post_body">{{ post.body|safe }}</div>
|
||||||
<div class="post_score" title="{{ post.score.1 }}">{{ post.score.0 }}<span class="label"> Upvotes</span></div>
|
<div class="post_score" title="{{ post.score.1 }}">
|
||||||
|
{% if prefs.hide_score != "on" %}
|
||||||
{% call poll(post) %}
|
{{ post.score.0 }}
|
||||||
|
{% else %}
|
||||||
|
•
|
||||||
|
{% endif %}
|
||||||
|
<span class="label"> Upvotes</span></div>
|
||||||
<div class="post_footer">
|
<div class="post_footer">
|
||||||
<ul id="post_links">
|
<ul id="post_links">
|
||||||
<li class="desktop_item"><a href="{{ post.permalink }}">permalink</a></li>
|
<li class="desktop_item"><a href="{{ post.permalink }}">permalink</a></li>
|
||||||
@ -270,8 +273,13 @@
|
|||||||
<span>{% if post.post_type == "link" %}{{ post.domain }}{% else %}{{ post.post_type }}{% endif %}</span>
|
<span>{% if post.post_type == "link" %}{{ post.domain }}{% else %}{{ post.post_type }}{% endif %}</span>
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<div class="post_score" title="{{ post.score.1 }}">
|
||||||
<div class="post_score" title="{{ post.score.1 }}">{{ post.score.0 }}<span class="label"> Upvotes</span></div>
|
{% if prefs.hide_score != "on" %}
|
||||||
|
{{ post.score.0 }}
|
||||||
|
{% else %}
|
||||||
|
•
|
||||||
|
{% endif %}
|
||||||
|
<span class="label"> Upvotes</span></div>
|
||||||
<div class="post_body post_preview">
|
<div class="post_body post_preview">
|
||||||
{{ post.body|safe }}
|
{{ post.body|safe }}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user