mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-22 14:05:09 -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,92 +16,117 @@
|
|||||||
<!-- 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">
|
||||||
<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| %>
|
||||||
<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>
|
||||||
<% else %>
|
<i class="remove-filter icon ion-md-close"></i>
|
||||||
<a href="<%= base_url + "#{filter_params.gsub(/&date=[a-z]+/, "")}&date=#{date}"%>">
|
</a>
|
||||||
<%= translate(locale, date) %>
|
<% else %>
|
||||||
</a>
|
<a href="<%= base_url + "#{filter_params.gsub(/&date=[a-z]+/, "")}&date=#{date}"%>">
|
||||||
<% end %>
|
<%= translate(locale, date) %>
|
||||||
</div>
|
</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="pure-u-1-3 pure-u-md-1-5" id="filter-content_type">
|
<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| %>
|
||||||
<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>
|
||||||
<% else %>
|
<i class="remove-filter icon ion-md-close"></i>
|
||||||
<a href="<%= base_url + "#{filter_params.gsub(/&content_type=[a-z]+/, "")}&content_type=#{content_type}"%>">
|
</a>
|
||||||
<%= translate(locale, content_type) %>
|
<% else %>
|
||||||
</a>
|
<a href="<%= base_url + "#{filter_params.gsub(/&content_type=[a-z]+/, "")}&content_type=#{content_type}"%>">
|
||||||
<% end %>
|
<%= translate(locale, content_type) %>
|
||||||
</div>
|
</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="pure-u-1-3 pure-u-md-1-5" id="filter-duration">
|
<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| %>
|
||||||
<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>
|
||||||
<% else %>
|
<i class="remove-filter icon ion-md-close"></i>
|
||||||
<a href="<%= base_url + "#{filter_params.gsub(/&duration=[a-z]+/, "")}&duration=#{duration}"%>">
|
</a>
|
||||||
<%= translate(locale, duration) %>
|
<% else %>
|
||||||
</a>
|
<a href="<%= base_url + "#{filter_params.gsub(/&duration=[a-z]+/, "")}&duration=#{duration}"%>">
|
||||||
<% end %>
|
<%= translate(locale, duration) %>
|
||||||
</div>
|
</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="pure-u-1-3 pure-u-md-1-5" id="filter-features">
|
<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| %>
|
||||||
<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) %>
|
||||||
<b><%= translate(locale, feature) %></b>
|
<% if operator_hash["features"].split(",").size == 1 %>
|
||||||
<% elsif operator_hash.has_key?("features") %>
|
<a style="color: inherit;" href="<%= base_url + "#{filter_params.gsub(/&features=[a-z]+/, "")}"%>">
|
||||||
<a href="<%= base_url + filter_params.gsub(/features=/, "features=#{feature},")%>">
|
<b><%= translate(locale, feature) %></b>
|
||||||
<%= translate(locale, feature) %>
|
<i class="remove-filter icon ion-md-close"></i>
|
||||||
</a>
|
</a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a href="<%= "#{base_url}#{filter_params}&features=#{feature}"%>">
|
<% data = filter_params.match(/.*features=.*(#{feature}(%2C|&|$)).*/).not_nil! %>
|
||||||
<%= translate(locale, feature) %>
|
<% 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>
|
</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
<% elsif operator_hash.has_key?("features") %>
|
||||||
<% end %>
|
<a href="<%= base_url + filter_params.gsub(/features=/, "features=#{feature},")%>">
|
||||||
</div>
|
<%= translate(locale, feature) %>
|
||||||
|
</a>
|
||||||
|
<% else %>
|
||||||
|
<a href="<%= "#{base_url}#{filter_params}&features=#{feature}"%>">
|
||||||
|
<%= translate(locale, feature) %>
|
||||||
|
</a>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="pure-u-1-3 pure-u-md-1-5" id="filter-sort">
|
<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| %>
|
||||||
<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>
|
||||||
<% else %>
|
<i class="remove-filter icon ion-md-close"></i>
|
||||||
<a href="<%= base_url + "#{filter_params.gsub(/&sort=[a-z]+/, "")}&sort=#{sort}"%>">
|
</a>
|
||||||
<%= translate(locale, sort) %>
|
<% else %>
|
||||||
</a>
|
<a href="<%= base_url + "#{filter_params.gsub(/&sort=[a-z]+/, "")}&sort=#{sort}"%>">
|
||||||
<% end %>
|
<%= translate(locale, sort) %>
|
||||||
</div>
|
</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
Loading…
Reference in New Issue
Block a user