From af385663c428e29e69c6707ee2e914531fab4e4f 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 --- locales/en-US.json | 7 +++- src/invidious.cr | 30 +++++++++++--- src/invidious/views/channel_about.ecr | 35 ++++++++++++++++ src/invidious/views/community.ecr | 3 -- .../views/components/channel-information.ecr | 40 +++++++++++++------ 5 files changed, 93 insertions(+), 22 deletions(-) create mode 100644 src/invidious/views/channel_about.ecr diff --git a/locales/en-US.json b/locales/en-US.json index 88daa4eb..7e836546 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -384,6 +384,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", @@ -423,5 +424,9 @@ "Current version: ": "Current version: ", "next_steps_error_message": "After which you should try to: ", "next_steps_error_message_refresh": "Refresh", - "next_steps_error_message_go_to_youtube": "Go to Youtube" + "next_steps_error_message_go_to_youtube": "Go to Youtube", + "Details": "Details", + "Stats": "Stats", + "Joined": "Joined", + "Links": "Links", } diff --git a/src/invidious.cr b/src/invidious.cr index 0ab526f8..7e7e238a 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -1674,11 +1674,6 @@ get "/user/:user/about" do |env| env.redirect "/channel/#{user}" end -get "/channel/:ucid/about" do |env| - ucid = env.params.url["ucid"] - env.redirect "/channel/#{ucid}" -end - get "/channel/:ucid" do |env| locale = LOCALES[env.get("preferences").as(Preferences).locale]? @@ -1825,6 +1820,31 @@ get "/channel/:ucid/community" do |env| templated "community" end +get "/channel/:ucid/about" do |env| + locale = LOCALES[env.get("preferences").as(Preferences).locale]? + + user = env.get? "user" + if user + user = user.as(User) + subscriptions = user.subscriptions + end + subscriptions ||= [] of String + + 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 + # API Endpoints get "/api/v1/stats" do |env| diff --git a/src/invidious/views/channel_about.ecr b/src/invidious/views/channel_about.ecr new file mode 100644 index 00000000..8272c1ea --- /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, "Details") %>

+

Country: <%=channel.country%>

+
+
+ +
+
+

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

+

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

+

<%= 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 a89a16d9..68186af5 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 %>