feat: add confirm leaving Invidious view and route

This commit is contained in:
unlxam 2024-08-08 22:51:24 -03:00
parent c5fdd9ea65
commit a02b55b2c0
3 changed files with 35 additions and 0 deletions

View File

@ -43,4 +43,14 @@ module Invidious::Routes::Misc
instance_url = fetch_random_instance
env.redirect "https://#{instance_url}#{referer}"
end
def self.confirm_leave(env)
locale = env.get("preferences").as(Preferences).locale
link = env.params.query["link"]?
referer = get_referer(env)
templated "confirm_leave"
end
end

View File

@ -21,6 +21,7 @@ module Invidious::Routing
get "/privacy", Routes::Misc, :privacy
get "/licenses", Routes::Misc, :licenses
get "/redirect", Routes::Misc, :cross_instance_redirect
get "/confirm_leave", Routes::Misc, :confirm_leave
self.register_channel_routes
self.register_watch_routes

View File

@ -0,0 +1,24 @@
<% content_for "header" do %>
<title><%= translate(locale, "Leave Invidious") %> - Invidious</title>
<% end %>
<div class="h-box">
<div class="pure-form pure-form-aligned">
<legend><%= translate(locale, "You are leaving Invidious. Continue to external link?") %></legend>
<div class="pure-g">
<div class="pure-u-1-2">
<a value="confirm_leave" class="pure-button pure-button-primary" href="<%= link %>">
<%= translate(locale, "Yes") %>
</a>
</div>
<div class="pure-u-1-2">
<a class="pure-button" href="<%= referer %>">
<%= translate(locale, "No") %>
</a>
</div>
</div>
</div>
</div>