Provide rough draft of better project organization

This commit is contained in:
Matthew McGarvey
2020-10-05 23:41:18 -05:00
parent 1978c3d3bd
commit 85c212aee3
9 changed files with 115 additions and 43 deletions

View File

@ -0,0 +1,8 @@
abstract class Invidious::Routes::BaseRoute
private getter config : Config
def initialize(@config)
end
abstract def handle(env)
end

View 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

View 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

View 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