aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/templates/container_view_browse.html
blob: 6ea06df8cc558ad577d6489040fa11897c77b7fd (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
{% 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>
              {% endif %}
            </td>
          {% endif %}

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

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

{% macro browse_releases(found) %}
  <h2>
    {% 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>
  <br>
  {% for release_doc in found.results %}
    <div class="ui grid">
      <div class="two wide center aligned column">
        {% if request.args.volume %}
          {% if release_doc.pages %}
            {{ release_doc.pages }}
          {% else %}
            {# blank #}
          {% endif %}
        {% elif release_doc.release_date %}
          {{ release_doc.release_date }}
        {% endif %}
      </div>
      <div class="fourteen wide column">
        {{ entity_macros.release_search_result_row(release_doc, margin_top=False) }}
      </div>
    </div>
  {% endfor %}
{% 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 %}