diff --git a/src/invidious.cr b/src/invidious.cr index 4af87648..0ab526f8 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -1760,6 +1760,7 @@ get "/channel/:ucid/playlists" do |env| continuation = env.params.query["continuation"]? + 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 00d2dcc2..7e0777fd 100644 --- a/src/invidious/views/channel.ecr +++ b/src/invidious/views/channel.ecr @@ -1,113 +1,6 @@ -<% content_for "header" do %> -<%= channel.author %> - Invidious - -<% end %> +<% content_type = 0 %> -<% 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 %> -
  • - - <%= 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_slice(4) do |slice| %> diff --git a/src/invidious/views/community.ecr b/src/invidious/views/community.ecr index b0092e5f..a89a16d9 100644 --- a/src/invidious/views/community.ecr +++ b/src/invidious/views/community.ecr @@ -1,68 +1,9 @@ -<% content_for "header" do %> -<%= channel.author %> - Invidious -<% end %> - -<% if channel.banner %> -
    - "> -
    - -
    -
    -
    -<% end %> - -
    -
    -
    - - <%= channel.author %> -
    -
    -
    -

    - -

    -
    -
    - -
    -

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

    -
    - -
    - <% ucid = channel.ucid %> - <% author = channel.author %> - <% 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 975ccd6c..09bde10c 100644 --- a/src/invidious/views/playlists.ecr +++ b/src/invidious/views/playlists.ecr @@ -1,87 +1,6 @@ -<% content_for "header" do %> -<%= channel.author %> - Invidious -<% end %> +<% content_type = 1 %> -<% if channel.banner %> -
    - "> -
    - -
    -
    -
    -<% end %> - -
    -
    -
    - - <%= channel.author %> -
    -
    -
    -

    - -

    -
    -
    - -
    -

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

    -
    - -
    - <% ucid = channel.ucid %> - <% author = channel.author %> - <% 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_slice(4) do |slice| %>