From 8be208c772a672c848c07d8e0ddd8b97ccc74f95 Mon Sep 17 00:00:00 2001 From: syeopite Date: Mon, 12 Apr 2021 03:55:53 -0700 Subject: [PATCH] Refactor channel tab templates (cherry picked from commit 40823d5816eb79109ec148aed81c60c0984e3a37) --- src/invidious/routes/channels.cr | 1 - src/invidious/views/channel.ecr | 114 +----------------------------- src/invidious/views/community.ecr | 74 ++----------------- src/invidious/views/playlists.ecr | 88 +---------------------- 4 files changed, 10 insertions(+), 267 deletions(-) diff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.cr index 29748cd0..cb80d2b4 100644 --- a/src/invidious/routes/channels.cr +++ b/src/invidious/routes/channels.cr @@ -48,7 +48,6 @@ module Invidious::Routes::Channels end locale, user, subscriptions, continuation, ucid, channel = data - sort_options = {"last", "oldest", "newest"} sort_by = env.params.query["sort_by"]?.try &.downcase sort_by ||= "last" diff --git a/src/invidious/views/channel.ecr b/src/invidious/views/channel.ecr index f285358e..cad0a568 100644 --- a/src/invidious/views/channel.ecr +++ b/src/invidious/views/channel.ecr @@ -1,116 +1,6 @@ -<% ucid = channel.ucid %> -<% author = HTML.escape(channel.author) %> +<% content_type = 0 %> -<% content_for "header" do %> -<%= author %> - Invidious - -<% end %> - -<% if channel.banner %> -
- "> -
- -
-
-
-<% end %> - -
-
-
- - <%= author %> -
-
-
-

- -

-
-
- -
-
-

<%= channel.description_html %>

-
-
- -
- <% sub_count_text = number_to_short_text(channel.sub_count) %> - <%= rendered "components/subscribe_widget" %> -
- -
-
- - -
- - <% if !channel.auto_generated %> -
  • - - <%= translate(locale, "Videos") %> - -
  • - <% end %> -
  • - <% if channel.auto_generated %> - <%= translate(locale, "Playlists") %> - <% else %> - - <%= translate(locale, "Playlists") %> - - <% end %> -
  • -
  • - <% if channel.tabs.includes? "community" %> - - <%= translate(locale, "Community") %> - - <% end %> -
  • - -
    -
    -
    -
    -
    -
    - -
    -
    -
    - -
    -
    -
    +<%= rendered "components/channel-information" %>
    <% items.each do |item| %> diff --git a/src/invidious/views/community.ecr b/src/invidious/views/community.ecr index 15d8ed1e..3288f6b7 100644 --- a/src/invidious/views/community.ecr +++ b/src/invidious/views/community.ecr @@ -1,71 +1,9 @@ -<% ucid = channel.ucid %> -<% author = HTML.escape(channel.author) %> - -<% content_for "header" do %> -<%= author %> - Invidious -<% end %> - -<% if channel.banner %> -
    - "> -
    - -
    -
    -
    -<% end %> - -
    -
    -
    - - <%= author %> -
    -
    -
    -

    - -

    -
    -
    - -
    -
    -

    <%= XML.parse_html(channel.description_html).xpath_node(%q(.//pre)).try &.content %>

    -
    -
    - -
    - <% sub_count_text = number_to_short_text(channel.sub_count) %> - <%= rendered "components/subscribe_widget" %> -
    - -
    -
    - <%= translate(locale, "View channel on YouTube") %> - - <% if !channel.auto_generated %> - - <% end %> - -
    - <% if channel.tabs.includes? "community" %> - <%= translate(locale, "Community") %> - <% end %> -
    -
    -
    -
    - -
    -
    -
    +<% content_type = 2 %> +<% +# Make compiler happy +%> +<% sort_options = Tuple.new %> +<%= rendered "components/channel-information" %> <% if error_message %>
    diff --git a/src/invidious/views/playlists.ecr b/src/invidious/views/playlists.ecr index 1245256f..b5e094d8 100644 --- a/src/invidious/views/playlists.ecr +++ b/src/invidious/views/playlists.ecr @@ -1,90 +1,6 @@ -<% ucid = channel.ucid %> -<% author = HTML.escape(channel.author) %> +<% content_type = 1 %> -<% content_for "header" do %> -<%= author %> - Invidious -<% end %> - -<% if channel.banner %> -
    - "> -
    - -
    -
    -
    -<% end %> - -
    -
    -
    - - <%= author %> -
    -
    -
    -

    - -

    -
    -
    - -
    -
    -

    <%= XML.parse_html(channel.description_html).xpath_node(%q(.//pre)).try &.content if !channel.description_html.empty? %>

    -
    -
    - -
    - <% sub_count_text = number_to_short_text(channel.sub_count) %> - <%= rendered "components/subscribe_widget" %> -
    - -
    -
    - - - - - -
    - <% if !channel.auto_generated %> - <%= translate(locale, "Playlists") %> - <% end %> -
    -
    - <% if channel.tabs.includes? "community" %> - <%= translate(locale, "Community") %> - <% end %> -
    -
    -
    -
    -
    - <% {"last", "oldest", "newest"}.each do |sort| %> -
    - <% if sort_by == sort %> - <%= translate(locale, sort) %> - <% else %> - - <%= translate(locale, sort) %> - - <% end %> -
    - <% end %> -
    -
    -
    - -
    -
    -
    +<%= rendered "components/channel-information" %>
    <% items.each do |item| %>