diff --git a/assets/css/default.css b/assets/css/default.css index e403e606..793295d9 100644 --- a/assets/css/default.css +++ b/assets/css/default.css @@ -628,3 +628,6 @@ body.dark-theme { } } +#filters { + display: none; +} \ No newline at end of file diff --git a/assets/js/search.js b/assets/js/search.js new file mode 100644 index 00000000..36edd053 --- /dev/null +++ b/assets/js/search.js @@ -0,0 +1,13 @@ +function toggle_comments(event) { + var target = event.target; + var body = document.getElementById('filters'); + if (body.style.display === 'flex') { + target.innerHTML = '[ + ]'; + body.style.display = 'none'; + } else { + target.innerHTML = '[ - ]'; + body.style.display = 'flex'; + } +} + +document.getElementById('togglefilters').onclick = toggle_comments; \ No newline at end of file diff --git a/locales/en-US.json b/locales/en-US.json index acd2b667..66e71bb6 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -383,5 +383,32 @@ "Videos": "Videos", "Playlists": "Playlists", "Community": "Community", + "relevance": "Relevance", + "rating": "Rating", + "date": "Upload date", + "views": "View count", + "content_type": "Type", + "duration": "Duration", + "features": "Features", + "sort": "Sort By", + "hour": "Last Hour", + "today": "Today", + "week": "This week", + "month": "This month", + "year": "This year", + "video": "Video", + "channel": "Channel", + "playlist": "Playlist", + "movie": "Movie", + "show": "Show", + "hd": "HD", + "subtitles": "Subtitles/CC", + "creative_commons": "Creative Commons", + "3d": "3D", + "live": "Live", + "4k": "4K", + "location": "Location", + "hdr": "HDR", + "filter": "Filter", "Current version: ": "Current version: " } \ No newline at end of file diff --git a/src/invidious/routes/playlists.cr b/src/invidious/routes/playlists.cr index 6c899054..c5023c08 100644 --- a/src/invidious/routes/playlists.cr +++ b/src/invidious/routes/playlists.cr @@ -267,7 +267,7 @@ class Invidious::Routes::Playlists < Invidious::Routes::BaseRoute query = env.params.query["q"]? if query begin - search_query, count, items = process_search_query(query, page, user, region: nil) + search_query, count, items, operators = process_search_query(query, page, user, region: nil) videos = items.select { |item| item.is_a? SearchVideo }.map { |item| item.as(SearchVideo) } rescue ex videos = [] of SearchVideo diff --git a/src/invidious/routes/search.cr b/src/invidious/routes/search.cr index 48446161..a993a17a 100644 --- a/src/invidious/routes/search.cr +++ b/src/invidious/routes/search.cr @@ -48,11 +48,17 @@ class Invidious::Routes::Search < Invidious::Routes::BaseRoute user = env.get? "user" begin - search_query, count, videos = process_search_query(query, page, user, region: nil) + search_query, count, videos, operators = process_search_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 85fd024a..1c4bc74e 100644 --- a/src/invidious/search.cr +++ b/src/invidious/search.cr @@ -445,5 +445,5 @@ def process_search_query(query, page, user, region) count, items = search(search_query, page, search_params, region).as(Tuple) end - {search_query, count, items} + {search_query, count, items, operators} end diff --git a/src/invidious/views/search.ecr b/src/invidious/views/search.ecr index bc13b7ea..3fa9242b 100644 --- a/src/invidious/views/search.ecr +++ b/src/invidious/views/search.ecr @@ -2,6 +2,102 @@