-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confirmation before connecting to youtube.com/youtu.be #4826
base: master
Are you sure you want to change the base?
Conversation
<% end %> | ||
|
||
<div class="h-box"> | ||
<h3><%= translate(locale, "You are leaving Invidious. Continue to external link?") %></h3> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add this line to locales/en-US.json
, otherwise Weblate won't be able to detect it, and in turn that won't be proposed to translators:
"confirm_dialog_external_link": "You are leaving Invidious. Continue to external link?"
<h3><%= translate(locale, "You are leaving Invidious. Continue to external link?") %></h3> | |
<h3><%= translate(locale, "confirm_dialog_external_link") %></h3> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the suggestion I made above! You need to use confirm_dialog_external_link
, not the translated string here!
@@ -303,6 +303,7 @@ module Invidious::Comments | |||
if format == "html" | |||
response = JSON.parse(response) | |||
content_html = Frontend::Comments.template_youtube(response, locale, thin_mode) | |||
content_html = Comments.replace_external_links(content_html) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why you added this here? Is it because you missed one link to replace, as mentioned here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was for replacing the links on comments with the confirmation page, such as when creators pin their own with links from Discord or Twitch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, okay, I see!
Also, I realized that there was #4667 pending. I merged, so can you rebase your change on that please? |
28b8149
to
33b30c9
Compare
Rebased, since this PR goes directly with the feature of the confirmation page, I added the |
if env.params.query["link"]? && !env.params.query["link"].empty? | ||
link = HTML.escape(env.params.query["link"].to_s) | ||
|
||
templated "confirm_leave" | ||
else | ||
env.redirect "#{referer}" | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small improvements:
.presence
will returnnil
ifenv.params.query["link"]?
is eithernil
(= the parameter is absent) or an empty string. Otherwise, it returns its value.- you can assign a variable inside an
if
condition. Theif
will check if that variable is truthy or falsey. - For the referer, the string interpolation is superfluous
- There was a trailing whitespace on the empty line after
link = ...
. Don't forget to runmake format
to ensure that your code is properly formatted!
if env.params.query["link"]? && !env.params.query["link"].empty? | |
link = HTML.escape(env.params.query["link"].to_s) | |
templated "confirm_leave" | |
else | |
env.redirect "#{referer}" | |
end | |
if raw_link = env.params.query["link"]?.presence | |
link = HTML.escape(raw_link) | |
templated "confirm_leave" | |
else | |
env.redirect referer | |
end |
<% end %> | ||
|
||
<div class="h-box"> | ||
<h3><%= translate(locale, "You are leaving Invidious. Continue to external link?") %></h3> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the suggestion I made above! You need to use confirm_dialog_external_link
, not the translated string here!
@@ -303,6 +303,7 @@ module Invidious::Comments | |||
if format == "html" | |||
response = JSON.parse(response) | |||
content_html = Frontend::Comments.template_youtube(response, locale, thin_mode) | |||
content_html = Comments.replace_external_links(content_html) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, okay, I see!
Closes #4798
I also thought that since we are adding a confirmation before going to youtube.com/youtu.be in the "Watch on YouTube (Embed)" and "[YT]" in the comments. It would make sense adding also to external domains from links in the description and comments too. What you think about that?