From 66e7285108363c3c3dcb814bdffb716c14e1724d Mon Sep 17 00:00:00 2001 From: syeopite Date: Sat, 2 Oct 2021 11:51:15 -0700 Subject: [PATCH 1/4] 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 0e6356d0..94d54283 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 7f797e37..66f1ae10 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 15d8ed1e..17bc4f89 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 5788bf51..a58571aa 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 00000000..062c3de0 --- /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 12f93a72..4c23ad98 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 1245256f..74890f5a 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 cad36e73..928e5645 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 %>

<% if !channel.auto_generated %> diff --git a/src/invidious/views/community.ecr b/src/invidious/views/community.ecr index 17bc4f89..f0add06b 100644 --- a/src/invidious/views/community.ecr +++ b/src/invidious/views/community.ecr @@ -47,7 +47,7 @@ <% if env.get("preferences").as(Preferences).automatic_instance_redirect%> "><%= translate(locale, "Switch Invidious Instance") %> <% else %> - "><%= translate(locale, "Switch Invidious Instance") %> + <%= translate(locale, "Switch Invidious Instance") %> <% end %>
<% if !channel.auto_generated %> diff --git a/src/invidious/views/playlist.ecr b/src/invidious/views/playlist.ecr index 4c23ad98..d0518de7 100644 --- a/src/invidious/views/playlist.ecr +++ b/src/invidious/views/playlist.ecr @@ -47,7 +47,7 @@ <%= translate(locale, "Switch Invidious Instance") %> <% else %> - "> + <%= translate(locale, "Switch Invidious Instance") %> <% end %> diff --git a/src/invidious/views/playlists.ecr b/src/invidious/views/playlists.ecr index 74890f5a..12dba088 100644 --- a/src/invidious/views/playlists.ecr +++ b/src/invidious/views/playlists.ecr @@ -50,7 +50,7 @@ <% if env.get("preferences").as(Preferences).automatic_instance_redirect%> "><%= translate(locale, "Switch Invidious Instance") %> <% else %> - "><%= translate(locale, "Switch Invidious Instance") %> + <%= translate(locale, "Switch Invidious Instance") %> <% end %> diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 928e5645..2f3709dd 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -119,7 +119,7 @@ we're going to need to do it here in order to allow for translations. <% if env.get("preferences").as(Preferences).automatic_instance_redirect%> "><%= translate(locale, "Switch Invidious Instance") %> <% else %> - "><%= translate(locale, "Switch Invidious Instance") %> + <%= translate(locale, "Switch Invidious Instance") %> <% end %>