aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/templates/container_view_browse.html
blob: d16502d011377bd1e5da915cb0cea3321a421570 (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
{% set container = entity %}
{% set entity_view = "browse" %}
{% set entity_type = "container" %}
{% import "entity_macros.html" as entity_macros %}
{% extends "entity_base.html" %}

{% macro browse_year_volume_issue_table(entity, data) %}
<table class="ui basic compact structured table">
  <thead>
    <tr>
      <th>Year
      <th>Volume
      <th>Issue
      <th class="right aligned">Indexed Content
    </tr>
  </thead>
  <tbody>
  {# NOTE: this section is pretty nested, with complex behavior; it could be hard to edit and understand #}
  {# TODO: these "sorts" are lexical, not numeric, which causes problems #}
  {% for year in data %}
    {% set year_loop = loop %}
    {% for volume in year.volumes %}
      {% set volume_loop = loop %}
      {% for issue in volume.issues %}
        {% set issue_loop = loop %}
        <tr>
          {% if volume_loop.first and issue_loop.first %}
            {% set year_rowspan = year.volumes|map(attribute='issues')|map('length')|sum %}
            <td rowspan="{{ year_rowspan }}" class="top aligned">
              <a href="/container/{{ entity.ident }}/browse?year={{ year.year }}">{{ year.year }}</a>
            </td>
          {% endif %}

          {% if issue_loop.first %}
            <td rowspan="{{ volume.issues|length }}" class="top aligned">
              {% if volume.volume %}
                <a href="/container/{{ entity.ident }}/browse?volume={{ volume.volume }}">Vol. {{ volume.volume }}</a>
              {% else %}
                -
              {% endif %}
            </td>
          {% endif %}

          <td>
            {% if issue.issue %}
              <a href="/container/{{ entity.ident }}/browse?year={{ year.year }}&volume={{ volume.volume or '' }}&issue={{ issue.issue or '' }}">Issue {{ issue.issue }}</a>
            {% else %}
              -
            {% endif %}
          </td>

          <td class="right aligned">
            <a href="/container/{{ entity.ident }}/browse?year={{ year.year }}&volume={{ volume.volume or '' }}&issue={{ issue.issue or '' }}">{{ "{:,}".format(issue.count) }} releases</a>
          </td>
        </tr>
      {% endfor %}
    {% endfor %}
  {% endfor %}
  </tbody>
</table>
{% endmacro %}

{% macro browse_releases(found) %}
  <h2 style="margin-bottom: 1em;">
    {% if request.args.volume %}
      Volume {{ request.args.volume }}
      {%- if request.args.issue %}, Issue {{ request.args.issue }}{% endif -%}
      {%- if request.args.year %} ({{ request.args.year }}){% endif %}
    {% else %}
      Year {{ request.args.year }}
    {% endif %}
  </h2>
  {% if not found.results %}
    <p><i>No publications found!</i>
  {% else %}
    <table class="ui very basic compact structured table">
    <thead>
      <tr><th class="one wide center aligned">{% if request.args.volume %}Page(s){% else %}Date{% endif %}</th>
          <th class="nine wide">Publication</th>
    </thead>
    <tbody>
    {% for release_doc in found.results %}
      <tr><td class="center aligned">
          {% if request.args.volume %}
            {% if release_doc.pages %}
              {{ release_doc.pages }}
            {% else %}
              -
            {% endif %}
          {% elif release_doc.release_date %}
            {{ release_doc.release_date }}
          {% else %}
            -
          {% endif %}
        </td>
        <td>
          {{ entity_macros.release_search_result_row(release_doc, margin_top=False) }}
        </td>
    {% endfor %}
    </tbody>
    </table>
    {% if found.count_found > found.count_returned %}
      <p><i>Showing only the first {{ found.count_returned }} out of {{ found.count_found }} releases</i>
    {% endif %}
    <p><i><a href="/container/{{ entity.ident }}/browse">Back to full listing</a></i>
  {% endif %}
{% endmacro %}

{% block entity_main %}

{% if releases_found %}
  {{ browse_releases(releases_found) }}
{% elif entity._browse_year_volume_issue %}
  <div class="ui container text">
    <h3>Publications by Year, Volume, and Issue</h3>
    <p>This table includes content which does not have article-level metadata
    about volume or issue, but at least the year of publication must be known.
    "Stub" releases (eg, spam or duplicate DOIs) are not listed.
    {{ browse_year_volume_issue_table(entity, entity._browse_year_volume_issue) }}
  </div>
{% endif %}

{% endblock %}