diff options
| author | Samantaz Fox <coding@samantaz.fr> | 2022-04-06 22:23:22 +0200 |
|---|---|---|
| committer | Samantaz Fox <coding@samantaz.fr> | 2022-04-08 22:28:43 +0200 |
| commit | 62d7abdd9e699779a7e74ed5569aa6d631004210 (patch) | |
| tree | e8a964549603e9584847e0b065042a5984c1a211 | |
| parent | dbc74164ab572cbc3d537c9548e44bdb14bff266 (diff) | |
| download | invidious-62d7abdd9e699779a7e74ed5569aa6d631004210.tar.gz invidious-62d7abdd9e699779a7e74ed5569aa6d631004210.tar.bz2 invidious-62d7abdd9e699779a7e74ed5569aa6d631004210.zip | |
Add a user friendly message for when no results are found
| -rw-r--r-- | assets/css/search.css | 9 | ||||
| -rw-r--r-- | locales/en-US.json | 4 | ||||
| -rw-r--r-- | src/invidious/frontend/misc.cr | 14 | ||||
| -rw-r--r-- | src/invidious/views/search.ecr | 27 |
4 files changed, 42 insertions, 12 deletions
diff --git a/assets/css/search.css b/assets/css/search.css index 226207a5..a5996362 100644 --- a/assets/css/search.css +++ b/assets/css/search.css @@ -69,6 +69,15 @@ fieldset, legend { #filters-apply { text-align: end; } +/* Error message */ + +.no-results-error { + text-align: center; + line-height: 180%; + font-size: 110%; + padding: 15px 15px 125px 15px; +} + /* Responsive rules */ @media only screen and (max-width: 800px) { diff --git a/locales/en-US.json b/locales/en-US.json index 03df88b6..58098929 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -175,7 +175,9 @@ "Show less": "Show less", "Watch on YouTube": "Watch on YouTube", "Switch Invidious Instance": "Switch Invidious Instance", - "Broken? Try another Invidious Instance": "Broken? Try another Invidious Instance", + "search_message_no_results": "No results found.", + "search_message_change_filters_or_query": "Try widening your search query and/or changing the filters.", + "search_message_use_another_instance": " You can also <a href=\"`x`\">search on another instance</a>.", "Hide annotations": "Hide annotations", "Show annotations": "Show annotations", "Genre: ": "Genre: ", diff --git a/src/invidious/frontend/misc.cr b/src/invidious/frontend/misc.cr new file mode 100644 index 00000000..43ba9f5c --- /dev/null +++ b/src/invidious/frontend/misc.cr @@ -0,0 +1,14 @@ +module Invidious::Frontend::Misc + extend self + + def redirect_url(env : HTTP::Server::Context) + prefs = env.get("preferences").as(Preferences) + + if prefs.automatic_instance_redirect + current_page = env.get?("current_page").as(String) + redirect_url = "/redirect?referer=#{current_page}" + else + redirect_url = "https://redirect.invidious.io#{env.request.resource}" + end + end +end diff --git a/src/invidious/views/search.ecr b/src/invidious/views/search.ecr index f1f6ab20..7110703e 100644 --- a/src/invidious/views/search.ecr +++ b/src/invidious/views/search.ecr @@ -9,18 +9,13 @@ url_prev_page = "/search?q=#{search_query_encoded}&#{filter_params}&page=#{query.page - 1}" url_next_page = "/search?q=#{search_query_encoded}&#{filter_params}&page=#{query.page + 1}" + + redirect_url = Invidious::Frontend::Misc.redirect_url(env) -%> <!-- Search redirection and filtering UI --> -<% if videos.size == 0 %> - <h3 style="text-align: center"> - <a href="/redirect?referer=<%= env.get?("current_page") %>"><%= translate(locale, "Broken? Try another Invidious Instance!") %></a> - </h3> -<%- else -%> - <%= Invidious::Frontend::SearchFilters.generate(query.filters, query.text, query.page, locale) %> -<%- end -%> - -<% if videos.size == 0 %><hr style="margin: 0;"/><% else %><hr/><% end %> +<%= Invidious::Frontend::SearchFilters.generate(query.filters, query.text, query.page, locale) %> +<hr/> <div class="pure-g h-box v-box"> <div class="pure-u-1 pure-u-lg-1-5"> @@ -36,11 +31,21 @@ </div> </div> +<%- if videos.empty? -%> +<div class="h-box no-results-error"> + <div> + <%= translate(locale, "search_message_no_results") %><br/><br/> + <%= translate(locale, "search_message_change_filters_or_query") %><br/><br/> + <%= translate(locale, "search_message_use_another_instance", redirect_url) %> + </div> +</div> +<%- else -%> <div class="pure-g"> - <% videos.each do |item| %> + <%- videos.each do |item| -%> <%= rendered "components/item" %> - <% end %> + <%- end -%> </div> +<%- end -%> <div class="pure-g h-box"> <div class="pure-u-1 pure-u-lg-1-5"> |
