mirror of
https://gitea.invidious.io/iv-org/invidious.git
synced 2024-08-15 00:53:41 +00:00
Fix search filters being overwritten by others
This commit is contained in:
parent
c68ba62eae
commit
46df266c36
1 changed files with 21 additions and 11 deletions
|
@ -13,7 +13,13 @@
|
||||||
<h3 style="display:inline"> <%= translate(locale, "filter") %> </h3>
|
<h3 style="display:inline"> <%= translate(locale, "filter") %> </h3>
|
||||||
</summary>
|
</summary>
|
||||||
<div id="filters" class="pure-g h-box">
|
<div id="filters" class="pure-g h-box">
|
||||||
<div class="pure-u-1-3 pure-u-md-1-5">
|
<!-- 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" id="filter-date">
|
||||||
<b><%= translate(locale, "date") %></b>
|
<b><%= translate(locale, "date") %></b>
|
||||||
<hr/>
|
<hr/>
|
||||||
<% ["hour", "today", "week", "month", "year"].each do |date| %>
|
<% ["hour", "today", "week", "month", "year"].each do |date| %>
|
||||||
|
@ -21,14 +27,15 @@
|
||||||
<% if operator_hash.fetch("date", "all") == date %>
|
<% if operator_hash.fetch("date", "all") == date %>
|
||||||
<b><%= translate(locale, date) %></b>
|
<b><%= translate(locale, date) %></b>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a href="/search?q=<%= HTML.escape(query.not_nil!) %>&page=<%= page %>&date=<%= date %>">
|
<a href="<%= base_url + "#{filter_params.gsub(/&date=[a-z]+/, "")}&date=#{date}"%>">
|
||||||
<%= translate(locale, date) %>
|
<%= translate(locale, date) %>
|
||||||
</a>
|
</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-u-1-3 pure-u-md-1-5">
|
|
||||||
|
<div class="pure-u-1-3 pure-u-md-1-5" id="filter-content_type">
|
||||||
<b><%= translate(locale, "content_type") %></b>
|
<b><%= translate(locale, "content_type") %></b>
|
||||||
<hr/>
|
<hr/>
|
||||||
<% ["video", "channel", "playlist", "movie", "show"].each do |content_type| %>
|
<% ["video", "channel", "playlist", "movie", "show"].each do |content_type| %>
|
||||||
|
@ -36,14 +43,15 @@
|
||||||
<% if operator_hash.fetch("content_type", "all") == content_type %>
|
<% if operator_hash.fetch("content_type", "all") == content_type %>
|
||||||
<b><%= translate(locale, content_type) %></b>
|
<b><%= translate(locale, content_type) %></b>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a href="/search?q=<%= HTML.escape(query.not_nil!) %>&page=<%= page %>&content_type=<%= content_type %>">
|
<a href="<%= base_url + "#{filter_params.gsub(/&content_type=[a-z]+/, "")}&content_type=#{content_type}"%>">
|
||||||
<%= translate(locale, content_type) %>
|
<%= translate(locale, content_type) %>
|
||||||
</a>
|
</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-u-1-3 pure-u-md-1-5">
|
|
||||||
|
<div class="pure-u-1-3 pure-u-md-1-5" id="filter-duration">
|
||||||
<b><%= translate(locale, "duration") %></b>
|
<b><%= translate(locale, "duration") %></b>
|
||||||
<hr/>
|
<hr/>
|
||||||
<% ["short", "long"].each do |duration| %>
|
<% ["short", "long"].each do |duration| %>
|
||||||
|
@ -51,14 +59,15 @@
|
||||||
<% if operator_hash.fetch("duration", "all") == duration %>
|
<% if operator_hash.fetch("duration", "all") == duration %>
|
||||||
<b><%= translate(locale, duration) %></b>
|
<b><%= translate(locale, duration) %></b>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a href="/search?q=<%= HTML.escape(query.not_nil!) %>&page=<%= page %>&duration=<%= duration %>">
|
<a href="<%= base_url + "#{filter_params.gsub(/&duration=[a-z]+/, "")}&duration=#{duration}"%>">
|
||||||
<%= translate(locale, duration) %>
|
<%= translate(locale, duration) %>
|
||||||
</a>
|
</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-u-1-3 pure-u-md-1-5">
|
|
||||||
|
<div class="pure-u-1-3 pure-u-md-1-5" id="filter-features">
|
||||||
<b><%= translate(locale, "features") %></b>
|
<b><%= translate(locale, "features") %></b>
|
||||||
<hr/>
|
<hr/>
|
||||||
<% ["hd", "subtitles", "creative_commons", "3d", "live", "purchased", "4k", "360", "location", "hdr"].each do |feature| %>
|
<% ["hd", "subtitles", "creative_commons", "3d", "live", "purchased", "4k", "360", "location", "hdr"].each do |feature| %>
|
||||||
|
@ -66,18 +75,19 @@
|
||||||
<% if operator_hash.fetch("features", "all").includes?(feature) %>
|
<% if operator_hash.fetch("features", "all").includes?(feature) %>
|
||||||
<b><%= translate(locale, feature) %></b>
|
<b><%= translate(locale, feature) %></b>
|
||||||
<% elsif operator_hash.has_key?("features") %>
|
<% elsif operator_hash.has_key?("features") %>
|
||||||
<a href="/search?q=<%= HTML.escape(query.not_nil!) %>&page=<%= page %>&features=<%= HTML.escape(operator_hash["features"] + ",#{feature}") %>">
|
<a href="<%= base_url + filter_params.gsub(/features=/, "features=#{feature},")%>">
|
||||||
<%= translate(locale, feature) %>
|
<%= translate(locale, feature) %>
|
||||||
</a>
|
</a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a href="/search?q=<%= HTML.escape(query.not_nil!) %>&page=<%= page %>&features=<%= feature %>">
|
<a href="<%= "#{base_url}#{filter_params}&features=#{feature}"%>">
|
||||||
<%= translate(locale, feature) %>
|
<%= translate(locale, feature) %>
|
||||||
</a>
|
</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-u-1-3 pure-u-md-1-5">
|
|
||||||
|
<div class="pure-u-1-3 pure-u-md-1-5" id="filter-sort">
|
||||||
<b><%= translate(locale, "sort") %></b>
|
<b><%= translate(locale, "sort") %></b>
|
||||||
<hr/>
|
<hr/>
|
||||||
<% ["relevance", "rating", "date", "views"].each do |sort| %>
|
<% ["relevance", "rating", "date", "views"].each do |sort| %>
|
||||||
|
@ -85,7 +95,7 @@
|
||||||
<% if operator_hash.fetch("sort", "relevance") == sort %>
|
<% if operator_hash.fetch("sort", "relevance") == sort %>
|
||||||
<b><%= translate(locale, sort) %></b>
|
<b><%= translate(locale, sort) %></b>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a href="/search?q=<%= HTML.escape(query.not_nil!) %>&page=<%= page %>&sort=<%= sort %>">
|
<a href="<%= base_url + "#{filter_params.gsub(/&sort=[a-z]+/, "")}&sort=#{sort}"%>">
|
||||||
<%= translate(locale, sort) %>
|
<%= translate(locale, sort) %>
|
||||||
</a>
|
</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
Loading…
Reference in a new issue