From 842c23a1192fb4fc03155c8cbe44f452b13bf062 Mon Sep 17 00:00:00 2001 From: syeopite Date: Thu, 24 Jun 2021 08:58:25 -0700 Subject: [PATCH] Fix merge conflicts --- src/invidious/routes/search.cr | 8 +- src/invidious/search.cr | 8 +- src/invidious/views/search.ecr | 220 +++++++++++++++++---------------- 3 files changed, 116 insertions(+), 120 deletions(-) diff --git a/src/invidious/routes/search.cr b/src/invidious/routes/search.cr index 513904b8..d98c8926 100644 --- a/src/invidious/routes/search.cr +++ b/src/invidious/routes/search.cr @@ -52,17 +52,11 @@ class Invidious::Routes::Search < Invidious::Routes::BaseRoute 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 diff --git a/src/invidious/search.cr b/src/invidious/search.cr index b2b0eee0..b26a4158 100644 --- a/src/invidious/search.cr +++ b/src/invidious/search.cr @@ -182,7 +182,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 @@ -237,14 +237,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 diff --git a/src/invidious/views/search.ecr b/src/invidious/views/search.ecr index 6afbee95..896ceda6 100644 --- a/src/invidious/views/search.ecr +++ b/src/invidious/views/search.ecr @@ -15,123 +15,125 @@
+ <% 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!)}" %> +
+ <%= translate(locale, "date") %> +
+ +
-
- <%= translate(locale, "date") %> -
- -
+
+ <%= translate(locale, "content_type") %> +
+ +
-
- <%= translate(locale, "content_type") %> -
- -
+
+ <%= translate(locale, "duration") %> +
+ +
-
- <%= translate(locale, "duration") %> -
- -
+
+ <%= translate(locale, "features") %> +
+ +
<%= translate(locale, "sort") %>
- <% ["relevance", "rating", "date", "views"].each do |sort| %> -
- <% if operator_hash.fetch("sort", "relevance") == sort %> - <%= translate(locale, sort) %> - <% else %> - "> - <%= translate(locale, sort) %> - - <% end %> -
- <% end %> +
    + <% ["relevance", "rating", "date", "views"].each do |sort| %> +
  • + <% if operators.fetch("sort", "relevance") == sort %> + <%= translate(locale, sort) %> + <% else %> + "> + <%= translate(locale, sort) %> + + <% end %> +
  • + <% end %> +
+
<% end %> @@ -161,7 +163,7 @@
- <% videos.each_slice(4) do |slice| %> + <% items.each_slice(4) do |slice| %> <% slice.each do |item| %> <%= rendered "components/item" %> <% end %>