summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2023-10-21 18:31:42 +0200
committerSamantaz Fox <coding@samantaz.fr>2023-10-21 18:31:42 +0200
commit2a65b5f52e1bedd6f3649c8fe833d1222e863051 (patch)
tree72e14f6d4d1f320c74ac321ac1c8701583b9c05f /src
parent9072fa4355733ec2f7c4b4bb8dd8dc2226ee24ac (diff)
parent40919c6a83c78b890b7974304110c10b30a3746a (diff)
downloadinvidious-2a65b5f52e1bedd6f3649c8fe833d1222e863051.tar.gz
invidious-2a65b5f52e1bedd6f3649c8fe833d1222e863051.tar.bz2
invidious-2a65b5f52e1bedd6f3649c8fe833d1222e863051.zip
Frontend: Add video timestamp on external links (#4101)
Diffstat (limited to 'src')
-rw-r--r--src/invidious/routes/watch.cr8
-rw-r--r--src/invidious/views/watch.ecr33
2 files changed, 25 insertions, 16 deletions
diff --git a/src/invidious/routes/watch.cr b/src/invidious/routes/watch.cr
index e5cf3716..3d935f0a 100644
--- a/src/invidious/routes/watch.cr
+++ b/src/invidious/routes/watch.cr
@@ -30,14 +30,6 @@ module Invidious::Routes::Watch
return env.redirect "/"
end
- embed_link = "/embed/#{id}"
- if env.params.query.size > 1
- embed_params = HTTP::Params.parse(env.params.query.to_s)
- embed_params.delete_all("v")
- embed_link += "?"
- embed_link += embed_params.to_s
- end
-
plid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "")
continuation = process_continuation(env.params.query, plid, id)
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr
index 62a154a4..07474896 100644
--- a/src/invidious/views/watch.ecr
+++ b/src/invidious/views/watch.ecr
@@ -113,19 +113,36 @@ we're going to need to do it here in order to allow for translations.
<div class="pure-u-1 pure-u-lg-1-5">
<div class="h-box">
<span id="watch-on-youtube">
- <a href="https://www.youtube.com/watch?v=<%= video.id %>"><%= translate(locale, "videoinfo_watch_on_youTube") %></a>
- (<a href="https://www.youtube.com/embed/<%= video.id %>"><%= translate(locale, "videoinfo_youTube_embed_link") %></a>)
+ <%-
+ link_yt_watch = URI.new(scheme: "https", host: "www.youtube.com", path: "/watch", query: "v=#{video.id}")
+ link_yt_embed = URI.new(scheme: "https", host: "www.youtube.com", path: "/embed/#{video.id}")
+
+ if !plid.nil? && !continuation.nil?
+ link_yt_param = URI::Params{"plid" => [plid], "index" => [continuation.to_s]}
+ link_yt_watch = IV::HttpServer::Utils.add_params_to_url(link_yt_watch, link_yt_param)
+ link_yt_embed = IV::HttpServer::Utils.add_params_to_url(link_yt_embed, link_yt_param)
+ end
+ -%>
+ <a id="link-yt-watch" data-base-url="<%= link_yt_watch %>" href="<%= link_yt_watch %>"><%= translate(locale, "videoinfo_watch_on_youTube") %></a>
+ (<a id="link-yt-embed" data-base-url="<%= link_yt_embed %>" href="<%= link_yt_embed %>"><%= translate(locale, "videoinfo_youTube_embed_link") %></a>)
</span>
+
<p id="watch-on-another-invidious-instance">
- <% if env.get("preferences").as(Preferences).automatic_instance_redirect%>
- <a href="/redirect?referer=<%= env.get?("current_page") %>"><%= translate(locale, "Switch Invidious Instance") %></a>
- <% else %>
- <a href="https://redirect.invidious.io<%= env.request.resource %>"><%= translate(locale, "Switch Invidious Instance") %></a>
- <% end %>
+ <%- link_iv_other = IV::Frontend::Misc.redirect_url(env) -%>
+ <a id="link-iv-other" data-base-url="<%= link_iv_other %>" href="<%= link_iv_other %>"><%= translate(locale, "Switch Invidious Instance") %></a>
</p>
+
<p id="embed-link">
- <a href="<%= embed_link %>"><%= translate(locale, "videoinfo_invidious_embed_link") %></a>
+ <%-
+ params_iv_embed = env.params.query.dup
+ params_iv_embed.delete_all("v")
+
+ link_iv_embed = URI.new(path: "/embed/#{id}")
+ link_iv_embed = IV::HttpServer::Utils.add_params_to_url(link_iv_embed, params_iv_embed)
+ -%>
+ <a id="link-iv-embed" data-base-url="<%= link_iv_embed %>" href="<%= link_iv_embed %>"><%= translate(locale, "videoinfo_invidious_embed_link") %></a>
</p>
+
<p id="annotations">
<% if params.annotations %>
<a href="/watch?<%= env.params.query %>&iv_load_policy=3">