summaryrefslogtreecommitdiff
path: root/src/invidious/views/search.ecr
blob: 7110703e26b2a42419d438f9a4f2b3bd9082a32a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<% content_for "header" do %>
<title><%= query.text.size > 30 ? HTML.escape(query.text[0,30].rstrip(".")) + "&hellip;" : HTML.escape(query.text) %> - Invidious</title>
<link rel="stylesheet" href="/css/search.css?v=<%= ASSET_COMMIT %>">
<% end %>

<%-
  search_query_encoded = URI.encode_www_form(query.text, space_to_plus: true)
  filter_params = query.filters.to_iv_params

  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 -->
<%= 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">
        <%- if query.page > 1 -%>
            <a href="<%= url_prev_page %>"><%= translate(locale, "Previous page") %></a>
        <%- end -%>
    </div>
    <div class="pure-u-1 pure-u-lg-3-5"></div>
    <div class="pure-u-1 pure-u-lg-1-5" style="text-align:right">
        <%- if videos.size >= 20 -%>
            <a href="<%= url_next_page %>"><%= translate(locale, "Next page") %></a>
        <%- end -%>
    </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| -%>
        <%= rendered "components/item" %>
    <%- end -%>
</div>
<%- end -%>

<div class="pure-g h-box">
    <div class="pure-u-1 pure-u-lg-1-5">
        <%- if query.page > 1 -%>
            <a href="<%= url_prev_page %>"><%= translate(locale, "Previous page") %></a>
        <%- end -%>
    </div>
    <div class="pure-u-1 pure-u-lg-3-5"></div>
    <div class="pure-u-1 pure-u-lg-1-5" style="text-align:right">
        <%- if videos.size >= 20 -%>
            <a href="<%= url_next_page %>"><%= translate(locale, "Next page") %></a>
        <%- end -%>
    </div>
</div>