From 0a2d9106688d644e143382801163d296ab9d06b4 Mon Sep 17 00:00:00 2001 From: syeopite Date: Tue, 13 Apr 2021 21:02:28 -0700 Subject: [PATCH] Add about tab to channels (cherry picked from commit e8015fc144324505563a46f7a8869d9be0622a96) --- locales/en-US.json | 7 +++- src/invidious/routes/channels.cr | 13 +++++- src/invidious/views/channel_about.ecr | 35 ++++++++++++++++ src/invidious/views/community.ecr | 3 -- .../views/components/channel-information.ecr | 40 +++++++++++++------ 5 files changed, 80 insertions(+), 18 deletions(-) create mode 100644 src/invidious/views/channel_about.ecr diff --git a/locales/en-US.json b/locales/en-US.json index 1b2ec894..e7765e2b 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -385,6 +385,7 @@ "Download": "Download", "Download as: ": "Download as: ", "%A %B %-d, %Y": "%A %B %-d, %Y", + "%B %-d, %Y": "%B %-d, %Y", "(edited)": "(edited)", "YouTube comment permalink": "YouTube comment permalink", "permalink": "permalink", @@ -433,5 +434,9 @@ "footer_source_code": "Source code", "footer_original_source_code": "Original source code", "footer_modfied_source_code": "Modified Source code", - "adminprefs_modified_source_code_url_label": "URL to modified source code repository" + "adminprefs_modified_source_code_url_label": "URL to modified source code repository", + "channel_about_page_details_section_header": "Details", + "channel_about_page_stats_section_header": "Stats", + "channel_about_page_stats_joined_label": "Joined", + "channel_about_page_links_section_header": "Links" } diff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.cr index cb80d2b4..64a8655e 100644 --- a/src/invidious/routes/channels.cr +++ b/src/invidious/routes/channels.cr @@ -98,7 +98,18 @@ module Invidious::Routes::Channels end locale, user, subscriptions, continuation, ucid, channel = data - env.redirect "/channel/#{ucid}" + ucid = env.params.url["ucid"] + continuation = env.params.query["continuation"]? + + begin + channel = get_about_info(ucid, locale) + rescue ex : ChannelRedirect + next env.redirect env.request.resource.gsub(ucid, ex.channel_id) + rescue ex + next error_template(500, ex) + end + + templated "channel_about" end # Redirects brand url channels to a normal /channel/:ucid route diff --git a/src/invidious/views/channel_about.ecr b/src/invidious/views/channel_about.ecr new file mode 100644 index 00000000..593872bf --- /dev/null +++ b/src/invidious/views/channel_about.ecr @@ -0,0 +1,35 @@ +<% content_type = 4 %> +<% sort_options = Tuple.new %> +<%= rendered "components/channel-information" %> + +
+
+
+

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

+

Country: <%=channel.country%>

+
+
+ +
+
+

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

+

<%= translate(locale, "channel_about_page_stats_joined_label") %> + +

+

<%= channel.total_views ? translate(locale, "`x` views", number_with_separator(channel.total_views || 0)) : "" %>

+
+
+ + +
diff --git a/src/invidious/views/community.ecr b/src/invidious/views/community.ecr index 3288f6b7..7d8fefbe 100644 --- a/src/invidious/views/community.ecr +++ b/src/invidious/views/community.ecr @@ -1,7 +1,4 @@ <% content_type = 2 %> -<% -# Make compiler happy -%> <% sort_options = Tuple.new %> <%= rendered "components/channel-information" %> diff --git a/src/invidious/views/components/channel-information.ecr b/src/invidious/views/components/channel-information.ecr index 8cf49c55..a756a446 100644 --- a/src/invidious/views/components/channel-information.ecr +++ b/src/invidious/views/components/channel-information.ecr @@ -77,19 +77,33 @@ <% end %> <% if channel.tabs.includes? "community" %> - <% if content_type == 2 %> -
  • - - <%= translate(locale, "Community") %> - -
  • - <% else %> -
  • - - <%= translate(locale, "Community") %> - -
  • - <% end %> + <% if content_type == 2 %> +
  • + + <%= translate(locale, "Community") %> + +
  • + <% else %> +
  • + + <%= translate(locale, "Community") %> + +
  • + <% end %> + <% end %> + + <% if content_type == 4 %> +
  • + + <%= translate(locale, "About") %> + +
  • + <% else %> +
  • + + <%= translate(locale, "About") %> + +
  • <% end %> <% if !channel.auto_generated %>