diff --git a/src/invidious/views/components/search-filters/filter-column.ecr b/src/invidious/views/components/search-filters/filter-column.ecr new file mode 100644 index 00000000..71a5015b --- /dev/null +++ b/src/invidious/views/components/search-filters/filter-column.ecr @@ -0,0 +1,36 @@ +<% + # Almost all of the filter columns are basically the same so we'll define it here as a component. + # Uses five values + # - filter_params: The URL params containing only the search filters. + # - base_url: The path to the /search endpoint of Invidious with the current search query passed inn + # - operators: containing all of the search filters currently applied + # - filters: the array of filters within the column we're creating + # - filter_name: name of the filter + # - selected_default: default selected filter +-%> + +
+ <%= translate(locale, filter_name) %> +
+ + + +
\ No newline at end of file diff --git a/src/invidious/views/components/search-filters/search-filters.ecr b/src/invidious/views/components/search-filters/search-filters.ecr new file mode 100644 index 00000000..b88a80d7 --- /dev/null +++ b/src/invidious/views/components/search-filters/search-filters.ecr @@ -0,0 +1,76 @@ +<% operators = operators.not_nil! %> + +
+ +

<%= translate(locale, "filter") %>

+
+ +
+ <% # 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=#{URI.encode_www_form(query.not_nil!)}" -%> + + <% filters = ["hour", "today", "week", "month", "year"] %> + <% filter_name = "date" %> + <% selected_default = "NotNeeded" %> + <%= rendered "components/search-filters/filter-column" -%> + + <% filters = ["video", "channel", "playlist", "movie", "show"] %> + <% filter_name = "content_type" %> + <% selected_default = "NotNeeded" %> + <%= rendered "components/search-filters/filter-column" -%> + + <% filters = ["short", "long"] %> + <% filter_name = "duration" %> + <%= rendered "components/search-filters/filter-column" -%> + + <% + # Since the feature filter column is unqiue (multiple filters can be applied), + # we'll have to define it manually. + %> +
+ <%= translate(locale, "features") %> +
+ + +
+ + <% filters = ["relevance", "rating", "date", "views"] %> + <% filter_name = "sort" %> + <% selected_default = "relevance" %> + <%= rendered "components/search-filters/filter-column" -%> + +
+
\ No newline at end of file diff --git a/src/invidious/views/search.ecr b/src/invidious/views/search.ecr index cd6705cb..3d2bb691 100644 --- a/src/invidious/views/search.ecr +++ b/src/invidious/views/search.ecr @@ -11,135 +11,7 @@ "><%= translate(locale, "Broken? Try another Invidious Instance!") %> <% else %> -
- -

<%= translate(locale, "filter") %>

-
-
- - - <% filter_params = env.request.query_params.to_s.gsub(/q=.+?(?=&)/, "") %> - <% base_url = "/search?q=#{URI.encode_www_form(query.not_nil!)}" %> - -
- <%= translate(locale, "date") %> -
- -
- -
- <%= translate(locale, "content_type") %> -
- -
- -
- <%= 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 %> -
-
+ <%= rendered "components/search-filters/search-filters" %> <% end %> <% if count == 0 %>