aboutsummaryrefslogtreecommitdiffstats
path: root/fatcat_scholar/templates/search.html
blob: 2bccaaf6eca894e3beeb8a1892c90d1e4cc3b9f9 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
{% import "search_macros.html" as search_macros %}
{% extends "base.html" %}

{% macro format_query_time(query_time_ms) -%}
  {% if query_time_ms >= 10000 %}
    {{ "{:0.3}".format(hits.query_time_ms/1000.0) }}
  {% else %}
    {{ "{:0.2}".format(hits.query_time_ms/1000.0) }}
  {% endif %}
{%- endmacro %}

{% block extra_head %}
{# among other things, this prevents query parameters from ending up in goatcounter #}
<link rel="canonical" href="{{ lang_prefix }}/search">
{% endblock %}

{% block title %}
{% if query and query.q %}{{ query.q }} - {% endif %}{{ super() }}
{% endblock %}

{% block fullmain %}

<!-- these hidden query fields should be *before* any form/button that could override them -->
{{ search_macros.query_hidden(query.time_options, query.filter_time) }}
{{ search_macros.query_hidden(query.type_options, query.filter_type) }}
{{ search_macros.query_hidden(query.availability_options, query.filter_availability) }}
{{ search_macros.query_hidden(query.sort_options, query.sort_order) }}
{% if query.debug %}
  <input form="search_form" type="hidden" name="debug" value="1">
{% endif %}

<div class="tablet-only" style="margin-top: 1.0em;">

  <details class="search-filters">
    <summary><i class="filter icon"></i>{{ "Filters" }}</summary>
    <div class="tablet-filter-bar">
      {{ search_macros.query_option(query.time_options, query.filter_time) }}
      {{ search_macros.query_option(query.type_options, query.filter_type) }}
      {{ search_macros.query_option(query.availability_options, query.filter_availability) }}
      {{ search_macros.query_option(query.sort_options, query.sort_order) }}
      {{ search_macros.clear_query(query) }}
    </div>
  </details>

  {% if hits %}
    <span class="hit-count" style="font-size: 1.5em;">{{ babel_numbers.format_decimal(hits.count_found, locale=locale) }}</span>
        Hit
        Hits
    <span style="color: rgba(0,0,0,0.55);">
    </span>
  {% else %}
    &nbsp;
  {% endif %}
</div>

<div class="ui equal height divided grid" style="margin-top: 1em;">

  <nav class="ui tablet-hide two wide column">
    {% if hits %}
      <div style="width: 100%; text-align: end;">
        {% if hits.count_found >= 10000000 %}
          {% set count_size = "1.0em" %}
        {% elif hits.count_found >= 1000 %}
          {% set count_size = "1.5em" %}
        {% else %}
          {% set count_size = "2.0em" %}
        {% endif %}
        <span class="hit-count" style="display: block; font-size: {{ count_size }};">
          {{ babel_numbers.format_decimal(hits.count_found, locale=locale) }}
        </span>
      </div>
      <div style="text-align: end;">
        <span style="color: rgba(0,0,0,0.55);">
        </span>
      </div>
      <div class="ui clearing divider"></div>
    {% endif %}

    <div class = "filter-bar">
      {{ search_macros.query_option(query.time_options, query.filter_time) }}
      {{ search_macros.query_option(query.type_options, query.filter_type) }}
      {{ search_macros.query_option(query.availability_options, query.filter_availability) }}
      {{ search_macros.query_option(query.sort_options, query.sort_order) }}
      {{ search_macros.clear_query(query) }}
    </div>
    
  </nav>

  <div class="ui fourteen wide column serp-column">
    {% if search_error %}
      <div class="ui icon error message">
        <i class="ban icon"></i>
        <div class="content">
          <div class="header">
          </div>
          <p>Computer said: <code>{{ search_error.message }}</code>
        </div>
      </div>
    {% elif hits and hits.results %}
      {% if hits.results %}
        {% if hits.offset != 0 %}
          <div style="margin-bottom: 2em; width: 100%;">
            <div class="search-pagination">
              {{ search_macros.search_pagination(hits, locale=locale) }}
            </div>
          </div>
        {% endif %}

        {# search results (rendered via macro) #}
        {% set expand_result = hits.query_type == 'lookup' %}
        {% for paper in hits.results %}
          {{ search_macros.fulltext_search_result_row(paper, locale=locale, debug_mode=query.debug, expand=expand_result) }}
        {% endfor %}

        {% if hits.count_found > hits.limit %}
          <div style="margin-top: 2em; width: 100%;">
            <div class="search-pagination">
              {{ search_macros.search_pagination(hits, locale=locale) }}
            </div>
          </div>
        {% endif %}
      {% endif %}
    {% elif hits %}
      <div class="ui placeholder segment" style="height: 100%;">
        <div class="ui icon header">
          <i class="search icon"></i>
        </div>
        <div class="inline">
          {% if query.filter_type != "everything" %}
            <button class="ui primary button" form="search_form" type="submit" name="filter_type" value="everything">
            </button>
          {% endif %}
          {% if query.filter_time and query.filter_time != "all_time" %}
            <button class="ui primary button" form="search_form" type="submit" name="filter_time" value="all_time">
            </button>
          {% endif %}
          {% if query.filter_availability != "everything" %}
            <button class="ui primary button" form="search_form" type="submit" name="filter_availability" value="everything">
            </button>
          {% endif %}
          <a href="{{ lang_prefix }}/search" class="ui primary button" style="margin: 0.5em;">{{ "Start Over" }}</a>
        </div>
        <div class="inline">
          <a href="https://archive.org/search.php?sin=TXT&query={{ query.q|urlencode }}" target="_blank" rel="noopener" class="ui button" style="margin: 0.5em;">Try archive.org</a>
          <a href="https://fatcat.wiki/release/search?q={{ query.q|urlencode }}" target="_blank" rel="noopener" class="ui button" style="margin: 0.5em;">Try fatcat.wiki</a>
          <a href="https://www.semanticscholar.org/search?q={{ query.q|urlencode }}" rel="noopener" target="_blank" rel="noopener" class="ui button" style="margin: 0.5em;">Try Semantic Scholar</a>
          <a href="https://scholar.google.com/scholar?q={{ query.q|urlencode }}" target="_blank" rel="noopener" class="ui button" style="margin: 0.5em;">Try Google Scholar</a>
        </div>
      </div>
    {% else %}
      <div class="ui placeholder segment" style="height: 100%;">
        <div class="ui icon header">
          <i class="search icon"></i>
        </div>
      </div>
    {% endif %}
  </div>

</div>
{% endblock %}