Merge pull request #1609 from saltycrys/add-popular-enabled-option

Add `popular-enabled` option
This commit is contained in:
Perflyst
2020-12-28 11:30:55 +01:00
committed by GitHub
6 changed files with 48 additions and 14 deletions

View File

@@ -5,30 +5,24 @@ class Invidious::Routes::Home < Invidious::Routes::BaseRoute
user = env.get? "user"
case preferences.default_home
when ""
templated "empty"
when "Popular"
templated "popular"
env.redirect "/feed/popular"
when "Trending"
env.redirect "/feed/trending"
when "Subscriptions"
if user
env.redirect "/feed/subscriptions"
else
templated "popular"
env.redirect "/feed/popular"
end
when "Playlists"
if user
env.redirect "/view_all_playlists"
else
templated "popular"
env.redirect "/feed/popular"
end
else
templated "empty"
end
end
private def popular_videos
Jobs::PullPopularVideosJob::POPULAR_VIDEOS.get
end
end

View File

@@ -158,6 +158,10 @@ class Invidious::Routes::UserPreferences < Invidious::Routes::BaseRoute
end
config.default_user_preferences.feed_menu = admin_feed_menu
popular_enabled = env.params.body["popular_enabled"]?.try &.as(String)
popular_enabled ||= "off"
config.popular_enabled = popular_enabled == "on"
captcha_enabled = env.params.body["captcha_enabled"]?.try &.as(String)
captcha_enabled ||= "off"
config.captcha_enabled = captcha_enabled == "on"