2021-06-19 04:16:18 -07:00

45 lines
1.1 KiB
Crystal

class Invidious::Routes::Misc < Invidious::Routes::BaseRoute
def home(env)
preferences = env.get("preferences").as(Preferences)
locale = LOCALES[preferences.locale]?
user = env.get? "user"
case preferences.default_home
when "Popular"
env.redirect "/feed/popular"
when "Trending"
env.redirect "/feed/trending"
when "Subscriptions"
if user
env.redirect "/feed/subscriptions"
else
env.redirect "/feed/popular"
end
when "Playlists"
if user
env.redirect "/view_all_playlists"
else
env.redirect "/feed/popular"
end
else
templated "search_homepage", navbar_search: false
end
end
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
def cross_instance_redirect(env)
instance_url = fetch_random_instance
referer = get_referer(env)
env.redirect "https://#{instance_url}#{referer}"
end
end