add Compilation symbols

This commit is contained in:
broquemonsieur 2023-06-06 23:54:34 -07:00
parent 8aff1d0409
commit 5fb47c5e9e
12 changed files with 24 additions and 7 deletions

View File

@ -627,11 +627,11 @@ default_user_preferences:
## ##
## Accepted values: A list of strings ## Accepted values: A list of strings
## Each entry can be one of: "Popular", "Trending", ## Each entry can be one of: "Popular", "Trending",
## "Subscriptions", "Playlists" ## "Subscriptions", "Playlists", "Compilations"
## ##
## Default: ["Popular", "Trending", "Subscriptions", "Playlists"] (show all feeds) ## Default: ["Popular", "Trending", "Subscriptions", "Playlists","Compilations"] (show all feeds)
## ##
#feed_menu: ["Popular", "Trending", "Subscriptions", "Playlists"] #feed_menu: ["Popular", "Trending", "Subscriptions", "Playlists","Compilations"]
## ##
## Default feed to display on the home page. ## Default feed to display on the home page.

View File

@ -413,6 +413,7 @@
"Audio mode": "Audio mode", "Audio mode": "Audio mode",
"Video mode": "Video mode", "Video mode": "Video mode",
"Playlists": "Playlists", "Playlists": "Playlists",
"Compilations": "Compilations",
"search_filters_title": "Filters", "search_filters_title": "Filters",
"search_filters_date_label": "Upload date", "search_filters_date_label": "Upload date",
"search_filters_date_option_none": "Any date", "search_filters_date_option_none": "Any date",

View File

@ -8,6 +8,7 @@ require "../src/invidious/channels/*"
require "../src/invidious/videos/caption" require "../src/invidious/videos/caption"
require "../src/invidious/videos" require "../src/invidious/videos"
require "../src/invidious/playlists" require "../src/invidious/playlists"
require "../src/invidious/compilations"
require "../src/invidious/search/ctoken" require "../src/invidious/search/ctoken"
require "../src/invidious/trending" require "../src/invidious/trending"
require "spectator" require "spectator"

View File

@ -121,7 +121,7 @@ Kemal.config.extra_options do |parser|
puts SOFTWARE.to_pretty_json puts SOFTWARE.to_pretty_json
exit exit
end end
parser.on("--migrate", "Run any migrations (beta, use at your own risk!!") do parser.on("--migrate", "Run any migrations (beta, use at your own risk!!)") do
Invidious::Database::Migrator.new(PG_DB).migrate Invidious::Database::Migrator.new(PG_DB).migrate
exit exit
end end

View File

@ -5,6 +5,10 @@ module Invidious::Routes::Feeds
env.redirect "/feed/playlists" env.redirect "/feed/playlists"
end end
def self.compilations(env)
templated "feeds/compilations"
end
def self.playlists(env) def self.playlists(env)
locale = env.get("preferences").as(Preferences).locale locale = env.get("preferences").as(Preferences).locale

View File

@ -23,6 +23,12 @@ module Invidious::Routes::Misc
else else
env.redirect "/feed/popular" env.redirect "/feed/popular"
end end
when "Compilations"
if user
env.redirect "/feed/compilations"
else
env.redirect "/feed/popular"
end
else else
templated "search_homepage", navbar_search: false templated "search_homepage", navbar_search: false
end end

View File

@ -99,7 +99,7 @@ module Invidious::Routes::PreferencesRoute
default_home = env.params.body["default_home"]?.try &.as(String) || CONFIG.default_user_preferences.default_home default_home = env.params.body["default_home"]?.try &.as(String) || CONFIG.default_user_preferences.default_home
feed_menu = [] of String feed_menu = [] of String
4.times do |index| 5.times do |index|
option = env.params.body["feed_menu[#{index}]"]?.try &.as(String) || "" option = env.params.body["feed_menu[#{index}]"]?.try &.as(String) || ""
if !option.empty? if !option.empty?
feed_menu << option feed_menu << option

View File

@ -99,6 +99,7 @@ module Invidious::Routing
get "/feed/popular", Routes::Feeds, :popular get "/feed/popular", Routes::Feeds, :popular
get "/feed/trending", Routes::Feeds, :trending get "/feed/trending", Routes::Feeds, :trending
get "/feed/subscriptions", Routes::Feeds, :subscriptions get "/feed/subscriptions", Routes::Feeds, :subscriptions
get "/feed/compilations", Routes::Feeds, :compilations
get "/feed/history", Routes::Feeds, :history get "/feed/history", Routes::Feeds, :history
# RSS Feeds # RSS Feeds

View File

@ -1,7 +1,7 @@
<div class="feed-menu"> <div class="feed-menu">
<% feed_menu = env.get("preferences").as(Preferences).feed_menu.dup %> <% feed_menu = env.get("preferences").as(Preferences).feed_menu.dup %>
<% if !env.get?("user") %> <% if !env.get?("user") %>
<% feed_menu.reject! {|item| {"Subscriptions", "Playlists"}.includes? item} %> <% feed_menu.reject! {|item| {"Subscriptions", "Playlists", "Compilations"}.includes? item} %>
<% end %> <% end %>
<% feed_menu.each do |feed| %> <% feed_menu.each do |feed| %>
<a href="/feed/<%= feed.downcase %>" class="feed-menu-item pure-menu-heading"> <a href="/feed/<%= feed.downcase %>" class="feed-menu-item pure-menu-heading">

View File

@ -0,0 +1,4 @@
<% content_for "header" do %>
<title><%= translate(locale, "Compilations") %> - Invidious</title>
<% end %>

View File

@ -165,7 +165,7 @@
</div> </div>
<% if env.get?("user") %> <% if env.get?("user") %>
<% feed_options = {"", "Popular", "Trending", "Subscriptions", "Playlists"} %> <% feed_options = {"", "Popular", "Trending", "Subscriptions", "Playlists","Compilations"} %>
<% else %> <% else %>
<% feed_options = {"", "Popular", "Trending"} %> <% feed_options = {"", "Popular", "Trending"} %>
<% end %> <% end %>