aboutsummaryrefslogtreecommitdiffstats
path: root/fatcat_covid19/templates/entity_macros.html
blob: 7be51ad085a1ef2e41eac7bba21408039c2d0c99 (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

{% macro fulltext_search_result_row(paper) -%}
<div class="row">
<div class="thirteen wide column">
  {# ### TITLE ROW #}
  <h4 style="margin-top: 1em; margin-bottom: 0px; font-size: 1.2em;">

    {# "best URL" calculation #}
    {% if paper.pmcid %}
    <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/{{ paper.pmcid }}/"
    {% elif paper.pmid %}
    <a href="https://pubmed.ncbi.nlm.nih.gov/{{ paper.pmid }}/"
    {% else %}
    <a href="https://fatcat.wiki/release/{{ paper.fatcat_ident }}"
    {% endif %}
    style="color: #2224c7;">
      {% if g.lang_code != 'en' and g.lang_code == paper.lang and paper.original_title %}
        {# show original title first instead of title if UI is in that language #}
        {{ paper.original_title[:512] }}
        {% if paper.original_title|length > 512 %}...{% endif %}
      {% elif paper.title %}
        {{ paper.title[:512] }}
        {% if paper.title|length > 512 %}...{% endif %}
      {% else %}
        [blank]
      {% endif %}
    </a>

    {# release type suffix #}
    {% if paper.release_type in ("article-journal", "paper-conference") %}
      {# pass #}
    {% elif paper.release_type in ("book", "chapter", "dataset") %}
      <b style="text-transform: uppercase;">[{{ _(paper.release_type) }}]</b>
    {% elif not paper.release_type %}
      <b style="text-transform: uppercase; color: red;">[media?]</b>
    {% else %}
      <b style="text-transform: uppercase;">[{{ _(paper.release_type) }}]</b>
    {% endif %}

    {# show inverse of title/original_title above #}
    {% if g.lang_code != 'en' and g.lang_code == paper.lang and paper.title and paper.title != paper.original_title %}
      <br>
      <i style="font-weight: normal;">
        {{ paper.title[:512] }} {% if paper.title|length > 512 %}...{% endif %}
      </i>
    {% elif paper.original_title and paper.title != paper.original_title %}
      <br>
      <i style="font-weight: normal;">
        {{ paper.original_title[:512] }} {% if paper.original_title|length > 512 %}...{% endif %}
      </i>
    {% endif %}

  </h4>

  {#
  <div style="float: right; padding: 4px;">
  &nbsp;&nbsp;<a href="{{ config.ELASTICSEARCH_BACKEND }}/{{ config.ELASTICSEARCH_FULLTEXT_INDEX }}/release/{{ paper.fatcat_ident }}" class="ui grey tag label"><i class="file icon"></i>json</a>
  </div>

  {% if paper.best_pdf_url %}
  <div style="float: right; padding: 4px;">
  &nbsp;&nbsp;<a href="{{ paper.best_pdf_url }}" class="ui violet tag label"><i class="file icon"></i>fulltext</a>
  </div>
  {% endif %}
  #}


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


  {# ### JOURNAL ROW #}
  {% if paper.release_year %}
    {{ paper.release_year }}
  {% endif %}
  {% if paper.release_year and paper.container_name %}
    |
  {% endif %}
  {% if paper.container_name %}
    {% if paper.container_id %}
      <a href="https://fatcat.wiki/container/{{ paper.container_id }}" style="color: black;">{{ paper.container_name }}</a>
    {% else %}
      {{ paper.container_name }}
    {% endif %}
    {% if paper.container_is_oa %}<i class="icon unlock orange small"></i>{% endif %}
  {% endif %}
  {% if paper.withdrawn_status %}
    <b style="color: red;"><code>[{{ paper.withdrawn_status }}]</code></b>
  {% endif %}
  {% if paper.release_stage == "accepted" %}
    <b style="color: brown;"><code>[{{ paper.release_stage }}]</code></b>
  {% elif paper.release_stage and paper.release_stage != "published" %}
    <b style="color: red;"><code>[{{ paper.release_stage }}]</code></b>
  {% elif not paper.release_stage %}
    <b style="color: red;"><code>[unpublished?]</code></b>
  {% endif %}

  {# ### ABSTRACT / QUERY HIGHLIGHT #}
  {% if paper._highlights %}
    <div style="padding-top: 1em; padding-left: 0.5em; padding-bottom: 0.5em;" class="search_highlights">
    {% for highlight in paper._highlights %}
      {{ highlight|safe }} ...
    {% endfor %}
    </div>
  {% elif paper.abstract %}
    <div style="padding-top: 1em; padding-left: 0.5em; padding-bottom: 0.5em;">
      {% if paper.abstract[0]|length > 500 %}
        {{ paper.abstract[0][:500] }}...
      {% else %}
        {{ paper.abstract[0][:500] }}...
      {% endif %}
    </div>
  {% else %}
    <br>
  {% endif %}

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

  {# ### SOURCE TAGS #}
  <div style="margin-top: 0.2em;">
  {% if paper.cord19_uid or 'cord19' in paper.source_tags %}
    <a href="https://pages.semanticscholar.org/coronavirus-research">
      <span class="ui label small">CORD-19</span>
    </a>
  {% endif %}
  {% if 'fatcat' in paper.source_tags %}
    <a href="https://fatcat.wiki">
      <span class="ui label small">fatcat</span>
    </a>
  {% endif %}
  {% if 'who' in paper.source_tags %}
    <a href="https://www.who.int/emergencies/diseases/novel-coronavirus-2019/global-research-on-novel-coronavirus-2019-ncov">
      <span class="ui blue label small">WHO</span>
    </a>
  {% endif %}
  {% if 'wanfang' in paper.source_tags %}
    <a href="http://subject.med.wanfangdata.com.cn/Channel/7">
      <span class="ui olive label small">Wanfang</span>
    </a>
  {% endif %}
  {% if 'cnki' in paper.source_tags %}
    <a href="http://en.gzbd.cnki.net/GZBT/brief/Default.aspx">
      <span class="ui brown label small">CNKI</span>
    </a>
  {% endif %}
  {# olive, brown, grey, pink, red, etc #}
  </div>

</div>
<div class="three wide left aligned column" style="padding: 1em;">
  {% if paper.fulltext.thumbnail_url %}
    {% if paper.fulltext.ia_pdf_url %}
      <a href="{{ paper.fulltext.ia_pdf_url }}">
    {% else %}
      <a href="{{ config.COVID19_FULLTEXT_HOST }}{{ paper.fulltext.pdf_url }}">
    {% endif %}
      <img src="{{ config.COVID19_FULLTEXT_HOST }}{{ paper.fulltext.thumbnail_url }}" style="border: 1px solid grey; max-height: 12em; max-width: 100%;">
    </a>
    <br>
  {% else %}
    {# No Fulltext #}
  {% endif %}
{# should we include these little links?
    <code style="font-size: 0.9rem; padding-left: 0.5em;">
    {% if paper.fulltext.pdf_url %}
      <a href="{{ config.COVID19_FULLTEXT_HOST }}{{ paper.fulltext.pdf_url }}">mirror</a>
    {% endif %}
    {% if paper.fulltext.grobid_xml_url %}
      <a href="{{ config.COVID19_FULLTEXT_HOST }}{{ paper.fulltext.grobid_xml_url }}">xml</a>
    {% endif %}
    </code>
#}
</div>
</div>
{% endmacro %}


{% macro top_results(found) -%}

<i>Showing
  {% if found.offset == 0 %}
  first
  {% else %}
  results {{ found.offset }} &mdash;
  {% endif %}

  {{ found.offset + found.count_returned }}
  out of {{ found.count_found }} results
</i>

{%- endmacro %}


{% macro bottom_results(found, endpoint='search.fulltext_search') -%}

{% if found.offset > 0 %}
  {% if found.offset - found.limit < 0 %}
    <a href="{{ url_for(endpoint, q=found.query.q, offset=0) }}">&#xab; {{ _("Previous") }}</a>
  {% else %}
    <a href="{{ url_for(endpoint, q=found.query.q, offset=found.offset - found.limit) }}">&#xab; {{ _("Previous") }}</a>
  {% endif %}
{% else %}
  <span style="color:gray">&#xab; {{ _("Previous") }}</span>
{% endif %}

&nbsp;&nbsp;<i>Showing results {{ found.offset }} &mdash; {{ found.offset +
found.count_returned }} out of {{ found.count_found }} results</i>&nbsp;&nbsp;

{% if found.offset + found.limit < found.count_found and found.offset + found.limit < found.deep_page_limit %}
  <a href="{{ url_for(endpoint, q=found.query.q, offset=found.offset + found.limit) }}">Next &#xbb;</a>
  {% else %}
  <span style="color:gray">{{ _("Next") }} &#xbb;</span>
{% endif %}

{%- endmacro %}