aboutsummaryrefslogtreecommitdiffstats
path: root/fatcat_scholar/templates/search_macros.html
blob: 7ebbd3229e6f4d9b65505c89487d12ad06cecae9 (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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243

{% macro tag_label(tag) -%}
  {% if tag == "oa" %}
    <span class="ui label basic orange small" title="Open Access">OA</span>
  {% elif tag == "scielo" %}
    <span class="ui label basic purple small" title="Hosted on SciELO platform">SciELO</span>
  {% elif tag == "ojs" %}
    <span class="ui label basic purple small" title="Hosted with Open Journal Systems">OJS</span>
  {% elif tag == "wordpress" %}
    <span class="ui label basic purple small" title="Hosted with Wordpress">Wordpress</span>
  {% elif tag == "road" %}
    {# skip for now; no curration? #}
    {# <span class="ui label basic orange small" title="ISSN Registry of Open Access Journals">ROAD</span> #}
  {% elif tag == "szczepanski" %}
    {# pass #}
  {% elif tag == "doaj" %}
    <span class="ui label basic orange small" title="Directory of Open Access Journals">DOAJ</span>
  {% else %}
    <span class="ui label small">{{ _(tag) }}</span>
  {% endif %}
{% endmacro %}

{% macro fulltext_search_result_row(paper) -%}
<div class="ui grid">
<div class="thirteen wide column">
  {# ### TITLE ROW #}
  <div style="margin-bottom: 0.1em; font-size: 1.2em; font-weight: bold;">

    {% if paper.doc_type == "work" %}
      <a href="https://fatcat.wiki/release/{{ paper.biblio.release_ident }}" style="color: #2224c7;" target="_blank">
        {% if paper.biblio.title %}
          {{ paper.biblio.title[:512] }}
          {% if paper.biblio.title|length > 512 %}...{% endif %}
        {% else %}
          [blank]
        {% endif %}
      </a>
      {# release type suffix #}
      <span style="font-weight: normal; text-transform: uppercase; font-weight: bold;">
      {% if paper.biblio.release_type in ("article-journal", "paper-conference") or paper.doc_type == "sim_page" %}
        {# pass #}
      {% elif paper.biblio.release_type in ("book", "chapter", "dataset") %}
        [{{ _(paper.biblio.release_type) }}]
      {% elif not paper.biblio.release_type %}
        [{{ _("unknown") }}]
      {% else %}
        [{{ _(paper.biblio.release_type) }}]
      {% endif %}
      </span>

      {# show inverse of title/original_title above #}
      {% if paper.biblio.original_title and paper.biblio.title != paper.biblio.original_title %}
        <br>
        <i style="font-weight: bold;">
          {{ paper.biblio.original_title[:512] }} {% if paper.biblio.original_title|length > 512 %}...{% endif %}
        </i>
      {% endif %}

    {% elif paper.doc_type == "sim_page" %}
      <a target="_blank" href="https://archive.org/details/{{ paper.ia_sim.issue_item }}/page/{{ paper.ia_sim.first_page }}" style="color: #2224c7;">Page {{ paper.ia_sim.first_page }}</a> of <a target="_blank" href="https://archive.org/details/{{ paper.ia_sim.issue_item }}" style="color: #2224c7;">{{ paper.biblio.container_name }}</a> (<a target="_blank" href="https://archive.org/details/{{ paper.ia_sim.issue_item }}" style="color: #2224c7;">Vol. {{ paper.biblio.volume }}, Issue {{ paper.biblio.issue }}</a>)
    {% endif %}

  </div>

  {# ### AUTHOR ROW #}
  {% if paper.biblio.contrib_names %}
    <div style="margin-top: 0.1em; margin-bottom: 0.2em; font-size: 1.1em;">
    {{ ", ".join(paper.biblio.contrib_names[:12]) }}
    {% if paper.biblio.contrib_names|length > 12 %}<i>(+{{ paper.biblio.contrib_names|length - 12 }} others)</i>{% endif %}
    </div>
  {% endif %}


  {# ### JOURNAL ROW #}
  {% if paper.biblio.release_year %}
    {{ paper.biblio.release_year }}
  {% endif %}
  {% if paper.biblio.container_name %}
    <i>
    {% if paper.biblio.container_ident %}
      <a target="_blank" href="https://fatcat.wiki/container/{{ paper.biblio.container_ident }}" style="color: black;">{{ paper.biblio.container_name }}</a>
    {% elif paper.doc_type == "sim_page" %}
      <a target="_blank" href="https://archive.org/details/{{ paper.ia_sim.pub_collection }}" style="color: black;">{{ paper.biblio.container_name }}</a>
    {% else %}
      {{ paper.biblio.container_name }}
    {% endif %}
    </i>
    &nbsp;
  {% endif %}

  {% if paper.biblio.release_stage == "submitted" %}
    <b style="color: brown; text-transform: uppercase;">pre-print</b>
  {% elif paper.biblio.release_stage and paper.biblio.release_stage != "published" %}
    <b style="color: brown; text-transform: uppercase;">{{ paper.biblio.release_stage }} version</b>
  {% elif not paper.biblio.release_stage %}
    <b style="color: brown; text-transform: uppercase;">unpublished</b>
  {% endif %}

  {% if paper.biblio.withdrawn_status %}
    <b style="color: red; text-transform: uppercase;">{{ paper.biblio.withdrawn_status }}</b>
  {% endif %}

  {# ### ABSTRACT / QUERY HIGHLIGHT #}
  {% if paper._highlights %}
    <div style="padding-top: 0.5em; padding-bottom: 0.5em;" class="search_highlights">
    {# this highlight HTML escape hacking should not be necessary in ES 7.x with highlight escaping #}
    {# but for now we manually escape, then de-escape the 'em' highlight tags #}
    {% autoescape false %}
      {% for highlight in paper._highlights %}
        {{ highlight|e|replace("&lt;em&gt;", "<em>")|replace("&lt;/em&gt;", "</em>") }} &nbsp;...&nbsp;
      {% endfor %}
    {% endautoescape %}
    </div>
  {% elif paper.abstracts %}
    <div style="padding-top: 0.5em; padding-bottom: 0.5em;">
      {% if paper.abstracts[0].body|length > 500 %}
        {{ paper.abstracts[0].body[:500] }}...
      {% else %}
        {{ paper.abstracts[0].body }}
      {% endif %}
    </div>
  {% else %}
    <br>
  {% endif %}

  {# ### IDENTIFIERS #}
  {% if paper.biblio.doi %}
    <a target="_blank" href="https://doi.org/{{paper.biblio.doi }}" style="color: green;">doi:{{ paper.biblio.doi }}</a> &nbsp;
  {% endif %}
  {% if paper.biblio.pmid %}
    <a target="_blank" href="https://www.ncbi.nlm.nih.gov/pubmed/{{paper.biblio.pmid }}" style="color: green;">pmid:{{ paper.biblio.pmid }}</a> &nbsp;
  {% endif %}
  {% if paper.biblio.pmcid %}
    <a target="_blank" href="https://pubmed.ncbi.nlm.nih.gov/{{paper.biblio.pmcid }}/" style="color: green;">pmcid:{{ paper.biblio.pmcid }}</a> &nbsp;
  {% endif %}
  {% if paper.biblio.arxiv_id %}
    <a target="_blank" href="https://arxiv.org/abs/{{paper.biblio.arxiv_id }}" style="color: green;">arXiv:{{ paper.biblio.arxiv_id }}</a> &nbsp;
  {% endif %}
  {% if paper.biblio.release_ident %}
    <a target="_blank" href="https://fatcat.wiki/release/{{paper.biblio.release_ident}}" style="color: green;">fatcat:{{ paper.biblio.release_ident}}</a> &nbsp;
  {% endif %}

  {# ### TAGS #}
  <div style="margin-top: 0.2em;">
    {# colors to use: olive, brown, grey, pink, red, etc #}
    {# TODO: remove doc for ES 7.x-style lack of type #}
    {# TODO: only show 'json' link if from cluster? #}
    <a target="_blank" href="{{ settings.ELASTICSEARCH_BACKEND }}/{{ settings.ELASTICSEARCH_FULLTEXT_INDEX }}/_doc/{{ paper.key }}">
      <span class="ui label small" title="search document JSON debug link">json</span>
    </a>

    {% for tag in paper.tags %}
      {{ tag_label(tag) }}
    {% endfor %}
  </div>

  {# ### COLLAPSED HITS  #}
  {% if paper._collapsed_count > 0 %}
    <div style="padding-top: 0.5em;">
      <button class="ui compact basic blue button" form="search_form" type="submit" name="collapse_key" value="{{ paper.collapse_key }}">
          <i class="ui icon zoom-in"></i>
          Show {{ paper._collapsed_count }} additional hits from this issue
      </button>
    </div>
  {% endif %}

</div>
<div class="three wide left aligned column" style="padding-top: 0.5em; padding-right: 0.5em;">
  {% if paper.fulltext.access_url %}
    {% if paper.fulltext.thumbnail_url %}
      <div class="ui card" style="margin-bottom: 0.2em;">
        <a class="image" target="_blank" href="{{ paper.fulltext.access_url}}">
          <img src="{{ paper.fulltext.thumbnail_url }}">
        </a>
      </div>
    {% endif %}
    <a target="_blank" href="{{ paper.fulltext.access_url}}">
      <div style="width: 100%; opacity: 0.65; text-align: center;">
        {# TODO: could have other hover info, like mimetype icon and file size? #}
        <span>
        {% if paper.fulltext.access_type == "wayback" %}
          web.archive.org
        {% elif paper.fulltext.access_type in ["ia_sim", "ia_file"] %}
          archive.org
        {% endif %}
        {% if paper.fulltext.file_mimetype == "application/pdf" %}
          <i class="file pdf outline icon"></i>
        {% elif paper.fulltext.access_type == "ia_sim" %}
          <i class="film icon"></i>
        {% endif %}
        </span>
      </div>
    </a>
  {% else %}
    {# No Fulltext #}
  {% endif %}
</div>
</div>
{% endmacro %}

{% macro search_pagination(hits, top) %}
{% if hits.offset > 0 %}
  <button class="text-button" form="search_form" type="submit" name="offset" value="{{ hits.offset - hits.limit }}" style="margin-right: 2em;">
    <a>&#xab; Previous</a>
  </button>
{% else %}
  <span style="color:gray; margin-right: 2em;">&#xab; Previous</span>
{% endif %}
<i>Showing results {{ hits.offset }} &mdash; {{ hits.offset + hits.limit }} out of {{ "{:,}".format(hits.count_found) }} results</i>
{% if hits.offset + hits.limit < hits.count_found %}
<button class="text-button" form="search_form" type="submit" name="offset" value="{{ hits.offset + hits.limit }}" style="margin-left: 2em;">
  <a>Next &#xbb;</a>
{% else %}
  <span style="color:gray; margin-left: 2em;">Next &#xbb;</span>
{% endif %}
</button>
{% endmacro %}

{% macro query_option(options, selected) -%}
<span style="color: rgba(0,0,0,0.4);">{{ _(options.label) }}</span>
<div class="ui link list" style="margin-top: 0.3em;">
  {% for opt in options.list %}
    <button class="text-button" form="search_form" type="submit" name="{{ options.slug }}" value="{{ opt.slug }}">
      {% if selected == opt.slug or (not selected and opt.slug == options.default) %}
        <span style="font-weight: bold;">
      {% else %}
        <span>
      {% endif %}
      {{ _(opt.label) }}
      </span>
    </button>
    <br>
    </span>
  {% endfor %}
</div>
<br>
{% endmacro %}

{% macro query_hidden(options, selected) -%}
{% if selected %}
  <input form="search_form" type="hidden" name="{{ options.slug }}" value="{{ selected }}">
{% endif %}
{% endmacro %}