Fix merge conflicts

This commit is contained in:
syeopite 2021-06-24 08:58:25 -07:00
parent 04e04efd19
commit 842c23a119
No known key found for this signature in database
GPG Key ID: 6FA616E5A5294A82
3 changed files with 116 additions and 120 deletions

View File

@ -52,17 +52,11 @@ class Invidious::Routes::Search < Invidious::Routes::BaseRoute
user = env.get? "user" user = env.get? "user"
begin begin
search_query, count, videos, operators = process_search_query(query, page, user, region: region) search_query, count, items, operators = process_search_query(env.params.query, query, page, user, region: nil)
rescue ex rescue ex
return error_template(500, ex) return error_template(500, ex)
end end
operator_hash = {} of String => String
operators.each do |operator|
key, value = operator.downcase.split(":")
operator_hash[key] = value
end
env.set "search", query env.set "search", query
templated "search" templated "search"
end end

View File

@ -182,7 +182,7 @@ def process_search_query(url_params, query, page, user, region)
sort = "relevance" sort = "relevance"
subscriptions = nil subscriptions = nil
# operators = url_params.split(" ").select { |a| a.match(/\w+:[\,]+/) } # operators = query.split(" ").select { |a| a.match(/\w+:[\w,]+/) }
url_params.each do |operator| url_params.each do |operator|
key, value = operator key, value = operator
@ -237,14 +237,14 @@ def process_search_query(url_params, query, page, user, region)
items.each do |i| items.each do |i|
if i.is_a? Category if i.is_a? Category
i.contents.each do |cate_items| i.contents.each do |cate_items|
if cate_items.is_a? (SearchVideo | SearchPlaylist | SearchChannel) if cate_items.is_a?(SearchVideo | SearchPlaylist | SearchChannel)
extracted_items << cate_items extracted_items << cate_items
end end
end end
else else
extracted_items << i extracted_items << i
end end
end end
{search_query, count, extracted_items, url_params} {search_query, count, items, url_params}
end end

View File

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