Add about tab to channels

(cherry picked from commit e8015fc144)
This commit is contained in:
syeopite 2021-04-13 21:02:28 -07:00
parent 2ed4a24dbc
commit 0a2d910668
No known key found for this signature in database
GPG key ID: 6FA616E5A5294A82
5 changed files with 80 additions and 18 deletions

View file

@ -385,6 +385,7 @@
"Download": "Download", "Download": "Download",
"Download as: ": "Download as: ", "Download as: ": "Download as: ",
"%A %B %-d, %Y": "%A %B %-d, %Y", "%A %B %-d, %Y": "%A %B %-d, %Y",
"%B %-d, %Y": "%B %-d, %Y",
"(edited)": "(edited)", "(edited)": "(edited)",
"YouTube comment permalink": "YouTube comment permalink", "YouTube comment permalink": "YouTube comment permalink",
"permalink": "permalink", "permalink": "permalink",
@ -433,5 +434,9 @@
"footer_source_code": "Source code", "footer_source_code": "Source code",
"footer_original_source_code": "Original source code", "footer_original_source_code": "Original source code",
"footer_modfied_source_code": "Modified 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"
} }

View file

@ -98,7 +98,18 @@ module Invidious::Routes::Channels
end end
locale, user, subscriptions, continuation, ucid, channel = data 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 end
# Redirects brand url channels to a normal /channel/:ucid route # Redirects brand url channels to a normal /channel/:ucid route

View file

@ -0,0 +1,35 @@
<% content_type = 4 %>
<% sort_options = Tuple.new %>
<%= rendered "components/channel-information" %>
<div class="pure-g">
<div class="pure-u-3-4">
<div class="h-box">
<h3> <%= translate(locale, "channel_about_page_details_section_header") %> </h3>
<p>Country: <%=channel.country%></p> <!-- Translate Country Names -->
</div>
</div>
<div class="pure-u-1-4">
<div class="h-box">
<h3> <%= translate(locale, "channel_about_page_stats_section_header") %> </h3>
<p> <%= translate(locale, "channel_about_page_stats_joined_label") %>
<time datetime="<%=channel.joined.to_s("%Y-%m-%d")%>">
<%= channel.joined.to_s(translate(locale, "%B %-d, %Y")) %>
</time>
</p>
<p><%= channel.total_views ? translate(locale, "`x` views", number_with_separator(channel.total_views || 0)) : "" %></p>
</div>
</div>
<div class="pure-u-2-3" id="external-links">
<div class="h-box">
<h3> <%= translate(locale, "channel_about_page_links_section_header") %> </h3>
<% channel.links.each do |link_tuple| %>
<p class="pure-u-11-24">
<a href="<%=link_tuple[1]%>"><%=link_tuple[0]%></a>
</p>
<% end %>
</div>
</div>
</div>

View file

@ -1,7 +1,4 @@
<% content_type = 2 %> <% content_type = 2 %>
<%
# Make compiler happy
%>
<% sort_options = Tuple.new %> <% sort_options = Tuple.new %>
<%= rendered "components/channel-information" %> <%= rendered "components/channel-information" %>

View file

@ -92,6 +92,20 @@
<% end %> <% end %>
<% end %> <% end %>
<% if content_type == 4 %>
<li class="pure-menu-item pure-menu-selected">
<a class="pure-menu-link" href="/channel/<%= channel.ucid %>/about">
<b> <%= translate(locale, "About") %> </b>
</a>
</li>
<% else %>
<li class="pure-menu-item">
<a class="pure-menu-link" href="/channel/<%= channel.ucid %>/about">
<%= translate(locale, "About") %>
</a>
</li>
<% end %>
<% if !channel.auto_generated %> <% if !channel.auto_generated %>
<li class="pure-menu-item navbar" style="margin: 0 0 0 0.5em"> <li class="pure-menu-item navbar" style="margin: 0 0 0 0.5em">
<div class="searchbar"> <div class="searchbar">