mirror of
https://github.com/iv-org/invidious
synced 2024-11-09 01:10:27 +00:00
Generalize redirect route
This commit is contained in:
parent
311e7684b2
commit
f178297452
@ -38,12 +38,7 @@ class Invidious::Routes::Misc < Invidious::Routes::BaseRoute
|
||||
|
||||
def cross_instance_redirect(env)
|
||||
instance_url = fetch_random_instance
|
||||
if env.params.query["id"]?
|
||||
id = env.params.query["id"]
|
||||
env.redirect "https://#{instance_url}/watch?v=#{id}"
|
||||
elsif env.params.query["q"]?
|
||||
query, page = env.params.query["q"], env.params.query["page"]
|
||||
env.redirect "https://#{instance_url}/search?q=#{query}&page=#{page}"
|
||||
end
|
||||
referer = get_referer(env)
|
||||
env.redirect "https://#{instance_url}#{referer}"
|
||||
end
|
||||
end
|
||||
|
@ -148,7 +148,7 @@
|
||||
<a title="<%=translate(locale, "Audio mode")%>" href="/watch?v=<%= item.id %>&listen=1">
|
||||
<i class="icon ion-md-headset"></i>
|
||||
</a>
|
||||
<a title="<%=translate(locale, "Switch Invidious Instance")%>" href="/redirect?id=<%= item.id %>&listen=1">
|
||||
<a title="<%=translate(locale, "Switch Invidious Instance")%>" href="/redirect?referer=<%= env.get?("current_page") %>">
|
||||
<i class="icon ion-md-jet"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<!-- Search redirection and filtering UI -->
|
||||
<% if count == 0 %>
|
||||
<h3 style="text-align: center">
|
||||
<%= translate(locale, "Broken?") %> <a href="/redirect?q=<%= HTML.escape(query.not_nil!) %>&page=<%= page + 1 %>"><%= translate(locale, "Switch Invidious Instance") %></a>
|
||||
<%= translate(locale, "Broken?") %> <a href="/redirect?referer=<%= env.get?("current_page") %>"><%= translate(locale, "Switch Invidious Instance") %></a>
|
||||
</h3>
|
||||
<% else %>
|
||||
<details id="filters">
|
||||
|
@ -110,7 +110,7 @@ we're going to need to do it here in order to allow for translations.
|
||||
(<a href="https://www.youtube.com/embed/<%= video.id %>"><%= translate(locale, "Embed") %></a>)
|
||||
</span>
|
||||
<p id="watch-on-another-invidious-instance">
|
||||
<a href="/redirect?id=<%= video.id %>"><%= translate(locale, "Switch Invidious Instance") %></a>
|
||||
<a href="/redirect?referer=<%= env.get?("current_page") %>"><%= translate(locale, "Switch Invidious Instance") %></a>
|
||||
</p>
|
||||
<p id="embed-link">
|
||||
<a href="<%= embed_link %>"><%= translate(locale, "Embed Link") %></a>
|
||||
|
Loading…
Reference in New Issue
Block a user