diff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.cr index 11c2f869..c11833d2 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 40f2804b..786ea4e8 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/components/channel-information.ecr b/src/invidious/views/components/channel-information.ecr new file mode 100644 index 00000000..6e636922 --- /dev/null +++ b/src/invidious/views/components/channel-information.ecr @@ -0,0 +1,146 @@ +<% content_for "header" do %> +<%= channel.author %> - Invidious + +<% end %> + +<% if channel.banner %> +
    + "> +
    + +
    +
    +
    +<% end %> + +
    +
    +
    + + <%= channel.author %> +
    +
    +
    +

    + +

    +
    +
    + +
    +

    <%= channel.description_html %>

    +
    + +
    + <% ucid = channel.ucid %> + <% author = channel.author %> + <% sub_count_text = number_to_short_text(channel.sub_count) %> + <%= rendered "components/subscribe_widget" %> +
    + +
    +
    + + + +
    + + <% if !channel.auto_generated %> + <% if content_type == 0 %> +
  • + + <%= translate(locale, "Videos") %> + +
  • + <% else %> +
  • + + <%= translate(locale, "Videos") %> + +
  • + <% end %> + <% end %> + + <% if content_type == 1 || channel.auto_generated %> +
  • + + <%= translate(locale, "Playlists") %> + +
  • + <% else %> +
  • + + <%= translate(locale, "Playlists") %> + +
  • + <% end %> + + <% if channel.tabs.includes? "community" %> + <% if content_type == 2 %> +
  • + + <%= translate(locale, "Community") %> + +
  • + <% else %> +
  • + + <%= translate(locale, "Community") %> + +
  • + <% end %> + <% end %> + + <% if !channel.auto_generated %> + + <% end %> +
    +
    +
    +
    + + <% if content_type == 0 || content_type == 1 %> + <% route = content_type == 1 ? "/playlists" : "" %> + <% url = "/channel/#{channel.ucid + route}" %> + <% if env.params.query %> + <% url += "?#{env.params.query}"%> + <% end %> + +
    +
    + +
    +
    + <% end %> +
    + +
    +
    +
    diff --git a/src/invidious/views/playlists.ecr b/src/invidious/views/playlists.ecr index d9a17a9b..ed196b65 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| %>