diff --git a/assets/css/default.css b/assets/css/default.css index 5a96638d..3957cfc7 100644 --- a/assets/css/default.css +++ b/assets/css/default.css @@ -1075,4 +1075,11 @@ h1, h2, h3, h4, h5, p, .hidden-channels { width: 300px; height: 200px; +} + +.preference-description { + width: 250px; + padding-left: 10px; + display: inline-block; + vertical-align: top; } \ No newline at end of file diff --git a/locales/en-US.json b/locales/en-US.json index e3d8ce37..f03bf9fc 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -117,6 +117,8 @@ "preferences_thin_mode_label": "Thin mode: ", "preferences_category_misc": "Miscellaneous preferences", "preferences_automatic_instance_redirect_label": "Automatic instance redirection (fallback to redirect.invidious.io): ", + "preferences_show_community_backends_label": "Display community backends? ", + "preferences_show_community_backends_description": "Community backends are backends that are not hosted by the instance owner but by third parties that the instance owner trusts. You decide whether to use them or not!", "preferences_category_subscription": "Subscription preferences", "preferences_annotations_subscribed_label": "Show annotations by default for subscribed channels? ", "Redirect homepage to feed: ": "Redirect homepage to feed: ", diff --git a/locales/es.json b/locales/es.json index 4b960ad4..9a3dfe29 100644 --- a/locales/es.json +++ b/locales/es.json @@ -71,6 +71,8 @@ "preferences_thin_mode_label": "Modo compacto: ", "preferences_category_misc": "Preferencias misceláneas", "preferences_automatic_instance_redirect_label": "Redirección automática de instancia (segunda opción a redirect.invidious.io): ", + "preferences_show_community_backends_label": "Mostrar backends comunitarios? ", + "preferences_show_community_backends_description": "Los backends comunitarios son backends que no están alojados por el propietario de la instancia, sino por terceros en los que el propietario de la instancia confía. ¡Tú decides si usarlos o no!", "preferences_category_subscription": "Preferencias de la suscripción", "preferences_annotations_subscribed_label": "¿Mostrar anotaciones por defecto para los canales suscritos? ", "Redirect homepage to feed: ": "Redirigir la página de inicio a la fuente: ", diff --git a/src/invidious/config.cr b/src/invidious/config.cr index 75c842b5..0bf0ca43 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -59,6 +59,7 @@ struct ConfigPreferences property hidden_channels : Array(String)? = nil @[YAML::Field(ignore: true)] property default_trending_type : Invidious::Routes::Feeds::TrendingTypes = Invidious::Routes::Feeds::TrendingTypes::Default + property show_community_backends : Bool = false def to_tuple {% begin %} @@ -95,6 +96,7 @@ class Config property note : String = "" property domain : Array(String) = [] of String + property community : Bool = false # Indicates if this companion instance uses the built-in proxy property builtin_proxy : Bool = false diff --git a/src/invidious/routes/preferences.cr b/src/invidious/routes/preferences.cr index f1c81b19..e42b68bc 100644 --- a/src/invidious/routes/preferences.cr +++ b/src/invidious/routes/preferences.cr @@ -172,6 +172,10 @@ module Invidious::Routes::PreferencesRoute default_trending_type = env.params.body["default_trending_type"]?.try &.as(String) default_trending_type ||= Invidious::Routes::Feeds::TrendingTypes::Default + show_community_backends = env.params.body["show_community_backends"]?.try &.as(String) + show_community_backends ||= "off" + show_community_backends= show_community_backends == "on" + # Convert to JSON and back again to take advantage of converters used for compatibility preferences = Preferences.from_json({ annotations: annotations, @@ -211,6 +215,7 @@ module Invidious::Routes::PreferencesRoute default_playlist: default_playlist, hidden_channels: hidden_channels, default_trending_type: default_trending_type, + show_community_backends: show_community_backends, }.to_json) if user = env.get? "user" diff --git a/src/invidious/user/preferences.cr b/src/invidious/user/preferences.cr index 55da7350..112200f8 100644 --- a/src/invidious/user/preferences.cr +++ b/src/invidious/user/preferences.cr @@ -59,6 +59,7 @@ struct Preferences property hidden_channels : Array(String)? = nil property default_trending_type : Invidious::Routes::Feeds::TrendingTypes = Invidious::Routes::Feeds::TrendingTypes::Default property default_playlist : String? = nil + property show_community_backends : Bool = false module BoolToString def self.to_json(value : String, json : JSON::Builder) diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr index a3f437c4..71bbf37c 100644 --- a/src/invidious/views/template.ecr +++ b/src/invidious/views/template.ecr @@ -119,6 +119,7 @@ Switch Backend: <% if domain %> <% CONFIG.invidious_companion.each_with_index do | companion, index | %> + <% next if companion.community && !preferences.show_community_backends %> <% host_backend = env.request.headers["Host"].sub(/([^.]+)(\d+)/, "\\1#{index+1}") %> <% is_current_backend_host = host_backend == env.request.headers["Host"] %> display: inline-block;"> @@ -136,6 +137,7 @@ <% else %> <% current_page = env.get("current_page") %> <% CONFIG.invidious_companion.each_with_index do | companion, index | %> + <% next if companion.community && !preferences.show_community_backends %> display: inline-block;"> <%= HTML.escape(CONFIG.backend_name_prefix + (index + 1).to_s) %> <%= HTML.escape(companion.note) %> checked<% end %>> + + <%= translate(locale, "preferences_show_community_backends_label") %> + checked<% end %>> + <%= translate(locale, "preferences_show_community_backends_description") %> + + <%= translate(locale, "preferences_hidden_channels") %> <% hidden_channels = preferences.hidden_channels %>