feat: Do not display backends that do not have an i2p equivalent when using i2p
Some checks failed
Stale issue handler / stale (push) Has been cancelled
Build and release container directly from master / release (docker/Dockerfile, AMD64, ubuntu-latest, linux/amd64, ) (push) Has been cancelled
Build and release container directly from master / release (docker/Dockerfile.arm64, ARM64, ubuntu-24.04-arm, linux/arm64/v8, -arm64) (push) Has been cancelled
Invidious CI / build - crystal: 1.14.1, stable: true (push) Has been cancelled
Invidious CI / build - crystal: 1.15.1, stable: true (push) Has been cancelled
Invidious CI / build - crystal: 1.16.3, stable: true (push) Has been cancelled
Invidious CI / build - crystal: 1.17.1, stable: true (push) Has been cancelled
Invidious CI / build - crystal: 1.18.2, stable: true (push) Has been cancelled
Invidious CI / build - crystal: nightly, stable: false (push) Has been cancelled
Invidious CI / Test AMD64 Docker build (push) Has been cancelled
Invidious CI / Test ARM64 Docker build (push) Has been cancelled
Invidious CI / lint (push) Has been cancelled

This commit is contained in:
Fijxu
2026-01-01 22:03:17 -03:00
parent 8ccb197e46
commit bc5d8d0b9b
2 changed files with 5 additions and 0 deletions

View File

@@ -85,8 +85,10 @@ module Invidious::Routes::BeforeAll
env.set "current_companion", current_companion
if host.split(".").last == "i2p"
env.set "using_i2p", true
env.set "companion_public_url", CONFIG.invidious_companion[current_companion].i2p_public_url.to_s
else
env.set "using_i2p", false
env.set "companion_public_url", CONFIG.invidious_companion[current_companion].public_url.to_s
end
end

View File

@@ -114,12 +114,14 @@
scheme = env.get("scheme")
status = BackendInfo.get_status
companion_switched = env.get?("companion_switched")
using_i2p = env.get?("using_i2p")
%>
<div class="h-box" style="margin-bottom: 10px;">
<b><%= translate(locale, "companion_switch_backend") %></b>
<% if domain %>
<% CONFIG.invidious_companion.each_with_index do | companion, index | %>
<% next if companion.community && !preferences.show_community_backends %>
<% next if companion.i2p_public_url.host.nil? && using_i2p %>
<% host_backend = env.request.headers["Host"].sub(/([^.]+)(\d+)/, "\\1#{index+1}") %>
<% 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;">
@@ -138,6 +140,7 @@
<% current_page = env.get("current_page") %>
<% CONFIG.invidious_companion.each_with_index do | companion, index | %>
<% next if companion.community && !preferences.show_community_backends %>
<% next if companion.i2p_public_url.host.nil? && using_i2p %>
<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) %>
<span style="color: