mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-22 22:09:23 -05:00
Add ability to remove search filters from UI
This commit is contained in:
parent
46df266c36
commit
d7901a99f8
@ -21,3 +21,29 @@
|
|||||||
content: "[ - ]";
|
content: "[ - ]";
|
||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.remove-filter {
|
||||||
|
margin-left: 6px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No theme */
|
||||||
|
|
||||||
|
.no-theme .remove-filter {
|
||||||
|
color: #ffffff
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Light theme */
|
||||||
|
@media (prefers-color-scheme: light) {
|
||||||
|
.light-theme .remove-filter {
|
||||||
|
color: #ffffff
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Dark theme */
|
||||||
|
|
||||||
|
.no-theme .remove-filter {
|
||||||
|
color: #030303
|
||||||
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<!-- 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=.+?(?=&)/, "") %>
|
<% filter_params = env.request.query_params.to_s.gsub(/q=.+?(?=&|$)/, "") %>
|
||||||
<% base_url = "/search?q=#{HTML.escape(query.not_nil!)}" %>
|
<% base_url = "/search?q=#{HTML.escape(query.not_nil!)}" %>
|
||||||
|
|
||||||
<div class="pure-u-1-3 pure-u-md-1-5" id="filter-date">
|
<div class="pure-u-1-3 pure-u-md-1-5" id="filter-date">
|
||||||
@ -25,7 +25,10 @@
|
|||||||
<% ["hour", "today", "week", "month", "year"].each do |date| %>
|
<% ["hour", "today", "week", "month", "year"].each do |date| %>
|
||||||
<div class="pure-u-1 pure-md-1-5">
|
<div class="pure-u-1 pure-md-1-5">
|
||||||
<% if operator_hash.fetch("date", "all") == date %>
|
<% 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>
|
<b><%= translate(locale, date) %></b>
|
||||||
|
<i class="remove-filter icon ion-md-close"></i>
|
||||||
|
</a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a href="<%= base_url + "#{filter_params.gsub(/&date=[a-z]+/, "")}&date=#{date}"%>">
|
<a href="<%= base_url + "#{filter_params.gsub(/&date=[a-z]+/, "")}&date=#{date}"%>">
|
||||||
<%= translate(locale, date) %>
|
<%= translate(locale, date) %>
|
||||||
@ -41,7 +44,10 @@
|
|||||||
<% ["video", "channel", "playlist", "movie", "show"].each do |content_type| %>
|
<% ["video", "channel", "playlist", "movie", "show"].each do |content_type| %>
|
||||||
<div class="pure-u-1 pure-md-1-5">
|
<div class="pure-u-1 pure-md-1-5">
|
||||||
<% if operator_hash.fetch("content_type", "all") == content_type %>
|
<% 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>
|
<b><%= translate(locale, content_type) %></b>
|
||||||
|
<i class="remove-filter icon ion-md-close"></i>
|
||||||
|
</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(/&content_type=[a-z]+/, "")}&content_type=#{content_type}"%>">
|
||||||
<%= translate(locale, content_type) %>
|
<%= translate(locale, content_type) %>
|
||||||
@ -57,7 +63,10 @@
|
|||||||
<% ["short", "long"].each do |duration| %>
|
<% ["short", "long"].each do |duration| %>
|
||||||
<div class="pure-u-1 pure-md-1-5">
|
<div class="pure-u-1 pure-md-1-5">
|
||||||
<% if operator_hash.fetch("duration", "all") == duration %>
|
<% 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>
|
<b><%= translate(locale, duration) %></b>
|
||||||
|
<i class="remove-filter icon ion-md-close"></i>
|
||||||
|
</a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a href="<%= base_url + "#{filter_params.gsub(/&duration=[a-z]+/, "")}&duration=#{duration}"%>">
|
<a href="<%= base_url + "#{filter_params.gsub(/&duration=[a-z]+/, "")}&duration=#{duration}"%>">
|
||||||
<%= translate(locale, duration) %>
|
<%= translate(locale, duration) %>
|
||||||
@ -73,7 +82,21 @@
|
|||||||
<% ["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| %>
|
||||||
<div class="pure-u-1 pure-md-1-5">
|
<div class="pure-u-1 pure-md-1-5">
|
||||||
<% if operator_hash.fetch("features", "all").includes?(feature) %>
|
<% 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>
|
<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") %>
|
<% elsif operator_hash.has_key?("features") %>
|
||||||
<a href="<%= base_url + filter_params.gsub(/features=/, "features=#{feature},")%>">
|
<a href="<%= base_url + filter_params.gsub(/features=/, "features=#{feature},")%>">
|
||||||
<%= translate(locale, feature) %>
|
<%= translate(locale, feature) %>
|
||||||
@ -93,7 +116,10 @@
|
|||||||
<% ["relevance", "rating", "date", "views"].each do |sort| %>
|
<% ["relevance", "rating", "date", "views"].each do |sort| %>
|
||||||
<div class="pure-u-1 pure-md-1-5">
|
<div class="pure-u-1 pure-md-1-5">
|
||||||
<% if operator_hash.fetch("sort", "relevance") == sort %>
|
<% if operator_hash.fetch("sort", "relevance") == sort %>
|
||||||
|
<a style="color: inherit;" href="<%= base_url + "#{filter_params.gsub(/&sort=[a-z]+/, "")}"%>">
|
||||||
<b><%= translate(locale, sort) %></b>
|
<b><%= translate(locale, sort) %></b>
|
||||||
|
<i class="remove-filter icon ion-md-close"></i>
|
||||||
|
</a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a href="<%= base_url + "#{filter_params.gsub(/&sort=[a-z]+/, "")}&sort=#{sort}"%>">
|
<a href="<%= base_url + "#{filter_params.gsub(/&sort=[a-z]+/, "")}&sort=#{sort}"%>">
|
||||||
<%= translate(locale, sort) %>
|
<%= translate(locale, sort) %>
|
||||||
@ -102,7 +128,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</details>
|
</details>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user