Add compilations to feeds menu

This commit is contained in:
broquemonsieur 2023-06-18 00:12:33 -07:00
parent ea48239543
commit 7cfa09984e
9 changed files with 28 additions and 12 deletions

View File

@ -60,12 +60,21 @@
document.querySelectorAll('[data-onclick="add_playlist_video"]').forEach(function (el) {
el.onclick = function () { add_playlist_video(el); };
});
document.querySelectorAll('[data-onclick="add_compilation_video"]').forEach(function (el) {
el.onclick = function () { add_compilation_video(el); };
});
document.querySelectorAll('[data-onclick="add_playlist_item"]').forEach(function (el) {
el.onclick = function () { add_playlist_item(el); };
});
document.querySelectorAll('[data-onclick="add_compilation_item"]').forEach(function (el) {
el.onclick = function () { add_compilation_item(el); };
});
document.querySelectorAll('[data-onclick="remove_playlist_item"]').forEach(function (el) {
el.onclick = function () { remove_playlist_item(el); };
});
document.querySelectorAll('[data-onclick="remove_compilation_item"]').forEach(function (el) {
el.onclick = function () { remove_compilation_item(el); };
});
document.querySelectorAll('[data-onclick="revoke_token"]').forEach(function (el) {
el.onclick = function () { revoke_token(el); };
});

View File

@ -1,8 +1,8 @@
-- Type: public.privacy
-- Type: public.compilation_privacy
-- DROP TYPE public.privacy;
-- DROP TYPE public.compilation_privacy;
CREATE TYPE public.privacy AS ENUM
CREATE TYPE public.compilation_privacy AS ENUM
(
'Unlisted',
'Private'
@ -21,7 +21,7 @@ CREATE TABLE IF NOT EXISTS public.compilations
video_count integer,
created timestamptz,
updated timestamptz,
privacy privacy,
privacy compilation_privacy,
index int8[]
);

View File

@ -319,8 +319,6 @@ def get_compilation(compid : String)
else
raise NotFoundException.new("Compilation does not exist.")
end
else
return fetch_compilation(compid)
end
end

View File

@ -30,7 +30,7 @@ struct ConfigPreferences
property quality : String = "hd720"
property quality_dash : String = "auto"
property default_home : String? = "Popular"
property feed_menu : Array(String) = ["Popular", "Trending", "Subscriptions", "Playlists"]
property feed_menu : Array(String) = ["Popular", "Trending", "Subscriptions", "Playlists", "Compilations"]
property automatic_instance_redirect : Bool = false
property region : String = "US"
property related_videos : Bool = true
@ -138,6 +138,9 @@ class Config
# Playlist length limit
property playlist_length_limit : Int32 = 500
# Compilation length limit
property compilation_length_limit : Int32 = 500
def disabled?(option)
case disabled = CONFIG.disable_proxy
when Bool

View File

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

View File

@ -27,7 +27,7 @@ module Invidious::Routes::Misc
if user
env.redirect "/feed/compilations"
else
env.redirect "/feed/popyular"
env.redirect "/feed/popular"
end
else
templated "search_homepage", navbar_search: false

View File

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

View File

@ -26,6 +26,7 @@ module Invidious::Routing
self.register_watch_routes
self.register_iv_playlist_routes
self.register_iv_compilation_routes
self.register_yt_playlist_routes
self.register_search_routes
@ -83,6 +84,7 @@ module Invidious::Routing
def register_iv_compilation_routes
get "/create_compilation", Routes::Compilations, :new
post "/create_compilation", Routes::Compilations, :create
post "/compilation_ajax", Routes::Compilations, :compilation_ajax
end
def register_iv_playlist_routes
@ -279,7 +281,7 @@ module Invidious::Routing
post "/api/v1/auth/subscriptions/:ucid", {{namespace}}::Authenticated, :subscribe_channel
delete "/api/v1/auth/subscriptions/:ucid", {{namespace}}::Authenticated, :unsubscribe_channel
get "/api/v1/auth/compilations", {{namespace}}::Authenticated, :create_compilation
post "/api/v1/auth/compilations", {{namespace}}::Authenticated, :create_compilation
get "/api/v1/auth/playlists", {{namespace}}::Authenticated, :list_playlists
post "/api/v1/auth/playlists", {{namespace}}::Authenticated, :create_playlist

View File

@ -174,7 +174,7 @@
<label for="default_home"><%= translate(locale, "preferences_default_home_label") %></label>
<select name="default_home" id="default_home">
<% feed_options.each do |option| %>
<option value="<%= option %>" <% if preferences.default_home == option %> selected <% end %>><%= translate(locale, option.blank? ? "Search" : option) %></option>
<option value="<%= option %>" <% if preferences.default_home == option %> selected <% end %>><%= translate(locale, option.blank? ? "Compilations" : option) %></option>
<% end %>
</select>
</div>
@ -184,7 +184,7 @@
<% (feed_options.size - 1).times do |index| %>
<select name="feed_menu[<%= index %>]" id="feed_menu[<%= index %>]">
<% feed_options.each do |option| %>
<option value="<%= option %>" <% if preferences.feed_menu[index]? == option %> selected <% end %>><%= translate(locale, option.blank? ? "Search" : option) %></option>
<option value="<%= option %>" <% if preferences.feed_menu[index]? == option %> selected <% end %>><%= translate(locale, option.blank? ? "Compilations" : option) %></option>
<% end %>
</select>
<% end %>