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") %>
<% 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") %>
<% 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" %>
@@ -155,19 +144,9 @@
-
+
+ <% endpoint_params = "?v=#{item.id}" %>
+ <%= rendered "components/video-context-buttons" %>
<% 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 @@
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 %>
<%= translate(locale, "Embed Link") %>
From bb396a310ed8b3042793e0dc7a4c88f8412f7e3d Mon Sep 17 00:00:00 2001
From: syeopite
Date: Sat, 2 Oct 2021 12:25:22 -0700
Subject: [PATCH 2/4] Remove unneeded redirect.invidious.io code in /redirect
---
src/invidious/routes/misc.cr | 5 -----
1 file changed, 5 deletions(-)
diff --git a/src/invidious/routes/misc.cr b/src/invidious/routes/misc.cr
index 94d54283..3ea4c272 100644
--- a/src/invidious/routes/misc.cr
+++ b/src/invidious/routes/misc.cr
@@ -40,11 +40,6 @@ module Invidious::Routes::Misc
def self.cross_instance_redirect(env)
referer = get_referer(env)
-
- if !env.get("preferences").as(Preferences).automatic_instance_redirect
- return env.redirect("https://redirect.invidious.io/#{referer}")
- end
-
instance_url = fetch_random_instance
env.redirect "https://#{instance_url}#{referer}"
end
From a531f4f05750db76ff61eb3477b75f71bdce2841 Mon Sep 17 00:00:00 2001
From: syeopite
Date: Fri, 15 Oct 2021 07:45:36 -0700
Subject: [PATCH 3/4] Rebase error
---
src/invidious/views/components/video-context-buttons.ecr | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/invidious/views/components/video-context-buttons.ecr b/src/invidious/views/components/video-context-buttons.ecr
index 062c3de0..daa107f0 100644
--- a/src/invidious/views/components/video-context-buttons.ecr
+++ b/src/invidious/views/components/video-context-buttons.ecr
@@ -8,7 +8,7 @@
<% if env.get("preferences").as(Preferences).automatic_instance_redirect%>
- " href="/redirect?referer=%2Fwatch<%=endpoint_params%>">
+ " href="/redirect?referer=%2Fwatch<%=URI.encode_www_form(endpoint_params)%>">
<% else %>
From 437bdedb07b438d329d254f9d515803fd8520a9f Mon Sep 17 00:00:00 2001
From: syeopite
Date: Fri, 15 Oct 2021 14:40:59 -0700
Subject: [PATCH 4/4] Use env.request.resource for instance switch link
---
src/invidious/views/channel.ecr | 2 +-
src/invidious/views/community.ecr | 2 +-
src/invidious/views/playlist.ecr | 2 +-
src/invidious/views/playlists.ecr | 2 +-
src/invidious/views/watch.ecr | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/invidious/views/channel.ecr b/src/invidious/views/channel.ecr
index 66f1ae10..40b553a9 100644
--- a/src/invidious/views/channel.ecr
+++ b/src/invidious/views/channel.ecr
@@ -48,7 +48,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/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 %>