mirror of
https://github.com/iv-org/invidious.git
synced 2025-07-30 09:18:28 +00:00
Fix specs and clean up
This commit is contained in:
parent
a333bc6efe
commit
5b175f6b33
@ -8,7 +8,7 @@ Spectator.describe "error_redirect_helper" do
|
|||||||
test_env.set "current_page", current_url
|
test_env.set "current_page", current_url
|
||||||
|
|
||||||
html = error_redirect_helper(test_env)
|
html = error_redirect_helper(test_env)
|
||||||
expect(html).to eq "<p style=\"margin-bottom: 4px;\">After which you should try to: </p>\n<ul>\n \n <li>\n <a href=\"/embed/IeQT18gaB-c?si=YxBQzH-GBSTS4vBS\">Refresh</a>\n </li>\n \n <li>\n <a href=\"/redirect?referer=/embed/IeQT18gaB-c?si=YxBQzH-GBSTS4vBS\">Switch Invidious Instance</a>\n </li>\n \n <li>\n <a href=\"https://youtube.com/embed/IeQT18gaB-c?si=YxBQzH-GBSTS4vBS\">Go to YouTube</a>\n </li>\n \n <li>\n <a href=\"/watch?v=IeQT18gaB-c?si=YxBQzH-GBSTS4vBS\">Open in new page</a>\n </li>\n \n</ul>\n"
|
expect(html).to eq "<p style=\"margin-bottom: 4px;\">After which you should try to: </p>\n<ul>\n \n <li>\n <a href=\"/embed/IeQT18gaB-c?si=YxBQzH-GBSTS4vBS\">Refresh</a>\n </li>\n \n <li>\n <a href=\"/redirect?referer=/embed/IeQT18gaB-c?si=YxBQzH-GBSTS4vBS\">Switch Invidious Instance</a>\n </li>\n \n <li>\n <a href=\"https://youtube.com/embed/IeQT18gaB-c?si=YxBQzH-GBSTS4vBS\">Go to YouTube</a>\n </li>\n \n</ul>\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "shows next steps for watch pages" do
|
it "shows next steps for watch pages" do
|
||||||
|
@ -12,6 +12,8 @@ require "../src/invidious/search/ctoken"
|
|||||||
require "../src/invidious/trending"
|
require "../src/invidious/trending"
|
||||||
require "../src/invidious/config"
|
require "../src/invidious/config"
|
||||||
require "../src/invidious/user/preferences.cr"
|
require "../src/invidious/user/preferences.cr"
|
||||||
|
require "../src/invidious/jobs"
|
||||||
|
require "../src/invidious/jobs/*"
|
||||||
require "spectator"
|
require "spectator"
|
||||||
|
|
||||||
CONFIG = Config.from_yaml(File.open("config/config.example.yml"))
|
CONFIG = Config.from_yaml(File.open("config/config.example.yml"))
|
||||||
|
@ -80,7 +80,7 @@ class Config
|
|||||||
property full_refresh : Bool = false
|
property full_refresh : Bool = false
|
||||||
|
|
||||||
# Jobs config structure. See jobs.cr and jobs/base_job.cr
|
# Jobs config structure. See jobs.cr and jobs/base_job.cr
|
||||||
# property jobs = Invidious::Jobs::JobsConfig.new
|
property jobs = Invidious::Jobs::JobsConfig.new
|
||||||
|
|
||||||
# Used to tell Invidious it is behind a proxy, so links to resources should be https://
|
# Used to tell Invidious it is behind a proxy, so links to resources should be https://
|
||||||
property https_only : Bool?
|
property https_only : Bool?
|
||||||
|
@ -173,25 +173,21 @@ def error_redirect_helper(env : HTTP::Server::Context)
|
|||||||
|
|
||||||
locale = env.get("preferences").as(Preferences).locale
|
locale = env.get("preferences").as(Preferences).locale
|
||||||
|
|
||||||
display_on_path = %w[
|
if request_path.starts_with?("/search") || request_path.starts_with?("/watch") ||
|
||||||
/search
|
request_path.starts_with?("/channel") || request_path.starts_with?("/playlist?list=PL") ||
|
||||||
/channel
|
request_path.starts_with?("/embed")
|
||||||
/watch
|
next_steps_text = translate(locale, "next_steps_error_message")
|
||||||
/playlist?list=PL
|
refresh = translate(locale, "next_steps_error_message_refresh")
|
||||||
/embed
|
go_to_youtube = translate(locale, "next_steps_error_message_go_to_youtube")
|
||||||
]
|
switch_instance = translate(locale, "Switch Invidious Instance")
|
||||||
|
steps = {
|
||||||
|
refresh => env.request.resource,
|
||||||
|
switch_instance => "/redirect?referer=#{env.get("current_page")}",
|
||||||
|
go_to_youtube => "https://youtube.com#{env.request.resource}"
|
||||||
|
}
|
||||||
|
|
||||||
return "" if display_on_path.none? { |path| request_path.starts_with? path }
|
return rendered "components/error_redirect"
|
||||||
|
else
|
||||||
next_steps_text = translate(locale, "next_steps_error_message")
|
return ""
|
||||||
refresh = translate(locale, "next_steps_error_message_refresh")
|
end
|
||||||
go_to_youtube = translate(locale, "next_steps_error_message_go_to_youtube")
|
|
||||||
switch_instance = translate(locale, "Switch Invidious Instance")
|
|
||||||
steps = {
|
|
||||||
refresh => env.request.resource,
|
|
||||||
switch_instance => "/redirect?referer=#{env.get("current_page")}",
|
|
||||||
go_to_youtube => "https://youtube.com#{env.request.resource}"
|
|
||||||
}
|
|
||||||
|
|
||||||
return rendered "components/error_redirect"
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user