2021-02-02 10:48:16 +05:30
|
|
|
class Invidious::Routes::Misc < Invidious::Routes::BaseRoute
|
|
|
|
def home(env)
|
2020-10-06 10:11:18 +05:30
|
|
|
preferences = env.get("preferences").as(Preferences)
|
|
|
|
locale = LOCALES[preferences.locale]?
|
|
|
|
user = env.get? "user"
|
|
|
|
|
|
|
|
case preferences.default_home
|
|
|
|
when "Popular"
|
2020-12-27 10:42:43 +05:30
|
|
|
env.redirect "/feed/popular"
|
2020-10-06 10:11:18 +05:30
|
|
|
when "Trending"
|
|
|
|
env.redirect "/feed/trending"
|
|
|
|
when "Subscriptions"
|
|
|
|
if user
|
|
|
|
env.redirect "/feed/subscriptions"
|
|
|
|
else
|
2020-12-27 10:42:43 +05:30
|
|
|
env.redirect "/feed/popular"
|
2020-10-06 10:11:18 +05:30
|
|
|
end
|
|
|
|
when "Playlists"
|
|
|
|
if user
|
|
|
|
env.redirect "/view_all_playlists"
|
|
|
|
else
|
2020-12-27 10:42:43 +05:30
|
|
|
env.redirect "/feed/popular"
|
2020-10-06 10:11:18 +05:30
|
|
|
end
|
|
|
|
else
|
2021-04-17 17:48:58 +05:30
|
|
|
templated "search_homepage", navbar_search: false
|
2020-10-06 10:11:18 +05:30
|
|
|
end
|
|
|
|
end
|
2021-02-02 10:48:16 +05:30
|
|
|
|
|
|
|
def privacy(env)
|
|
|
|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
|
|
|
templated "privacy"
|
|
|
|
end
|
|
|
|
|
|
|
|
def licenses(env)
|
|
|
|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
|
|
|
rendered "licenses"
|
|
|
|
end
|
2021-03-27 07:06:40 +05:30
|
|
|
|
|
|
|
def cross_instance_redirect(env)
|
2021-03-29 11:35:54 +05:30
|
|
|
referer = get_referer(env)
|
2021-05-16 08:38:33 +05:30
|
|
|
|
|
|
|
if !env.get("preferences").as(Preferences).automatic_instance_redirect
|
|
|
|
return env.redirect("https://redirect.invidious.io#{referer}")
|
|
|
|
end
|
|
|
|
|
|
|
|
instance_url = fetch_random_instance
|
2021-03-29 11:35:54 +05:30
|
|
|
env.redirect "https://#{instance_url}#{referer}"
|
2021-03-27 07:06:40 +05:30
|
|
|
end
|
2020-10-06 10:11:18 +05:30
|
|
|
end
|