mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2026-01-23 07:11:49 +00:00
feat: add support for community backends (volunteers that host invidious companion for the instance)
This commit is contained in:
@@ -1075,4 +1075,11 @@ h1, h2, h3, h4, h5, p,
|
|||||||
.hidden-channels {
|
.hidden-channels {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
height: 200px;
|
height: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preference-description {
|
||||||
|
width: 250px;
|
||||||
|
padding-left: 10px;
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
@@ -117,6 +117,8 @@
|
|||||||
"preferences_thin_mode_label": "Thin mode: ",
|
"preferences_thin_mode_label": "Thin mode: ",
|
||||||
"preferences_category_misc": "Miscellaneous preferences",
|
"preferences_category_misc": "Miscellaneous preferences",
|
||||||
"preferences_automatic_instance_redirect_label": "Automatic instance redirection (fallback to redirect.invidious.io): ",
|
"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_category_subscription": "Subscription preferences",
|
||||||
"preferences_annotations_subscribed_label": "Show annotations by default for subscribed channels? ",
|
"preferences_annotations_subscribed_label": "Show annotations by default for subscribed channels? ",
|
||||||
"Redirect homepage to feed: ": "Redirect homepage to feed: ",
|
"Redirect homepage to feed: ": "Redirect homepage to feed: ",
|
||||||
|
|||||||
@@ -71,6 +71,8 @@
|
|||||||
"preferences_thin_mode_label": "Modo compacto: ",
|
"preferences_thin_mode_label": "Modo compacto: ",
|
||||||
"preferences_category_misc": "Preferencias misceláneas",
|
"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_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_category_subscription": "Preferencias de la suscripción",
|
||||||
"preferences_annotations_subscribed_label": "¿Mostrar anotaciones por defecto para los canales suscritos? ",
|
"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: ",
|
"Redirect homepage to feed: ": "Redirigir la página de inicio a la fuente: ",
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ struct ConfigPreferences
|
|||||||
property hidden_channels : Array(String)? = nil
|
property hidden_channels : Array(String)? = nil
|
||||||
@[YAML::Field(ignore: true)]
|
@[YAML::Field(ignore: true)]
|
||||||
property default_trending_type : Invidious::Routes::Feeds::TrendingTypes = Invidious::Routes::Feeds::TrendingTypes::Default
|
property default_trending_type : Invidious::Routes::Feeds::TrendingTypes = Invidious::Routes::Feeds::TrendingTypes::Default
|
||||||
|
property show_community_backends : Bool = false
|
||||||
|
|
||||||
def to_tuple
|
def to_tuple
|
||||||
{% begin %}
|
{% begin %}
|
||||||
@@ -95,6 +96,7 @@ class Config
|
|||||||
|
|
||||||
property note : String = ""
|
property note : String = ""
|
||||||
property domain : Array(String) = [] of String
|
property domain : Array(String) = [] of String
|
||||||
|
property community : Bool = false
|
||||||
|
|
||||||
# Indicates if this companion instance uses the built-in proxy
|
# Indicates if this companion instance uses the built-in proxy
|
||||||
property builtin_proxy : Bool = false
|
property builtin_proxy : Bool = false
|
||||||
|
|||||||
@@ -172,6 +172,10 @@ module Invidious::Routes::PreferencesRoute
|
|||||||
default_trending_type = env.params.body["default_trending_type"]?.try &.as(String)
|
default_trending_type = env.params.body["default_trending_type"]?.try &.as(String)
|
||||||
default_trending_type ||= Invidious::Routes::Feeds::TrendingTypes::Default
|
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
|
# Convert to JSON and back again to take advantage of converters used for compatibility
|
||||||
preferences = Preferences.from_json({
|
preferences = Preferences.from_json({
|
||||||
annotations: annotations,
|
annotations: annotations,
|
||||||
@@ -211,6 +215,7 @@ module Invidious::Routes::PreferencesRoute
|
|||||||
default_playlist: default_playlist,
|
default_playlist: default_playlist,
|
||||||
hidden_channels: hidden_channels,
|
hidden_channels: hidden_channels,
|
||||||
default_trending_type: default_trending_type,
|
default_trending_type: default_trending_type,
|
||||||
|
show_community_backends: show_community_backends,
|
||||||
}.to_json)
|
}.to_json)
|
||||||
|
|
||||||
if user = env.get? "user"
|
if user = env.get? "user"
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ struct Preferences
|
|||||||
property hidden_channels : Array(String)? = nil
|
property hidden_channels : Array(String)? = nil
|
||||||
property default_trending_type : Invidious::Routes::Feeds::TrendingTypes = Invidious::Routes::Feeds::TrendingTypes::Default
|
property default_trending_type : Invidious::Routes::Feeds::TrendingTypes = Invidious::Routes::Feeds::TrendingTypes::Default
|
||||||
property default_playlist : String? = nil
|
property default_playlist : String? = nil
|
||||||
|
property show_community_backends : Bool = false
|
||||||
|
|
||||||
module BoolToString
|
module BoolToString
|
||||||
def self.to_json(value : String, json : JSON::Builder)
|
def self.to_json(value : String, json : JSON::Builder)
|
||||||
|
|||||||
@@ -119,6 +119,7 @@
|
|||||||
<b>Switch Backend:</b>
|
<b>Switch Backend:</b>
|
||||||
<% if domain %>
|
<% if domain %>
|
||||||
<% CONFIG.invidious_companion.each_with_index do | companion, index | %>
|
<% 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}") %>
|
<% host_backend = env.request.headers["Host"].sub(/([^.]+)(\d+)/, "\\1#{index+1}") %>
|
||||||
<% is_current_backend_host = host_backend == env.request.headers["Host"] %>
|
<% is_current_backend_host = host_backend == env.request.headers["Host"] %>
|
||||||
<a href="<%= scheme %>://<%= host_backend %><%= env.request.resource %>" style="<%= is_current_backend_host ? "text-decoration-line: underline;" : "" %> display: inline-block;">
|
<a href="<%= scheme %>://<%= host_backend %><%= env.request.resource %>" style="<%= is_current_backend_host ? "text-decoration-line: underline;" : "" %> display: inline-block;">
|
||||||
@@ -136,6 +137,7 @@
|
|||||||
<% else %>
|
<% else %>
|
||||||
<% current_page = env.get("current_page") %>
|
<% current_page = env.get("current_page") %>
|
||||||
<% CONFIG.invidious_companion.each_with_index do | companion, index | %>
|
<% CONFIG.invidious_companion.each_with_index do | companion, index | %>
|
||||||
|
<% next if companion.community && !preferences.show_community_backends %>
|
||||||
<a href="/switchbackend?backend_id=<%= index.to_s %>&referer=<%= current_page %>" style="<%= current_backend == index ? "text-decoration-line: underline;" : "" %> display: inline-block;">
|
<a href="/switchbackend?backend_id=<%= index.to_s %>&referer=<%= current_page %>" style="<%= current_backend == index ? "text-decoration-line: underline;" : "" %> display: inline-block;">
|
||||||
<%= HTML.escape(CONFIG.backend_name_prefix + (index + 1).to_s) %> <%= HTML.escape(companion.note) %>
|
<%= HTML.escape(CONFIG.backend_name_prefix + (index + 1).to_s) %> <%= HTML.escape(companion.note) %>
|
||||||
<span style="color:
|
<span style="color:
|
||||||
|
|||||||
@@ -235,6 +235,12 @@
|
|||||||
<input name="automatic_instance_redirect" id="automatic_instance_redirect" type="checkbox" <% if preferences.automatic_instance_redirect %>checked<% end %>>
|
<input name="automatic_instance_redirect" id="automatic_instance_redirect" type="checkbox" <% if preferences.automatic_instance_redirect %>checked<% end %>>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<label for="show_community_backends"><%= translate(locale, "preferences_show_community_backends_label") %></label>
|
||||||
|
<input name="show_community_backends" id="show_community_backends" type="checkbox" <% if preferences.show_community_backends %>checked<% end %>>
|
||||||
|
<span class="preference-description"><%= translate(locale, "preferences_show_community_backends_description") %></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<label for="hidden_channels"><%= translate(locale, "preferences_hidden_channels") %></label>
|
<label for="hidden_channels"><%= translate(locale, "preferences_hidden_channels") %></label>
|
||||||
<% hidden_channels = preferences.hidden_channels %>
|
<% hidden_channels = preferences.hidden_channels %>
|
||||||
|
|||||||
Reference in New Issue
Block a user