From 2a9789cc1ec27addea9af716e5d1247a793a1cfa Mon Sep 17 00:00:00 2001 From: broquemonsieur Date: Mon, 3 Jul 2023 19:46:29 -0700 Subject: [PATCH] Add CSS element for compilation video --- assets/css/default.css | 16 +++- src/invidious/routing.cr | 1 + src/invidious/search/query.cr | 9 +- src/invidious/views/compilation.ecr | 96 +++++++++++++++++++ .../views/components/compilation_video.ecr | 15 +++ src/invidious/views/components/item.ecr | 80 +++++++++++++++- 6 files changed, 208 insertions(+), 9 deletions(-) create mode 100644 src/invidious/views/components/compilation_video.ecr diff --git a/assets/css/default.css b/assets/css/default.css index 9828513a..504329cd 100644 --- a/assets/css/default.css +++ b/assets/css/default.css @@ -761,8 +761,16 @@ h1, h2, h3, h4, h5, p, } div.compilation-video-panel { - display: block; - margin-left: auto; - margin-right: auto; - color: #d9d9d9; + padding: 28.125%; + position: relative; + box-sizing: border-box; } + +img.compilation-video-panel { + position: absolute; + width: 100%; + height: 100%; + left: 0; + top: 0; + object-fit: cover; +} \ No newline at end of file diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr index d64ccceb..ac01694d 100644 --- a/src/invidious/routing.cr +++ b/src/invidious/routing.cr @@ -86,6 +86,7 @@ module Invidious::Routing get "/create_compilation", Routes::Compilations, :new post "/create_compilation", Routes::Compilations, :create post "/compilation_ajax", Routes::Compilations, :compilation_ajax + get "/add_compilation_items", Routes::Compilations, :add_compilation_items_page end def register_iv_playlist_routes diff --git a/src/invidious/search/query.cr b/src/invidious/search/query.cr index e38845d9..de64388e 100644 --- a/src/invidious/search/query.cr +++ b/src/invidious/search/query.cr @@ -8,6 +8,7 @@ module Invidious::Search # Types specific to Invidious Subscriptions # Search user subscriptions Playlist # "Add playlist item" search + Compilation # "Add compilation item" search end getter type : Type = Type::Regular @@ -75,6 +76,12 @@ module Invidious::Search # @filters, _, @query, _ = Filters.from_legacy_filters(@raw_query) # + when .compilation? + # In "add compilation item" mode, filters are parsed from the query + # string itself (legacy), and the channel is ignored. + # + @filters, _, @query, _ = Filters.from_legacy_filters(@raw_query) + # when .subscriptions?, .regular? if params["sp"]? # Parse the `sp` URL parameter (youtube compatibility) @@ -112,7 +119,7 @@ module Invidious::Search return items if self.empty_raw_query? case @type - when .regular?, .playlist? + when .regular?, .playlist?, .compilation? items = Processors.regular(self) # when .channel? diff --git a/src/invidious/views/compilation.ecr b/src/invidious/views/compilation.ecr index 741f6770..6bcd7d0f 100644 --- a/src/invidious/views/compilation.ecr +++ b/src/invidious/views/compilation.ecr @@ -6,3 +6,99 @@ <% end %> +
+
+

<%= title %>

+ <% if compilation.is_a? InvidiousCompilation %> + + <% if compilation.author == user.try &.email %> + <%= author %> | + <% else %> + <%= author %> | + <% end %> + <%= translate_count(locale, "generic_videos_count", compilation.video_count) %> | + <%= translate(locale, "Updated `x` ago", recode_date(compilation.updated, locale)) %> | + <% case compilation.as(InvidiousCompilation).privacy when %> + <% when CompilationPrivacy::Unlisted %> + <%= translate(locale, "Unlisted") %> + <% when CompilationPrivacy::Private %> + <%= translate(locale, "Private") %> + <% end %> + + <% else %> + + <%= author %> | + <%= translate_count(locale, "generic_videos_count", compilation.video_count) %> | + <%= translate(locale, "Updated `x` ago", recode_date(compilation.updated, locale)) %> + + <% end %> +
+
+

+
+ <% if compilation.is_a?(InvidiousCompilation) && compilation.author == user.try &.email %> +
+
+ <% else %> + <% if !Invidious::Database::Compilations.exists?(compilation.id) %> +
+ <% end %> + <% end %> +
+
+

+
+
+ +
+
<%= compilation.description_html %>
+
+ +<% if compilation.is_a?(InvidiousCompilation) && compilation.author == user.try &.email %> +
+

+ +

+
+<% end %> + +
+
+
+ +<% if compilation.is_a?(InvidiousCompilation) && compilation.author == user.try &.email %> + + +<% end %> + +
+<% videos.each do |compilation_video| %> + <%= rendered "components/compilation_video" %> +<% end %> +
+ + + +
+
+ <% if page > 1 %> + + <%= translate(locale, "Previous page") %> + + <% end %> +
+
+
+ <% if page_count != 1 && page < page_count %> + + <%= translate(locale, "Next page") %> + + <% end %> +
+
\ No newline at end of file diff --git a/src/invidious/views/components/compilation_video.ecr b/src/invidious/views/components/compilation_video.ecr new file mode 100644 index 00000000..0feb34ea --- /dev/null +++ b/src/invidious/views/components/compilation_video.ecr @@ -0,0 +1,15 @@ +
+
+
+
+ + + + + + +
+ +
+
+
\ No newline at end of file diff --git a/src/invidious/views/components/item.ecr b/src/invidious/views/components/item.ecr index e01a119e..57115b8f 100644 --- a/src/invidious/views/components/item.ecr +++ b/src/invidious/views/components/item.ecr @@ -102,13 +102,78 @@

<%= HTML.escape(item.author) %><% if !item.is_a?(InvidiousCompilation) && !item.is_a?(InvidiousPlaylist) && !item.author_verified.nil? && item.author_verified %> <% end %>

<% when CompilationVideo %> - +
+ +
+ <% when PlaylistVideo %> +
+ <% if !env.get("preferences").as(Preferences).thin_mode %> +
+ + + <% if plid_form = env.get?("remove_playlist_items") %> +
" method="post"> + "> +

+ +

+
+ <% end %> + + <% if item.responds_to?(:live_now) && item.live_now %> +

<%= translate(locale, "LIVE") %>

+ <% elsif item.length_seconds != 0 %> +

<%= recode_length_seconds(item.length_seconds) %>

+ <% end %> + + <% if item_watched %> +
+
+ <% end %> +
+ <% end %> +

<%= HTML.escape(item.title) %>

+
+ +
+ + <% endpoint_params = "?v=#{item.id}&list=#{item.plid}" %> + <%= rendered "components/video-context-buttons" %> +
+ +
+
+ <% if item.responds_to?(:premiere_timestamp) && item.premiere_timestamp.try &.> Time.utc %> +

<%= translate(locale, "Premieres in `x`", recode_date((item.premiere_timestamp.as(Time) - Time.utc).ago, locale)) %>

+ <% elsif Time.utc - item.published > 1.minute %> +

<%= translate(locale, "Shared `x` ago", recode_date(item.published, locale)) %>

+ <% end %> +
+ + <% if item.responds_to?(:views) && item.views %> +
+

<%= translate_count(locale, "generic_views_count", item.views || 0, NumberFormatting::Short) %>

+
+ <% end %> +
<% when Category %> <% else %> <%- @@ -157,6 +222,13 @@ + <% elsif compid_form = env.get? "add_compilation_items" %> +
" method="post"> + "> +

+ +

+
<%- elsif item.is_a?(PlaylistVideo) && (plid_form = env.get?("remove_playlist_items")) -%> <%- form_parameters = "action_remove_video=1&set_video_id=#{item.index}&playlist_id=#{plid_form}&referer=#{env.get("current_page")}" -%>