mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-04-11.git
synced 2024-08-15 00:43:26 +00:00
Fix merge conflicts
This commit is contained in:
parent
c9d49dd5a6
commit
c03fa65790
3 changed files with 119 additions and 121 deletions
|
@ -54,17 +54,11 @@ module Invidious::Routes::Search
|
|||
user = env.get? "user"
|
||||
|
||||
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
|
||||
return error_template(500, ex)
|
||||
end
|
||||
|
||||
operator_hash = {} of String => String
|
||||
operators.each do |operator|
|
||||
key, value = operator.downcase.split(":")
|
||||
operator_hash[key] = value
|
||||
end
|
||||
|
||||
env.set "search", query
|
||||
templated "search"
|
||||
end
|
||||
|
|
|
@ -183,7 +183,7 @@ def process_search_query(url_params, query, page, user, region)
|
|||
sort = "relevance"
|
||||
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|
|
||||
key, value = operator
|
||||
|
||||
|
@ -238,14 +238,14 @@ def process_search_query(url_params, query, page, user, region)
|
|||
items.each do |i|
|
||||
if i.is_a? Category
|
||||
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
|
||||
end
|
||||
end
|
||||
else
|
||||
extracted_items << i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
{search_query, count, extracted_items, url_params}
|
||||
{search_query, count, items, url_params}
|
||||
end
|
||||
|
|
|
@ -18,123 +18,125 @@
|
|||
<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!)}" %>
|
||||
|
||||
<% 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-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 operator_hash.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-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 operator_hash.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-duration">
|
||||
<b><%= translate(locale, "duration") %></b>
|
||||
<hr/>
|
||||
<ul class="pure-menu-list">
|
||||
<% ["short", "long"].each do |duration| %>
|
||||
<li class="pure-menu-item">
|
||||
<% if operator_hash.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) %>
|
||||
|
||||
<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 operator_hash.fetch("features", "all").includes?(feature) %>
|
||||
<% if operator_hash["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 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>
|
||||
<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/>
|
||||
<% ["relevance", "rating", "date", "views"].each do |sort| %>
|
||||
<div class="pure-u-1 pure-md-1-5">
|
||||
<% if operator_hash.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 %>
|
||||
</div>
|
||||
<% end %>
|
||||
<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 %>
|
||||
|
@ -164,8 +166,10 @@
|
|||
</div>
|
||||
|
||||
<div class="pure-g">
|
||||
<% videos.each do |item| %>
|
||||
<%= rendered "components/item" %>
|
||||
<% items.each_slice(4) do |slice| %>
|
||||
<% slice.each do |item| %>
|
||||
<%= rendered "components/item" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue