created on/off setting for link confirmation

This commit is contained in:
potatoesAreGod 2022-11-22 19:37:27 +01:00
parent 18f6ebe988
commit ff76e59cbb
No known key found for this signature in database
GPG Key ID: B7E6851293EA7B35
6 changed files with 17 additions and 2 deletions

View File

@ -199,6 +199,7 @@ Assign a default value for each setting by passing environment variables to Libr
| `USE_HLS` | `["on", "off"]` | `off` |
| `HIDE_HLS_NOTIFICATION` | `["on", "off"]` | `off` |
| `AUTOPLAY_VIDEOS` | `["on", "off"]` | `off` |
| `LINK_CONFIRMATION` | `["on", "off"]` | `off` |
### Examples

View File

@ -40,6 +40,9 @@
},
"LIBREDDIT_HIDE_HLS_NOTIFICATION": {
"required": false
},
"LIBREDDIT_DEFAULT_LINK_CONFIRMATION": {
"required": false
}
}
}

View File

@ -19,7 +19,7 @@ struct SettingsTemplate {
// CONSTANTS
const PREFS: [&str; 11] = [
const PREFS: [&str; 12] = [
"theme",
"front_page",
"layout",
@ -31,6 +31,7 @@ const PREFS: [&str; 11] = [
"use_hls",
"hide_hls_notification",
"autoplay_videos",
"link_confirmation",
];
// FUNCTIONS

View File

@ -466,6 +466,7 @@ pub struct Preferences {
pub hide_hls_notification: String,
pub use_hls: String,
pub autoplay_videos: String,
pub link_confirmation: String,
pub comment_sort: String,
pub post_sort: String,
pub subscriptions: Vec<String>,
@ -498,6 +499,7 @@ impl Preferences {
use_hls: setting(&req, "use_hls"),
hide_hls_notification: setting(&req, "hide_hls_notification"),
autoplay_videos: setting(&req, "autoplay_videos"),
link_confirmation: setting(&req, "link_confirmation"),
comment_sort: setting(&req, "comment_sort"),
post_sort: setting(&req, "post_sort"),
subscriptions: setting(&req, "subscriptions").split('+').map(String::from).filter(|s| !s.is_empty()).collect(),

View File

@ -35,16 +35,18 @@
</div>
{% block search %}{% endblock %}
<div id="links">
<a id="reddit_link" href="#popup">
<a id="reddit_link" {% if prefs.link_confirmation == "on" %}href="#popup"{% else %}href="https://www.reddit.com{{ url }}"{% endif %}>
<span>reddit</span>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M23 12.0737C23 10.7308 21.9222 9.64226 20.5926 9.64226C19.9435 9.64226 19.3557 9.90274 18.923 10.3244C17.2772 9.12492 15.0099 8.35046 12.4849 8.26135L13.5814 3.05002L17.1643 3.8195C17.2081 4.73947 17.9539 5.47368 18.8757 5.47368C19.8254 5.47368 20.5951 4.69626 20.5951 3.73684C20.5951 2.77769 19.8254 2 18.8758 2C18.2001 2 17.6214 2.39712 17.3404 2.96952L13.3393 2.11066C13.2279 2.08679 13.1116 2.10858 13.016 2.17125C12.9204 2.23393 12.8533 2.33235 12.8295 2.44491L11.6051 8.25987C9.04278 8.33175 6.73904 9.10729 5.07224 10.3201C4.63988 9.90099 4.05398 9.64226 3.40757 9.64226C2.0781 9.64226 1 10.7308 1 12.0737C1 13.0618 1.58457 13.9105 2.4225 14.2909C2.38466 14.5342 2.36545 14.78 2.36505 15.0263C2.36505 18.7673 6.67626 21.8 11.9945 21.8C17.3131 21.8 21.6243 18.7673 21.6243 15.0263C21.6243 14.7794 21.6043 14.5359 21.5678 14.2957C22.4109 13.9175 23 13.0657 23 12.0737Z"/>
</svg>
</a>
{% if prefs.link_confirmation == "on" %}
<div class="popup" id="popup">
<div class="popup-inner">
<h1>You are about to leave Libreddit</h1>
<p>Do you want to continue?</p>
<p>https://www.reddit.com{{ url }}</p>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 639.24 563">
<defs>
<style>.cls-1{fill:#000;}.cls-2{fill:#f8aa00;}</style>
@ -59,6 +61,7 @@
<a id="toreddit" href="https://www.reddit.com{{ url }}" rel="nofollow">Yes, take me to Reddit</a>
</div>
</div>
{% endif %}
<a id="settings_link" href="/settings">
<span>settings</span>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">

View File

@ -79,6 +79,11 @@
<input type="hidden" value="off" name="hide_hls_notification">
<input type="checkbox" name="hide_hls_notification" {% if prefs.hide_hls_notification == "on" %}checked{% endif %}>
</div>
<div id="link_confirmation">
<label for="link_confirmation">Require confirmation for Open in Reddit</label>
<input type="hidden" value="off" name="link_confirmation">
<input type="checkbox" name="link_confirmation" {% if prefs.link_confirmation == "on" %}checked{% endif %}>
</div>
<input id="save" type="submit" value="Save">
</div>
</form>