Cherry-pick fixes

This commit is contained in:
syeopite 2021-10-27 22:39:02 -07:00
parent 9a06546c5b
commit f4e8bb99ba
No known key found for this signature in database
GPG key ID: 6FA616E5A5294A82
9 changed files with 45 additions and 182 deletions

View file

@ -50,3 +50,10 @@
#link-widget-primary a:hover { #link-widget-primary a:hover {
color: #e1e1e1 !important; color: #e1e1e1 !important;
} }
/* Center sorting options when screen is less than 640px*/
@media screen and (max-width: 640px) {
#sort-options {
margin-right: auto;
}
}

View file

@ -568,4 +568,15 @@ p,
#content-navigation { #content-navigation {
margin-bottom: 0.5em; margin-bottom: 0.5em;
display: flex;
overflow-x: scroll;
overflow-y: hidden;
white-space: nowrap;
-ms-overflow-style: none;
scrollbar-width: none;
}
#content-navigation::-webkit-scrollbar {
display: none; /* Safari and Chrome */
} }

View file

@ -7,6 +7,7 @@ module Invidious::Routes::Channels
def self.videos(env) def self.videos(env)
data = self.fetch_basic_information(env) data = self.fetch_basic_information(env)
if !data.is_a?(Tuple) if !data.is_a?(Tuple)
return data return data
end end
@ -48,6 +49,7 @@ module Invidious::Routes::Channels
end end
locale, user, subscriptions, continuation, ucid, channel = data locale, user, subscriptions, continuation, ucid, channel = data
sort_options = {"last", "oldest", "newest"}
sort_by = env.params.query["sort_by"]?.try &.downcase sort_by = env.params.query["sort_by"]?.try &.downcase
sort_by ||= "last" sort_by ||= "last"
@ -104,9 +106,9 @@ module Invidious::Routes::Channels
begin begin
channel = get_about_info(ucid, locale) channel = get_about_info(ucid, locale)
rescue ex : ChannelRedirect rescue ex : ChannelRedirect
next env.redirect env.request.resource.gsub(ucid, ex.channel_id) return env.redirect env.request.resource.gsub(ucid, ex.channel_id)
rescue ex rescue ex
next error_template(500, ex) return error_template(500, ex)
end end
templated "channel/about" templated "channel/about"
@ -157,11 +159,11 @@ module Invidious::Routes::Channels
end end
end end
private def search(env) def self.search(env)
return env.redirect "/search?#{env.params.query}&channel=#{env.params.url["ucid"]}" return env.redirect "/search?#{env.params.query}&channel=#{env.params.url["ucid"]}"
end end
private def fetch_basic_information(env) private def self.fetch_basic_information(env)
locale = LOCALES[env.get("preferences").as(Preferences).locale]? locale = LOCALES[env.get("preferences").as(Preferences).locale]?
user = env.get? "user" user = env.get? "user"

View file

@ -1,5 +1,5 @@
<% content_for "header" do %> <% content_for "header" do %>
<title><%= channel.author %> - Invidious</title> <title><%= HTML.escape(channel.author) %> - Invidious</title>
<link rel="stylesheet" href="/css/channel.css?v=<%= ASSET_COMMIT %>"> <link rel="stylesheet" href="/css/channel.css?v=<%= ASSET_COMMIT %>">
<link rel="alternate" type="application/rss+xml" title="RSS" href="/feed/channel/<%= channel.ucid %>" > <link rel="alternate" type="application/rss+xml" title="RSS" href="/feed/channel/<%= channel.ucid %>" >
<% end %> <% end %>

View file

@ -1,5 +1,5 @@
<% content_for "header" do %> <% content_for "header" do %>
<title><%= channel.author %> - Invidious</title> <title><%= HTML.escape(channel.author) %> - Invidious</title>
<link rel="stylesheet" href="/css/channel.css?v=<%= ASSET_COMMIT %>"> <link rel="stylesheet" href="/css/channel.css?v=<%= ASSET_COMMIT %>">
<% end %> <% end %>

View file

@ -1,5 +1,5 @@
<% content_for "header" do %> <% content_for "header" do %>
<title><%= channel.author %> - Invidious</title> <title><%= HTML.escape(channel.author) %> - Invidious</title>
<link rel="stylesheet" href="/css/channel.css?v=<%= ASSET_COMMIT %>"> <link rel="stylesheet" href="/css/channel.css?v=<%= ASSET_COMMIT %>">
<% end %> <% end %>

View file

@ -1,3 +1,5 @@
<% author = HTML.escape(channel.author) %>
<% if channel.banner %> <% if channel.banner %>
<div class="pure-g" id="channel-banner-container"> <div class="pure-g" id="channel-banner-container">
<div class="pure-u-1" id="banner" style='background-image: url(/ggpht<%= URI.parse(channel.banner.not_nil!.gsub("=w1060-", "=w1280-")).request_target %>)'> <div class="pure-u-1" id="banner" style='background-image: url(/ggpht<%= URI.parse(channel.banner.not_nil!.gsub("=w1060-", "=w1280-")).request_target %>)'>
@ -33,14 +35,14 @@
<% end %> <% end %>
<div class="pure-g h-box"> <div class="pure-g h-box">
<div class="pure-u-2-3"> <div class="pure-u-1">
<div class="channel-profile"> <div class="pure-u-1-2 channel-profile">
<img src="/ggpht<%= URI.parse(channel.author_thumbnail).request_target %>"> <img src="/ggpht<%= URI.parse(channel.author_thumbnail).request_target %>">
<span><%= channel.author %></span> <span><%= author %></span>
</div> </div>
</div>
<div class="pure-u-1-3" style="text-align:right"> <div class="pure-u-1-2" style="float: right;">
<h3> <h3 style="text-align:right">
<a href="/feed/channel/<%= channel.ucid %>"><i class="icon ion-logo-rss"></i></a> <a href="/feed/channel/<%= channel.ucid %>"><i class="icon ion-logo-rss"></i></a>
<a title="<%=translate(locale, "Watch on YouTube")%>" href="https://youtube.com/<%=URI.decode_www_form(env.get("current_page").to_s)%>"> <a title="<%=translate(locale, "Watch on YouTube")%>" href="https://youtube.com/<%=URI.decode_www_form(env.get("current_page").to_s)%>">
<i class="icon ion-logo-youtube"></i> <i class="icon ion-logo-youtube"></i>
@ -50,6 +52,7 @@
</a> </a>
</h3> </h3>
</div> </div>
</div>
</div> </div>
<div class="h-box"> <div class="h-box">
@ -58,7 +61,6 @@
<div class="h-box"> <div class="h-box">
<% ucid = channel.ucid %> <% ucid = channel.ucid %>
<% author = channel.author %>
<% sub_count_text = number_to_short_text(channel.sub_count) %> <% sub_count_text = number_to_short_text(channel.sub_count) %>
<%= rendered "components/subscribe_widget" %> <%= rendered "components/subscribe_widget" %>
</div> </div>
@ -67,20 +69,6 @@
<!-- TODO Refactor this! --> <!-- TODO Refactor this! -->
<div class="pure-menu pure-menu-horizontal"> <div class="pure-menu pure-menu-horizontal">
<ul class="pure-menu-list"> <ul class="pure-menu-list">
<!-- <% if content_type == 0 %>
<li class="pure-menu-item pure-menu-selected">
<a class="pure-menu-link" href="/channel/<%= channel.ucid %>">
<b> <%= translate(locale, "Home") %> </b>
</a>
</li>
<% else %>
<li class="pure-menu-item">
<a class="pure-menu-link" href="/channel/<%= channel.ucid %>">
<%= translate(locale, "Home") %>
</a>
</li>
<% end -%> -->
<% if !channel.auto_generated %> <% if !channel.auto_generated %>
<% if content_type == 1 %> <% if content_type == 1 %>
<li class="pure-menu-item pure-menu-selected"> <li class="pure-menu-item pure-menu-selected">
@ -127,20 +115,6 @@
<% 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 %>/channels">
<b> <%= translate(locale, "Channels") %> </b>
</a>
</li>
<% else %>
<li class="pure-menu-item">
<a class="pure-menu-link" href="/channel/<%= channel.ucid %>/channels">
<%= translate(locale, "Channels") %>
</a>
</li>
<% end -%>
<% if content_type == 5 %> <% if content_type == 5 %>
<li class="pure-menu-item pure-menu-selected"> <li class="pure-menu-item pure-menu-selected">
<a class="pure-menu-link" href="/channel/<%= channel.ucid %>/about"> <a class="pure-menu-link" href="/channel/<%= channel.ucid %>/about">

View file

@ -1,4 +1,3 @@
<div class="h-box"> <div class="h-box">
<% route = content_type == 1 ? "/videos" : "/playlists" %> <% route = content_type == 1 ? "/videos" : "/playlists" %>
<% url = "/channel/#{channel.ucid + route}" %> <% url = "/channel/#{channel.ucid + route}" %>

View file

@ -1,130 +0,0 @@
<% operators = operators.not_nil! %>
<details id="filters">
<summary class="simulated_a">
<h3 style="display:inline"> <%= translate(locale, "filter") %> </h3>
</summary>
<div id="filters" class="pure-g h-box">
<!-- Grabs all search filters. This is to make sure we don't accidently overwrite something within the
search query later on-->
<% filter_params = env.request.query_params.to_s.gsub(/q=.+?(?=&|$)/, "") %>
<% base_url = "/search?q=#{HTML.escape(query.not_nil!)}" %>
<div class="pure-u-1-3 pure-u-md-1-5 filter-catagory" id="filter-date">
<b><%= translate(locale, "date") %></b>
<hr/>
<ul class="pure-menu-list">
<% ["hour", "today", "week", "month", "year"].each do |date| %>
<li class="pure-menu-item">
<% if operators.fetch("date", "all") == date %>
<a style="color: inherit;" href="<%= base_url + "#{filter_params.gsub(/&date=[a-z]+/, "")}"%>">
<b><%= translate(locale, date) %></b>
<i class="remove-filter icon ion-md-close"></i>
</a>
<% else %>
<a href="<%= base_url + "#{filter_params.gsub(/&date=[a-z]+/, "")}&date=#{date}"%>">
<%= translate(locale, date) %>
</a>
<% end %>
</li>
<% end %>
</ul>
</div>
<div class="pure-u-1-3 pure-u-md-1-5 filter-catagory" id="filter-content_type">
<b><%= translate(locale, "content_type") %></b>
<hr/>
<ul class="pure-menu-list">
<% ["video", "channel", "playlist", "movie", "show"].each do |content_type| %>
<li class="pure-menu-item">
<% if operators.fetch("content_type", "all") == content_type %>
<a style="color: inherit;" href="<%= base_url + "#{filter_params.gsub(/&content_type=[a-z]+/, "")}"%>">
<b><%= translate(locale, content_type) %></b>
<i class="remove-filter icon ion-md-close"></i>
</a>
<% else %>
<a href="<%= base_url + "#{filter_params.gsub(/&content_type=[a-z]+/, "")}&content_type=#{content_type}"%>">
<%= translate(locale, content_type) %>
</a>
<% end %>
</li>
<% end %>
</ul>
</div>
<div class="pure-u-1-3 pure-u-md-1-5 filter-catagory" id="filter-duration">
<b><%= translate(locale, "duration") %></b>
<hr/>
<ul class="pure-menu-list">
<% ["short", "long"].each do |duration| %>
<li class="pure-menu-item">
<% if operators.fetch("duration", "all") == duration %>
<a style="color: inherit;" href="<%= base_url + "#{filter_params.gsub(/&duration=[a-z]+/, "")}"%>">
<b><%= translate(locale, duration) %></b>
<i class="remove-filter icon ion-md-close"></i>
</a>
<% else %>
<a href="<%= base_url + "#{filter_params.gsub(/&duration=[a-z]+/, "")}&duration=#{duration}"%>">
<%= translate(locale, duration) %>
</a>
<% end %>
</li>
<% end %>
</ul>
</div>
<div class="pure-u-1-3 pure-u-md-1-5 filter-catagory" id="filter-features">
<b><%= translate(locale, "features") %></b>
<hr/>
<ul class="pure-menu-list">
<% ["hd", "subtitles", "creative_commons", "3d", "live", "purchased", "4k", "360", "location", "hdr"].each do |feature| %>
<li class="pure-menu-item">
<% if operators.fetch("features", "all").includes?(feature) %>
<% if operators["features"].split(",").size == 1 %>
<a style="color: inherit;" href="<%= base_url + "#{filter_params.gsub(/&features=[a-z]+/, "")}"%>">
<b><%= translate(locale, feature) %></b>
<i class="remove-filter icon ion-md-close"></i>
</a>
<% else %>
<% data = filter_params.match(/.*features=.*(#{feature}(%2C|&|$)).*/).not_nil! %>
<% start = data.begin(1) %>
<% last = data.end(1) %>
<a style="color: inherit;" href="<%= base_url + "#{filter_params[0...start] + filter_params[last..-1]}"%>">
<b><%= translate(locale, feature) %></b>
<i class="remove-filter icon ion-md-close"></i>
</a>
<% end %>
<% elsif operators.has_key?("features") %>
<a href="<%= base_url + filter_params.gsub(/features=/, "features=#{feature},")%>">
<%= translate(locale, feature) %>
</a>
<% else %>
<a href="<%= "#{base_url}#{filter_params}&features=#{feature}"%>">
<%= translate(locale, feature) %>
</a>
<% end %>
</li>
<% end %>
</ul>
</div>
<div class="pure-u-1-3 pure-u-md-1-5 filter-catagory" id="filter-sort">
<b><%= translate(locale, "sort") %></b>
<hr/>
<ul class="pure-menu-list">
<% ["relevance", "rating", "date", "views"].each do |sort| %>
<li class="pure-menu-item">
<% if operators.fetch("sort", "relevance") == sort %>
<b><%= translate(locale, sort) %></b>
<% else %>
<a href="<%= base_url + "#{filter_params.gsub(/&sort=[a-z]+/, "")}&sort=#{sort}"%>">
<%= translate(locale, sort) %>
</a>
<% end %>
</li>
<% end %>
</ul>
</div>
</div>
</details>