Princeton-CDH/ppa-django

View on GitHub
ppa/archive/templates/archive/digitizedwork_detail.html

Summary

Maintainability
Test Coverage
{% extends "base.html"  %}
{% load render_bundle from webpack_loader %}
{% load static semanticui humanize %}

{% block js %}
{% if object.has_fulltext %}
{% render_bundle 'searchWithin' 'js' %}
{% endif %}
{% endblock %}

{% block page-subtitle %}Archive ยท {{ object.title }} {% endblock %}
{% block metadata %}
<meta name="twitter:label1" content="Publication Date" />
<meta name="twitter:data1" content="{{ object.pub_date }}" />
<meta name="twitter:label2" content="Author" />
<meta name="twitter:data2" content="{{ object.author }}" />
{% endblock %}

{% block head_extras %}
    <link rel="unapi-server" type="application/xml" title="unAPI"
          href="{% url 'unapi' %}" />
    <noscript>
        <link rel="stylesheet" type="text/css" href="{% static 'css/noscript.css' %}"/>
    </noscript>
{% endblock %}

{% block page-context-id %}digitized-work{% endblock %}

{% block page_nav %}
    {% include 'snippets/nav.html' with style="archive" active="archive" %}
{% endblock %}

{% block content %}
<section class="meta ui basic vertical segment container">
    {% if object.item_type != object.FULL %}
    <div class="work-type icon" aria-label="{{ object.get_item_type_display|lower }}"></div>
    {% endif %}
    <h1 class="header">{{ object.title }}</h1>
    {% if object.item_type == object.FULL %} {# unapi metadata only available for full works #}
    <abbr class="unapi-id" title="{{ object.index_id }}"></abbr>
    {% endif %}
    <table class="metadata ui very basic table">
        <tbody>
            {% if object.subtitle %}
            <tr class="secondary-title">
                <th scope="row">Secondary Title</th>
                <td>{{ object.subtitle }}</td>
            </tr>
            {% endif %}
            {% if object.book_journal %}
            <tr class="book-journal">
                <th scope="row">{% if object.item_type == object.ARTICLE %}Journal{% elif object.item_type == object.EXCERPT %}Book{% endif %} Title</th>
                <td>{{ object.book_journal }}</td>
            </tr>
            {% endif %}
            {% if object.enumcron %}
            <tr>
                <th scope="row">Volume</th>
                <td>{{ object.enumcron }}</td>
            </tr>
            {% endif %}
            {% if object.pub_date %}
            <tr>
                <th scope="row">Publication Date</th>
                <td>{{ object.pub_date }}</td>
            </tr>
            {% endif %}
            {% if object.author %}
            <tr>
                <th scope="row">Author</th>
                <td>{{ object.author }}</td>
            </tr>
            {% endif %}
            {% if object.publisher %}
            <tr>
                <th scope="row">Publisher</th>
                <td>{{ object.publisher }}</td>
            </tr>
            {% endif %}
            {% if object.pub_place %}
            <tr>
                <th scope="row">City</th>
                <td>{{ object.pub_place }}</td>
            </tr>
            {% endif %}
            {% if object.page_count %}
            <tr>
                <th scope="row">Page count</th>
                <td>{{ object.page_count }}</td>
            </tr>
            {% endif %}
            {% if object.pages_orig %}
            <tr>
                <th scope="row">Pages</th>
                <td>{{ object.pages_orig }}</td>
            </tr>
            {% endif %}
            {% if object.collections.exists %}
            <tr>
                <th scope="row">PPA Collection{{ object.collections.count|pluralize }}</th>
                <td>
                    {% for collection in object.collections.all %}
                    <label class="ui basic button" href="{% url 'archive:list' %}?collections={{ collection.pk }}">{{ collection }}</label>
                    {% endfor %}
                </td>
            </tr>
            {% endif %}

            {% if object.source_url %}
            <tr class="source-link">
                <th scope="row">{{ object.get_source_link_label }}</th>
                <td>
                    {% if object.pages_digital %}  {# if page range is defined (excerpt/article), link to first *digital* page in range #}
                        {% if object.source == object.HATHI %}
                        <a href="{% hathi_page_url object.source_id object.first_page_digital %}" target="_blank" rel="noopener noreferrer">{{ object.source_id }}</a>
                        {% elif object.source == object.GALE %}
                        <a href="{% gale_page_url object.source_url object.first_page_digital %}" target="_blank" rel="noopener noreferrer">{{ object.source_id }}</a>
                        {% endif %}
                    {% else %} {# when there is no page range, use source url #}
                    <a href="{{ object.source_url }}" target="_blank" rel="noopener noreferrer">{{ object.source_id }}</a>
                    {% endif %}
                </td>
            </tr>
            {% endif %}
            {% if object.public_notes %}
            <tr>
              <th scope="row">Note on edition</th>
              <td>
                {{ object.public_notes }}
              </td>
            </tr>
            {% endif %}
            {% if user.is_authenticated %}
              {% if object.notes %}
              <tr>
                <th scope="row">Curation notes</th>
                <td>
                  {{ object.notes }}
                </td>
              </tr>
              {% endif %}
            <tr>
                <th scope="row">Added</th>
                <td>{{ object.added|date:"d M Y" }}</td>
            </tr>
            <tr>
                <th scope="row">Last Updated</th>
                <td>{{ object.updated|date:"d M Y" }}</td>
            </tr>
            {% endif %}
        </tbody>
    </table>

    {# if cluster  is set, this work is part of a reprint/edition group #}
    {% if object.cluster %}
    {# TODO: if we can get count from solr, here's how to get count from db #}
    {# {{ object.cluster.digitizedwork_set.count }} #}
        {% include "archive/snippets/cluster_work.html" with cluster_id=object.cluster %}

    {% endif %}

</section>
{# search within a volume currently only supported for hathi content #}
{% if object.has_fulltext %}
<section class="ui basic vertical segment container">
    <form id="search-within" class="ui form">
        <div class="ui vertical basic grid segment">
            <legend class="sr-only">text search fields</legend>
            <div class="twelve wide column">
                {% render_field search_form.query %}
                <span class="question-popup" data-html="{{ search_form.QUESTION_POPUP_TEXT }}" data-position="top center">
                    <i class="ui question circle icon"></i>
                </span>
            </div>
            <input class="sr-only sr-only-focusable" type="submit" aria-label="submit search">
        </div>
    </form>
    {% include 'archive/snippets/jump_top.html' with anchor='digitized-work' %}
</section>
  {# display matching pages with highlighted text if there is a search active #}
  <output class="ajax-container" form="search-within">
    {% include 'archive/snippets/results_within_list.html' %}
  </output>
{% endif %}
{% endblock %}