Skip to content

Commit

Permalink
Add more details to records and archives
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Jan 18, 2024
1 parent 7c83090 commit 661a5a0
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 12 deletions.
4 changes: 4 additions & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
headings_list,
pretty_date,
pretty_number,
remove_all_whitespace,
replace_ext_ref,
slugify,
tna_html,
)
Expand Down Expand Up @@ -50,6 +52,8 @@ def create_app(config_class=Config):
app.add_template_filter(article_type)
app.add_template_filter(brand_icon_from_url)
app.add_template_filter(headings_list)
app.add_template_filter(replace_ext_ref)
app.add_template_filter(remove_all_whitespace)

@app.context_processor
def context_processor():
Expand Down
2 changes: 2 additions & 0 deletions app/catalogue/routes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import re

from app.catalogue import bp
from app.lib import cache, cache_key_prefix
from flask import current_app, render_template, url_for
Expand Down
14 changes: 14 additions & 0 deletions app/lib/template_filters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import re
from datetime import datetime

from flask import url_for


def tna_html(s):
return s.replace("<ul>", '<ul class="tna-ul">').replace(
Expand Down Expand Up @@ -74,3 +76,15 @@ def headings_list(s):
for heading in headings_raw
]
return headings


def replace_ext_ref(s):
ext_ref_pattern = re.compile(r'(<a class="extref" href="([\w\d]+)">)')
for link, id in re.findall(ext_ref_pattern, s):
new_link = url_for("catalogue.details", id=id)
s = s.replace(link, f'<a href="{new_link}">')
return s


def remove_all_whitespace(s):
return s.replace(" ", "")
24 changes: 22 additions & 2 deletions app/templates/catalogue/archive.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,32 @@ <h2 class="tna-heading-l">Contact information</h2>
{% if address_parts %}
<dt>Address</dt>
<dd>
<address class="etna-address">{{ '<br>'.join(address_parts) | safe }}</address>
<address class="etna-address">
{% if data.contact_info.map_url %}
<a href="{{ data.contact_info.map_url }}">{{ '<br>'.join(address_parts) | safe }}</a>
{% else %}
{{ '<br>'.join(address_parts) | safe }}
{% endif %}
</address>
</dd>
{% endif %}
{% if data.contact_info.url %}
<dt>Website</dt>
<dd><a href="{{ data.contact_info.url }}" target="_blank" title="Website for {{ data.name }} (opens in new tab)" rel="noopener noreferrer">{{ data.contact_info.url }}</a></dd>
<dd>
<a href="{{ data.contact_info.url }}" target="_blank" title="Website for {{ data.name }} (opens in new tab)" rel="noopener noreferrer">{{ data.contact_info.url }}</a>
</dd>
{% endif %}
{% if data.contact_info.email %}
<dt>Email</dt>
<dd>
<a href="mailto:{{ data.contact_info.email }}" title="Send an email to {{ data.name }}">{{ data.contact_info.email }}</a>
</dd>
{% endif %}
{% if data.contact_info.phone %}
<dt>Phone</dt>
<dd>
<a href="tel:{{ data.contact_info.phone | remove_all_whitespace }}" title="Call {{ data.name }}">{{ data.contact_info.phone }}</a>
</dd>
{% endif %}
</dl>
</aside>
Expand Down
19 changes: 9 additions & 10 deletions app/templates/catalogue/record.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ <h2 class="tna-heading-l">Detailed catalogue location</h2>
<div class="tna-container">
<div class="tna-column tna-column--width-2-3 tna-column--width-5-6-medium tna-column--full-small tna-column--full-tiny tna-!--margin-top-m">
<h2 class="tna-heading-l">Description and record details</h2>
<dl class="tna-dl">
<dl class="tna-dl etna-record-details">
{% if data.ref %}
<dt>Reference</dt>
<dd>{{ data.ref }}</dd>
Expand All @@ -148,7 +148,7 @@ <h2 class="tna-heading-l">Description and record details</h2>
{% endif %}
{% if data.description %}
<dt>Description</dt>
<dd>{{ data.description | safe }}</dd>
<dd>{{ data.description | replace_ext_ref | safe }}</dd>
{% endif %}
{% if data.held_by %}
<dt>Held by</dt>
Expand All @@ -168,29 +168,28 @@ <h2 class="tna-heading-l">Description and record details</h2>
{% endif %}
{% if data.languages %}
<dt>Language(s)</dt>
<dd>{{ ', '.join(data.languages) }}</dd>
<!-- <dd>
<ul class="tna-ul">
<dd>
<ul class="tna-ul tna-ul--plain">
{% for language in data.languages %}
<li>{{ language }}</li>
{% endfor %}
</ul>
</dd> -->
</dd>
{% endif %}
{% if data.creators %}
<dt>Creator(s)</dt>
<dd>
<ul class="tna-ul">
<ul class="tna-ul tna-ul--plain">
{% for creator in data.creators %}
<li>{{ creator.name }} ({{ creator.date }}) &mdash; {{ creator.title }}</li>
<li>{{ creator.name }} ({{ creator.date }}){% if creator.title %} &mdash; {{ creator.title }}{% endif %}</li>
{% endfor %}
</ul>
</dd>
{% endif %}
{% if data.acquisition %}
<dt>Immediate source of acquisition</dt>
<dd>
<ul class="tna-ul">
<ul class="tna-ul tna-ul--plain">
{% for acquisitor in data.acquisition %}
<li>{{ acquisitor.title }}{% if acquisitor.date %} ({{ acquisitor.date }}){% endif %}</li>
{% endfor %}
Expand All @@ -199,7 +198,7 @@ <h2 class="tna-heading-l">Description and record details</h2>
{% endif %}
{% if data.arrangement %}
<dt>Arrangement</dt>
<dd>{{ data.arrangement | safe }}</dd>
<dd>{{ data.arrangement | replace_ext_ref | safe }}</dd>
{% endif %}
{% if data.physical_description %}
<dt>Physical description</dt>
Expand Down
39 changes: 39 additions & 0 deletions src/styles/catalogue.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,42 @@
.etna-address {
font-style: normal;
}

.etna-record-details {
dd .tna-ul--plain li + li {
margin-top: 0.5rem;
}

dd p .list .item {
margin-left: 2rem;

display: block;

position: relative;

&::before {
padding-right: 0.5rem;
position: absolute;
top: 0;
right: 100%;

content: "";
}
}

.emph-italic {
font-style: italic;
}

.bioghist {
display: block;

&:not(:first-child) {
margin-top: 1rem;
}
}

span + p {
margin-top: 1rem;
}
}
1 change: 1 addition & 0 deletions src/styles/modules/dev/_record-details.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
}

.etna-record-hierarchy {
width: calc(100% - 12rem);
margin-top: 1rem;
padding-left: 14rem;

Expand Down

0 comments on commit 661a5a0

Please sign in to comment.