Skip to content

Commit

Permalink
Merge pull request #1628 from Princeton-CDH/feature/1627-itt-scholars…
Browse files Browse the repository at this point in the history
…hip-records

Implement scholarship records page redesign; include ITT panel (#1554)
  • Loading branch information
blms authored Jul 24, 2024
2 parents b3052e9 + e4f74fa commit fbd984c
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 67 deletions.
36 changes: 18 additions & 18 deletions geniza/corpus/templates/corpus/document_scholarship.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,36 @@ <h1 class="sr-only">{{ page_title }}</h1>
<dd>
{{ source.grouper.formatted_display|safe }}
</dd>
<dt class="relation">
{# Translators: label for included document relations for a single footnote #}
{% translate "includes" as includes_text %}
{% if source.list|has_location_or_url %}
{# Translators: label for document relations in list of footnotes #}
{% blocktranslate with relation=source.list|all_doc_relations|lower trimmed %}
for {{ relation }} see
{% endblocktranslate%}
{% else %}
{# Translators: label for document relations for one footnote with no location or URL #}
{% blocktranslate with relation=source.list|all_doc_relations|lower trimmed %}
includes {{ relation }}
{% endblocktranslate%}
{% endif %}
</dt>
{% if source.list|has_location_or_url %}
<dd class="relation">
<ul>
{# Translators: accessibility label for the specific location of a citation in a source record #}
<dt class="sr-only">{% translate "Location in source" %}</dt>
<dd>
<ul class="locations">
{% for fn in source.list %}
{% ifchanged %}{# omit duplicate footnote locations #}
<li class="location">{% include "corpus/snippets/footnote_location.html" %}</li>
<li>{% include "corpus/snippets/footnote_location.html" %}</li>
{% endifchanged %}
{% endfor %}
</ul>
</dd>
{% endif %}

{# Translators: accessibility label for the relationship(s) of a source to a document #}
<dt class="sr-only">{% translate "Relation to document" %}</dt>
<dd>
<ul class="relations">
{% for relation in source.list|all_doc_relations %}
<li>{{ relation }}</li>
{% endfor %}
</ul>
</dd>
</dl>
</li>
{% endspaceless %}
{% endfor %}
</ol>
</div>

{# viewer #}
{% include "corpus/snippets/document_transcription.html" %}
{% endblock main %}
2 changes: 1 addition & 1 deletion geniza/corpus/templates/corpus/snippets/document_tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{% translate "Document Details" as details_text %}
<li><a href="{{ document_url }}"{% if request.path == document_url %} aria-current="page"{% endif %}>{{ details_text }}</a></li>
{# Translators: n_records is number of scholarship records #}
{% blocktranslate asvar srec_text %}Scholarship Records ({{ n_records }}){% endblocktranslate %}
{% blocktranslate asvar srec_text %}Select Bibliography ({{ n_records }}){% endblocktranslate %}
{% url 'corpus:document-scholarship' pk=document.pk as scholarship_url %}
<li>{% if n_records > 0 %}<a href="{{ scholarship_url }}"{% if request.path == scholarship_url %} aria-current="page"{% endif %}>{{ srec_text }}</a>{% else %}<span disabled aria-disabled="true">{{ srec_text }}</span>{% endif %}</li>
{# Translators: n_reldocs is number of related documents #}
Expand Down
8 changes: 5 additions & 3 deletions geniza/corpus/templatetags/corpus_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ def has_location_or_url(footnotes):

@register.filter
def all_doc_relations(footnotes):
"""For scholarship records list: join doc relations for all footnotes
by a comma."""
return ", ".join(sorted(set([str(fn.doc_relation) for fn in footnotes])))
"""For scholarship records list: list doc relations for all footnotes."""
relations = set()
for fn in footnotes:
relations.update(set([n.strip() for n in str(fn.doc_relation).split(",")]))
return sorted(relations)
22 changes: 13 additions & 9 deletions geniza/corpus/tests/test_corpus_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,7 @@ def test_source_relation(self, client, document, source, twoauthor_source):
response = client.get(
reverse("corpus:document-scholarship", args=[document.pk])
)
assertContains(
response, '<dt class="relation">includes edition</dt>', html=True
)
assertContains(response, "<li>Edition</li>", html=True)

fn2 = Footnote.objects.create(
content_object=document,
Expand All @@ -401,7 +399,7 @@ def test_source_relation(self, client, document, source, twoauthor_source):
response = client.get(
reverse("corpus:document-scholarship", args=[document.pk])
)
assertContains(response, '<dt class="relation">for edition see</dt>', html=True)
assertContains(response, "<li>Edition</li>", html=True)

fn2.doc_relation = [Footnote.EDITION, Footnote.TRANSLATION]
fn2.save()
Expand All @@ -410,7 +408,13 @@ def test_source_relation(self, client, document, source, twoauthor_source):
)
assertContains(
response,
'<dt class="relation">for edition, translation see</dt>',
"<li>Edition</li>",
html=True,
)
print(response.content)
assertContains(
response,
"<li>Translation</li>",
html=True,
)

Expand All @@ -425,7 +429,7 @@ def test_source_location(self, client, document, source):
response = client.get(
reverse("corpus:document-scholarship", args=[document.pk])
)
assertContains(response, "p. 25")
assertContains(response, "<li>p. 25</li>", html=True)
fn.location = ""
fn.save()
response = client.get(
Expand Down Expand Up @@ -484,7 +488,7 @@ def test_no_footnotes(self, client, document):
# uses span, not link
assertContains(
response,
"<span disabled aria-disabled='true'>Scholarship Records (0)</span>",
"<span disabled aria-disabled='true'>Select Bibliography (0)</span>",
html=True,
)

Expand All @@ -498,13 +502,13 @@ def test_with_footnotes(self, client, document, source, twoauthor_source):
response, reverse("corpus:document-scholarship", args=[document.pk])
)
# count should be 1
assertContains(response, "Scholarship Records (1)")
assertContains(response, "Select Bibliography (1)")

Footnote.objects.create(content_object=document, source=twoauthor_source)
response = client.get(document.get_absolute_url())

# count should be 2
assertContains(response, "Scholarship Records (2)")
assertContains(response, "Select Bibliography (2)")

def test_no_related_docs(self, client, document, empty_solr):
"""document nav should render disabled related documents tab if no related documents"""
Expand Down
16 changes: 8 additions & 8 deletions geniza/corpus/tests/test_corpus_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ def test_all_doc_relations(self, document, footnote):
source=footnote.source,
doc_relation=Footnote.DIGITAL_EDITION,
)
assert (
corpus_extras.all_doc_relations(list(document.footnotes.all()))
== "Digital Edition, Edition"
)
assert corpus_extras.all_doc_relations(list(document.footnotes.all())) == [
"Digital Edition",
"Edition",
]
# should not repeat doc relations even if multiple of the same type appear
Footnote.objects.create(
object_id=document.pk,
Expand All @@ -71,10 +71,10 @@ def test_all_doc_relations(self, document, footnote):
doc_relation=Footnote.EDITION,
location="other place",
)
assert (
corpus_extras.all_doc_relations(list(document.footnotes.all()))
== "Digital Edition, Edition"
)
assert corpus_extras.all_doc_relations(list(document.footnotes.all())) == [
"Digital Edition",
"Edition",
]


def test_dict_item():
Expand Down
9 changes: 6 additions & 3 deletions sitemedia/js/controllers/iiif_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,12 @@ export default class extends Controller {
);
}
const OSD = this.osdTarget.querySelector(".openseadragon-container");
OSD.style.transition = "opacity 300ms ease, visibility 0s ease 300ms";
OSD.style.visibility = "hidden";
OSD.style.opacity = "0";
if (OSD) {
OSD.style.transition =
"opacity 300ms ease, visibility 0s ease 300ms";
OSD.style.visibility = "hidden";
OSD.style.opacity = "0";
}
}

addOpenSeaDragon(settings) {
Expand Down
2 changes: 1 addition & 1 deletion sitemedia/scss/components/_docheader.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ html[lang="ar"] span#formatted-title {

// Edit link for admins
.edit-link-container {
@include container.measure;
max-width: calc(896px + 2rem);
top: spacing.$spacing-4xl;
position: absolute;
width: 100%;
Expand Down
63 changes: 44 additions & 19 deletions sitemedia/scss/components/_footnote.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@

.citation {
counter-increment: search-counter;
padding-bottom: spacing.$spacing-md;
padding: 0 0 spacing.$spacing-md spacing.$spacing-xl;
margin-left: -#{spacing.$spacing-lg};
@include breakpoints.for-tablet-landscape-up {
padding-left: spacing.$spacing-xl;
padding-left: 1.625rem;
margin-left: 0;
}
@include typography.body;
Expand All @@ -26,42 +25,68 @@
}
&::before {
content: counter(search-counter);
margin-left: -#{spacing.$spacing-xl};
margin-left: -1.625rem;
text-align: left;
float: left;
@include typography.body-bold;
}
.relation {
max-width: none; // required to span the whole width
background-color: var(--background-light);
margin-left: -#{spacing.$spacing-xl};
padding: spacing.$spacing-4xs 0 spacing.$spacing-4xs spacing.$spacing-xl;
&:is(dt) {
margin-top: spacing.$spacing-md;
@include typography.caption;
}
&:is(dd) {
margin-bottom: spacing.$spacing-2xs;
@include typography.meta;
}
li.location {
ul.locations {
margin-top: 0.5rem;
li {
@include typography.body-bold;
word-break: break-all;
}
}
ul.relations {
display: flex;
flex-flow: row wrap;
gap: 1rem;
margin-top: 1rem;
li {
display: flex;
align-items: center;
height: 2rem;
padding: 0 spacing.$spacing-md;
border-radius: 5px;
background-color: var(--background-gray);
}
}
div.unpublished {
margin-top: spacing.$spacing-3xs;
@include typography.unpublished;
color: var(--on-background-alt);
}
}

// RTL overrides
html[dir="rtl"] .citation {
padding: 0 spacing.$spacing-xl spacing.$spacing-md 0;
margin-right: -#{spacing.$spacing-lg};
margin-left: 0;
@include breakpoints.for-tablet-landscape-up {
padding-right: 1.625rem;
padding-left: 0;
margin-right: 0;
margin-left: 0;
}
&::before {
margin-left: 0;
margin-right: -1.625rem;
text-align: right;
float: right;
}
& + .citation {
padding-top: spacing.$spacing-md;
}
}

// Hebrew variant
html[lang="he"] .citation {
@include typography.body-he;
*[lang="en"] {
@include typography.body;
}
dd.relation:not([lang="en"]) {
ul.relations li:not([lang="en"]) {
@include typography.meta-he;
}
}
Expand All @@ -72,7 +97,7 @@ html[lang="ar"] .citation {
*[lang="en"] {
@include typography.body;
}
dd.relation:not([lang="en"]) {
ul.relations li:not([lang="en"]) {
@include typography.meta-ar;
}
}
4 changes: 2 additions & 2 deletions sitemedia/scss/components/_tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ nav#tabs {
padding-bottom: spacing.$spacing-xs;
border-bottom: 4px solid var(--tabs-bottom);
@include breakpoints.for-tablet-landscape-up {
padding-left: 6rem;
padding-right: 6rem;
padding-left: 5.5rem;
padding-right: 5.5rem;
}
}
// Link-specific tabs styling
Expand Down
16 changes: 16 additions & 0 deletions sitemedia/scss/pages/_document.scss
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,22 @@ main.document {
}
}

// RTL tweaks
html[dir="rtl"] main.document section.content-stats ul {
margin-right: 1.25rem;
margin-left: 0;
li + li {
border-left: none;
border-right: 1px solid var(--disabled);
padding-left: 0;
padding-right: 1rem;
@include breakpoints.for-tablet-landscape-up {
padding-left: 0;
padding-right: 1.5rem;
}
}
}

// Hebrew variant
html[lang="he"] main.document {
.container section.description h3 {
Expand Down
2 changes: 1 addition & 1 deletion sitemedia/scss/pages/_person.scss
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ html[dir="rtl"] main.person,
html[dir="rtl"] main.place,
html[dir="rtl"] main.document {
.container dl.metadata-list dt::before,
.container .description h2::before {
.container section > h2::before {
margin-right: 0;
margin-left: 12px;
}
Expand Down
21 changes: 19 additions & 2 deletions sitemedia/scss/pages/_scholarship.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
@use "../base/spacing";

main.scholarship {
max-width: 100vw;
@include breakpoints.for-tablet-landscape-up {
.container,
.container * {
max-width: calc(896px + 2rem);
}
}
// Primary container
div.container {
display: flex;
Expand All @@ -17,9 +24,19 @@ main.scholarship {
}
ol {
counter-reset: search-counter;
margin: spacing.$spacing-2xl 0 spacing.$spacing-xl spacing.$spacing-lg;
margin: 3rem 0 spacing.$spacing-xl spacing.$spacing-lg;
@include breakpoints.for-tablet-landscape-up {
margin: calc(2rem + 10px) 0 0;
}
}
}

// RTL overrides
html[dir="rtl"] main.scholarship {
ol {
margin: 3rem spacing.$spacing-lg spacing.$spacing-xl 0;
@include breakpoints.for-tablet-landscape-up {
margin: spacing.$spacing-3xl 0 0;
margin: calc(2rem + 10px) 0 0;
}
}
}

0 comments on commit fbd984c

Please sign in to comment.