forked from midou/invidious
Provide rough draft of better project organization
This commit is contained in:
8
src/invidious/routes/base_route.cr
Normal file
8
src/invidious/routes/base_route.cr
Normal file
@ -0,0 +1,8 @@
|
||||
abstract class Invidious::Routes::BaseRoute
|
||||
private getter config : Config
|
||||
|
||||
def initialize(@config)
|
||||
end
|
||||
|
||||
abstract def handle(env)
|
||||
end
|
34
src/invidious/routes/home.cr
Normal file
34
src/invidious/routes/home.cr
Normal file
@ -0,0 +1,34 @@
|
||||
class Invidious::Routes::Home < Invidious::Routes::BaseRoute
|
||||
def handle(env)
|
||||
preferences = env.get("preferences").as(Preferences)
|
||||
locale = LOCALES[preferences.locale]?
|
||||
user = env.get? "user"
|
||||
|
||||
case preferences.default_home
|
||||
when ""
|
||||
templated "empty"
|
||||
when "Popular"
|
||||
templated "popular"
|
||||
when "Trending"
|
||||
env.redirect "/feed/trending"
|
||||
when "Subscriptions"
|
||||
if user
|
||||
env.redirect "/feed/subscriptions"
|
||||
else
|
||||
templated "popular"
|
||||
end
|
||||
when "Playlists"
|
||||
if user
|
||||
env.redirect "/view_all_playlists"
|
||||
else
|
||||
templated "popular"
|
||||
end
|
||||
else
|
||||
templated "empty"
|
||||
end
|
||||
end
|
||||
|
||||
private def popular_videos
|
||||
Jobs::PullPopularVideosJob::POPULAR_VIDEOS.get
|
||||
end
|
||||
end
|
6
src/invidious/routes/licenses.cr
Normal file
6
src/invidious/routes/licenses.cr
Normal file
@ -0,0 +1,6 @@
|
||||
class Invidious::Routes::Licenses < Invidious::Routes::BaseRoute
|
||||
def handle(env)
|
||||
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
||||
rendered "licenses"
|
||||
end
|
||||
end
|
6
src/invidious/routes/privacy.cr
Normal file
6
src/invidious/routes/privacy.cr
Normal file
@ -0,0 +1,6 @@
|
||||
class Invidious::Routes::Privacy < Invidious::Routes::BaseRoute
|
||||
def handle(env)
|
||||
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
||||
templated "privacy"
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user