Add about tab to channels

This commit is contained in:
syeopite 2021-04-13 21:02:28 -07:00
parent 90bd19dc45
commit e8015fc144
No known key found for this signature in database
GPG key ID: 6FA616E5A5294A82
5 changed files with 80 additions and 19 deletions

View file

@ -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",
}

View file

@ -98,8 +98,18 @@ module Invidious::Routes::Channels
end
locale, user, subscriptions, continuation, ucid, channel = data
env.redirect "/channel/#{ucid}"
end
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
def self.brand_redirect(env)

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, "Details") %> </h3>
<p>Country: <%=channel.country%></p> <!-- Translate Country Names -->
</div>
</div>
<div class="pure-u-1-4">
<div class="h-box">
<h3> <%= translate(locale, "Stats") %> </h3>
<p> <%= translate(locale, "Joined") %>
<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, "Links") %> </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 %>
<%
# Make compiler happy
%>
<% sort_options = Tuple.new %>
<%= rendered "components/channel-information" %>

View file

@ -77,19 +77,33 @@
<% end %>
<% if channel.tabs.includes? "community" %>
<% if content_type == 2 %>
<li class="pure-menu-item pure-menu-selected">
<a class="pure-menu-link" href="/channel/<%= channel.ucid %>/community">
<b> <%= translate(locale, "Community") %> </b>
</a>
</li>
<% else %>
<li class="pure-menu-item">
<a class="pure-menu-link" href="/channel/<%= channel.ucid %>/community">
<%= translate(locale, "Community") %>
</a>
</li>
<% end %>
<% if content_type == 2 %>
<li class="pure-menu-item pure-menu-selected">
<a class="pure-menu-link" href="/channel/<%= channel.ucid %>/community">
<b> <%= translate(locale, "Community") %> </b>
</a>
</li>
<% else %>
<li class="pure-menu-item">
<a class="pure-menu-link" href="/channel/<%= channel.ucid %>/community">
<%= translate(locale, "Community") %>
</a>
</li>
<% 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 %>