Skip to content

Commit

Permalink
Add "what's in the PGP" section to doc detail (#1623)
Browse files Browse the repository at this point in the history
  • Loading branch information
blms committed Jul 23, 2024
1 parent a9aee34 commit ab5a94d
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 7 deletions.
33 changes: 33 additions & 0 deletions geniza/corpus/templates/corpus/document_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,39 @@ <h2 class="sr-only">
</dl>
</section>

{% if document.has_image or document.digital_editions.count or document.digital_translations.count %}
{% with n_transcriptions=document.digital_editions.count n_translations=document.digital_translations.count %}
<section class="content-stats">
{# Translators: label for document content stats (number of translations, transcriptions, images) #}
<h2>{% translate "What's in the PGP" %}</h2>
<ul>
{# translators: indicator that a document has an image #}
{% if document.has_image %}<li class="has-image">{% translate 'Image' %}</li>{% endif %}
{% if n_transcriptions > 0 %}
{# translators: n_transcriptions is the number of a document's digitized transcriptions #}
<li class="transcription-count">
{% blocktranslate count counter=n_transcriptions trimmed %}
{{ n_transcriptions }} Transcription
{% plural %}
{{ n_transcriptions }} Transcriptions
{% endblocktranslate %}
</li>
{% endif %}
{% if n_translations > 0 %}
{# translators: n_translations is the number of a document's digitized translations #}
<li class="translation-count">
{% blocktranslate count counter=n_translations trimmed %}
{{ n_translations }} Translation
{% plural %}
{{ n_translations }} Translations
{% endblocktranslate %}
</li>
{% endif %}
</ul>
</section>
{% endwith %}
{% endif %}

<section class="description">
{# Translators: label for document description #}
<h2>{% translate 'Description' %}</h2>
Expand Down
38 changes: 38 additions & 0 deletions geniza/corpus/tests/test_corpus_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,44 @@ def test_source_location(self, client, document, source):
)
assertNotContains(response, "p. 25") # should not show when removed

def test_whats_in_pgp(self, client, document, source, unpublished_editions):
"""Document detail template should show what's in the PGP"""
# has no image, transcription or translation
empty_doc = Document.objects.create()
response = client.get(empty_doc.get_absolute_url())
assertNotContains(response, "What's in the PGP")

# has image but no transcription or translation
response = client.get(document.get_absolute_url())
assertContains(response, "What's in the PGP")
assertContains(response, '<li class="has-image">Image</li>')
assertNotContains(response, '<li class="transcription-count">')
assertNotContains(response, '<li class="translation-count">')

# add a footnote with a digital edition
Footnote.objects.create(
content_object=document,
source=unpublished_editions,
doc_relation=[Footnote.DIGITAL_EDITION],
)
response = client.get(document.get_absolute_url())
assertContains(response, '<li class="transcription-count">')
assertContains(response, "1 Transcription")

# add two footnotes with digital translation
Footnote.objects.create(
content_object=document,
source=source,
doc_relation=[Footnote.DIGITAL_TRANSLATION],
)
Footnote.objects.create(
content_object=document,
source=unpublished_editions,
doc_relation=[Footnote.DIGITAL_TRANSLATION],
)
response = client.get(document.get_absolute_url())
assertContains(response, "2 Translations")


class TestDocumentTabsSnippet:
def test_detail_link(self, client, document):
Expand Down
77 changes: 70 additions & 7 deletions sitemedia/scss/pages/_document.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
main.document {
max-width: 100vw;
@include breakpoints.for-tablet-landscape-up {
box-sizing: content-box;
* {
max-width: 896px;
.container,
.container *,
section,
section * {
max-width: calc(896px + 2rem);
}
}
// Primary container
Expand Down Expand Up @@ -98,14 +100,12 @@ main.document {
margin: 2rem 0 0;
align-self: flex-start;
margin-left: 0;
padding: 0 spacing.$spacing-md 2rem;
}
}
// "Description" header and content
// "what's in the PGP" and "description"
section.content-stats,
section.description {
padding-bottom: 2rem;
margin: spacing.$spacing-md 0 0;
border-bottom: 1px solid var(--disabled);
@include breakpoints.for-tablet-landscape-up {
margin: 2rem 0 0;
}
Expand All @@ -118,6 +118,68 @@ main.document {
@include meta-marker;
}
}
}
// what's in the pgp
section.content-stats ul {
display: flex;
flex-flow: row wrap;
margin-left: 1.25rem;
gap: 1rem;
@include breakpoints.for-tablet-landscape-up {
gap: 1.5rem;
}
li + li {
border-left: 1px solid var(--disabled);
padding-left: 1rem;
@include breakpoints.for-tablet-landscape-up {
padding-left: 1.5rem;
}
}
li {
display: flex;
align-items: center;
gap: 0.625rem;
&::before {
display: flex;
align-items: center;
justify-content: center;
border-radius: 4px;
background-color: var(--background-light);
width: 1.5rem;
height: 1.5rem;
@include breakpoints.for-tablet-landscape-up {
width: 2rem;
height: 2rem;
}
}
}
li.has-image::before {
content: "\f1dd"; // phosphor ph-image icon
@include typography.icon-button-sm;
@include breakpoints.for-tablet-landscape-up {
@include typography.icon-button-md;
}
}
li.transcription-count::before {
content: "a";
font-size: typography.$text-size-xl;
@include breakpoints.for-tablet-landscape-up {
font-size: typography.$text-size-4xl;
}
}
li.translation-count::before {
content: "א";
@include typography.transcription;
@include breakpoints.for-tablet-landscape-up {
font-size: typography.$text-size-4xl;
padding-bottom: 2px;
}
}
}
// Description
section.description {
padding-bottom: 2rem;
border-bottom: 1px solid var(--disabled);
p {
white-space: pre-line;
padding-left: 1.25rem;
Expand All @@ -142,6 +204,7 @@ main.document {
@include breakpoints.for-tablet-landscape-up {
width: 896px;
margin: 2rem 0;
padding: 0;
}
@include typography.body;
color: var(--extra-metadata-text);
Expand Down

0 comments on commit ab5a94d

Please sign in to comment.