From 66e7285108363c3c3dcb814bdffb716c14e1724d Mon Sep 17 00:00:00 2001 From: syeopite Date: Sat, 2 Oct 2021 11:51:15 -0700 Subject: [PATCH] Only use /redirect when automatically redirecting --- src/invidious/routes/misc.cr | 2 +- src/invidious/views/channel.ecr | 6 +++- src/invidious/views/community.ecr | 6 +++- src/invidious/views/components/item.ecr | 31 +++---------------- .../components/video-context-buttons.ecr | 21 +++++++++++++ src/invidious/views/playlist.ecr | 13 ++++++-- src/invidious/views/playlists.ecr | 6 +++- src/invidious/views/watch.ecr | 4 +++ 8 files changed, 56 insertions(+), 33 deletions(-) create mode 100644 src/invidious/views/components/video-context-buttons.ecr diff --git a/src/invidious/routes/misc.cr b/src/invidious/routes/misc.cr index 0e6356d0e..94d542836 100644 --- a/src/invidious/routes/misc.cr +++ b/src/invidious/routes/misc.cr @@ -42,7 +42,7 @@ module Invidious::Routes::Misc referer = get_referer(env) if !env.get("preferences").as(Preferences).automatic_instance_redirect - return env.redirect("https://redirect.invidious.io#{referer}") + return env.redirect("https://redirect.invidious.io/#{referer}") end instance_url = fetch_random_instance diff --git a/src/invidious/views/channel.ecr b/src/invidious/views/channel.ecr index 7f797e376..66f1ae10e 100644 --- a/src/invidious/views/channel.ecr +++ b/src/invidious/views/channel.ecr @@ -45,7 +45,11 @@
<%= translate(locale, "View channel on YouTube") %>
- "><%= translate(locale, "Switch Invidious Instance") %> + <% if env.get("preferences").as(Preferences).automatic_instance_redirect%> + "><%= translate(locale, "Switch Invidious Instance") %> + <% else %> + "><%= translate(locale, "Switch Invidious Instance") %> + <% end %>
<% if !channel.auto_generated %>
diff --git a/src/invidious/views/community.ecr b/src/invidious/views/community.ecr index 15d8ed1e0..17bc4f89b 100644 --- a/src/invidious/views/community.ecr +++ b/src/invidious/views/community.ecr @@ -44,7 +44,11 @@
<%= translate(locale, "View channel on YouTube") %>
- "><%= translate(locale, "Switch Invidious Instance") %> + <% if env.get("preferences").as(Preferences).automatic_instance_redirect%> + "><%= translate(locale, "Switch Invidious Instance") %> + <% else %> + "><%= translate(locale, "Switch Invidious Instance") %> + <% end %>
<% if !channel.auto_generated %>
diff --git a/src/invidious/views/components/item.ecr b/src/invidious/views/components/item.ecr index 5788bf513..a58571aa1 100644 --- a/src/invidious/views/components/item.ecr +++ b/src/invidious/views/components/item.ecr @@ -79,19 +79,8 @@ - + <% endpoint_params = "?v=#{item.id}&list=#{item.plid}" %> + <%= rendered "components/video-context-buttons" %>
diff --git a/src/invidious/views/components/video-context-buttons.ecr b/src/invidious/views/components/video-context-buttons.ecr new file mode 100644 index 000000000..062c3de00 --- /dev/null +++ b/src/invidious/views/components/video-context-buttons.ecr @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/src/invidious/views/playlist.ecr b/src/invidious/views/playlist.ecr index 12f93a72b..4c23ad986 100644 --- a/src/invidious/views/playlist.ecr +++ b/src/invidious/views/playlist.ecr @@ -41,9 +41,16 @@ <%= translate(locale, "View playlist on YouTube") %> | - "> - <%= translate(locale, "Switch Invidious Instance") %> - + + <% if env.get("preferences").as(Preferences).automatic_instance_redirect%> + "> + <%= translate(locale, "Switch Invidious Instance") %> + + <% else %> + "> + <%= translate(locale, "Switch Invidious Instance") %> + + <% end %>
<% end %>
diff --git a/src/invidious/views/playlists.ecr b/src/invidious/views/playlists.ecr index 1245256fe..74890f5a1 100644 --- a/src/invidious/views/playlists.ecr +++ b/src/invidious/views/playlists.ecr @@ -47,7 +47,11 @@
- "><%= translate(locale, "Switch Invidious Instance") %> + <% if env.get("preferences").as(Preferences).automatic_instance_redirect%> + "><%= translate(locale, "Switch Invidious Instance") %> + <% else %> + "><%= translate(locale, "Switch Invidious Instance") %> + <% end %>
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index cad36e732..928e56453 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -116,7 +116,11 @@ we're going to need to do it here in order to allow for translations. (<%= translate(locale, "Embed") %>)

+ <% if env.get("preferences").as(Preferences).automatic_instance_redirect%> "><%= translate(locale, "Switch Invidious Instance") %> + <% else %> + "><%= translate(locale, "Switch Invidious Instance") %> + <% end %>