2021-10-02 20:04:02 +00:00
|
|
|
{% skip_file if flag?(:api_only) %}
|
|
|
|
|
2021-08-11 03:36:25 -07:00
|
|
|
module Invidious::Routes::Misc
|
|
|
|
def self.home(env)
|
2020-10-05 23:41:18 -05:00
|
|
|
preferences = env.get("preferences").as(Preferences)
|
|
|
|
locale = LOCALES[preferences.locale]?
|
|
|
|
user = env.get? "user"
|
|
|
|
|
|
|
|
case preferences.default_home
|
|
|
|
when "Popular"
|
2020-12-27 06:12:43 +01:00
|
|
|
env.redirect "/feed/popular"
|
2020-10-05 23:41:18 -05:00
|
|
|
when "Trending"
|
|
|
|
env.redirect "/feed/trending"
|
|
|
|
when "Subscriptions"
|
|
|
|
if user
|
|
|
|
env.redirect "/feed/subscriptions"
|
|
|
|
else
|
2020-12-27 06:12:43 +01:00
|
|
|
env.redirect "/feed/popular"
|
2020-10-05 23:41:18 -05:00
|
|
|
end
|
|
|
|
when "Playlists"
|
|
|
|
if user
|
2021-08-30 14:58:24 +00:00
|
|
|
env.redirect "/feed/playlists"
|
2020-10-05 23:41:18 -05:00
|
|
|
else
|
2020-12-27 06:12:43 +01:00
|
|
|
env.redirect "/feed/popular"
|
2020-10-05 23:41:18 -05:00
|
|
|
end
|
|
|
|
else
|
2021-04-17 05:18:58 -07:00
|
|
|
templated "search_homepage", navbar_search: false
|
2020-10-05 23:41:18 -05:00
|
|
|
end
|
|
|
|
end
|
2021-02-02 06:18:16 +01:00
|
|
|
|
2021-08-11 03:36:25 -07:00
|
|
|
def self.privacy(env)
|
2021-02-02 06:18:16 +01:00
|
|
|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
|
|
|
templated "privacy"
|
|
|
|
end
|
|
|
|
|
2021-08-11 03:36:25 -07:00
|
|
|
def self.licenses(env)
|
2021-02-02 06:18:16 +01:00
|
|
|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
|
|
|
rendered "licenses"
|
|
|
|
end
|
2021-03-26 18:36:40 -07:00
|
|
|
|
2021-08-11 03:36:25 -07:00
|
|
|
def self.cross_instance_redirect(env)
|
2021-03-28 23:05:54 -07:00
|
|
|
referer = get_referer(env)
|
2021-05-15 20:08:33 -07:00
|
|
|
|
|
|
|
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-28 23:05:54 -07:00
|
|
|
env.redirect "https://#{instance_url}#{referer}"
|
2021-03-26 18:36:40 -07:00
|
|
|
end
|
2020-10-05 23:41:18 -05:00
|
|
|
end
|