Add channel heading design to channel search

This commit is contained in:
syeopite 2021-06-25 16:56:05 -07:00
parent f381f909f4
commit 47bd7812a5
No known key found for this signature in database
GPG Key ID: 6FA616E5A5294A82
4 changed files with 163 additions and 129 deletions

View File

@ -57,6 +57,15 @@ class Invidious::Routes::Search < Invidious::Routes::BaseRoute
return error_template(500, ex) return error_template(500, ex)
end end
if operators.fetch("channel", false) && count > 0
channel = get_about_info(operators.fetch("channel", "Placeholder. This will never get reached!"), locale).not_nil!
if user
user = user.as(User)
subscriptions = user.subscriptions
end
subscriptions ||= [] of String
end
env.set "search", query env.set "search", query
templated "search" templated "search"
end end

View File

@ -27,6 +27,11 @@
</div> </div>
<% end %> <% end %>
<% if content_type != 7 %>
<% query = nil %>
<% operators = {} of String => String %>
<% end %>
<div class="pure-g h-box"> <div class="pure-g h-box">
<div class="pure-u-2-3"> <div class="pure-u-2-3">
<div class="channel-profile"> <div class="channel-profile">
@ -170,8 +175,9 @@
</div> </div>
<div class="h-box"> <div class="h-box">
<hr>
<% if content_type == 1 || content_type == 2 %> <% if content_type == 1 || content_type == 2 %>
<% # We really only need a single <hr> (handled below) outside of content_type 1 or 2 %>
<hr>
<% route = content_type == 1 ? "/videos" : "/playlists" %> <% route = content_type == 1 ? "/videos" : "/playlists" %>
<% url = "/channel/#{channel.ucid + route}" %> <% url = "/channel/#{channel.ucid + route}" %>

View File

@ -0,0 +1,130 @@
<% 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>

View File

@ -1,6 +1,18 @@
<% is_channel_search = operators.fetch("channel", false) && channel.is_a? AboutChannel && !subscriptions.nil?%>
<% content_for "header" do %> <% content_for "header" do %>
<link rel="stylesheet" href="/css/search.css?v=<%= ASSET_COMMIT %>"> <link rel="stylesheet" href="/css/search.css?v=<%= ASSET_COMMIT %>">
<title><%= search_query.not_nil!.size > 30 ? HTML.escape(query.not_nil![0,30].rstrip(".") + "...") : HTML.escape(query.not_nil!) %> - Invidious</title> <title><%= search_query.not_nil!.size > 30 ? HTML.escape(query.not_nil![0,30].rstrip(".") + "...") : HTML.escape(query.not_nil!) %> - Invidious</title>
<% if is_channel_search %>
<link rel="stylesheet" href="/css/channel.css?v=<%= ASSET_COMMIT %>">
<% end %>
<% end %>
<% # To satisfy the compiler we're going to need to repeat these two arguments %>
<% if is_channel_search && channel.is_a? AboutChannel && !subscriptions.nil? %>
<% content_type = 7 %>
<% sort_options = Tuple.new %>
<%= rendered "components/channel-information" %>
<% end %> <% end %>
<% if count == 0 %> <% if count == 0 %>
@ -8,138 +20,15 @@
<a href="/redirect?referer=<%= env.get?("current_page") %>"><%= translate(locale, "Broken? Try another Invidious Instance!") %></a> <a href="/redirect?referer=<%= env.get?("current_page") %>"><%= translate(locale, "Broken? Try another Invidious Instance!") %></a>
</h3> </h3>
<% else %> <% else %>
<details id="filters"> <% if is_channel_search %>
<summary class="simulated_a"> <% else %>
<h3 style="display:inline"> <%= translate(locale, "filter") %> </h3> <%= rendered "components/search-filters" %>
</summary> <% end %>
<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>
<% end %> <% end %>
<% if count == 0 %> <% if count == 0 %>
<hr style="margin: 0;"/> <hr style="margin: 0;"/>
<% elsif is_channel_search %>
<% else %> <% else %>
<hr/> <hr/>
<% end %> <% end %>