Skip to content

Commit

Permalink
Merge branch 'main' into feature/record-serialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood authored Sep 10, 2024
2 parents 8a5605c + 49c1a65 commit a30f724
Show file tree
Hide file tree
Showing 57 changed files with 1,402 additions and 1,552 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ RUN mkdir /app/app/static/assets; \
cp -r /app/node_modules/@nationalarchives/frontend/nationalarchives/assets/* /app/app/static/assets; \
cp -r /app/node_modules/plyr/dist/plyr.svg /app/app/static/assets/images

# Delete source files and tests
RUN rm -fR /app/src /app/test
# Delete source files, tests and docs
RUN rm -fR /app/src /app/test /app/docs

# Run the application
CMD ["tna-run", "etna:app"]
29 changes: 0 additions & 29 deletions Dockerfile.local

This file was deleted.

6 changes: 3 additions & 3 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ def apply_extra_headers(response):
]
)

app.add_template_filter(tna_html)
app.add_template_filter(slugify)
app.add_template_filter(pretty_date)
app.add_template_filter(headings_list)
app.add_template_filter(parse_json)
app.add_template_filter(pretty_date)
app.add_template_filter(sidebar_items_from_wagtail_body)
app.add_template_filter(slugify)
app.add_template_filter(tna_html)
app.add_template_filter(wagtail_streamfield_contains_media)
app.add_template_filter(wagtail_table_parser)

Expand Down
9 changes: 9 additions & 0 deletions app/lib/content_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ def replace_line_breaks(html):
return html


def replace_footnotes(html):
html = re.sub(
r'<footnote[^>]*id="([\w\d\-]+)"[^>]*>\s*\[([\w\d]+)\]\s*</footnote>',
r'<sup data-footnoteid="\g<1>"><a href="#footnote-\g<1>" class="tna-footnote" title="Footnote \g<2>">[\g<2>]</a></sup>',
html,
)
return html


def add_abbreviations(html):
for item in abbreviations:
html = re.sub(
Expand Down
15 changes: 12 additions & 3 deletions app/lib/template_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import urllib.parse
from datetime import datetime

from flask import url_for

from .content_parser import (
add_abbreviations,
b_to_strong,
lists_to_tna_lists,
replace_footnotes,
replace_line_breaks,
strip_wagtail_attributes,
)
Expand All @@ -19,6 +18,7 @@ def tna_html(s):
s = b_to_strong(s)
s = strip_wagtail_attributes(s)
s = replace_line_breaks(s)
s = replace_footnotes(s)
s = add_abbreviations(s)
return s

Expand Down Expand Up @@ -130,7 +130,9 @@ def wagtail_streamfield_contains_media(body):
return False


def sidebar_items_from_wagtail_body(body):
def sidebar_items_from_wagtail_body(content):
body = content["body"]
footnotes = content["footnotes"]
page_sections = []
page_children = []
page_grandchildren = []
Expand Down Expand Up @@ -205,6 +207,13 @@ def sidebar_items_from_wagtail_body(body):
+ item["id"],
}
)
if footnotes:
page_sections.append(
{
"text": "Footnotes",
"href": "#footnotes",
}
)
return page_sections or page_children


Expand Down
2 changes: 1 addition & 1 deletion app/main/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def browse():
return render_template("main/browse.html", global_alert=global_alerts())


@bp.route("/cookies/set/", methods=["POST"])
@bp.route("/help/cookies/set/", methods=["POST"])
def set_cookies():
current_cookies_policy = {
"usage": False,
Expand Down
1 change: 0 additions & 1 deletion app/static/main/people.css.map

This file was deleted.

22 changes: 11 additions & 11 deletions app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@
<link rel="preconnect" href="https://use.typekit.net">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!-- <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Open+Sans:[email protected]&family=Roboto+Mono:[email protected]&display=swap"> -->
<link rel="stylesheet" href="{{ url_for('static', filename='main.css', v=app_config.BUILD_VERSION) }}" media="screen,print">
<link rel="stylesheet" href="{{ url_for('static', filename='print.css', v=app_config.BUILD_VERSION) }}" media="print">
<link rel="stylesheet" href="https://use.typekit.net/kaq6qqh.css" media="screen,print">
<link rel="stylesheet" href="{{ url_for('static', filename='main.css') }}" media="screen,print">
<link rel="stylesheet" href="{{ url_for('static', filename='print.css') }}" media="print">
<link rel="stylesheet" href="{{ url_for('static', filename='font-awesome.css') }}" media="screen,print">
<link rel="stylesheet" href="{{ url_for('static', filename='ie.css') }}" media="all and (-ms-high-contrast: none), (-ms-high-contrast: active)">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Open+Sans:[email protected]&family=Roboto+Mono:[email protected]&display=swap" media="screen,print">
<link rel="stylesheet" href="{{ url_for('static', filename='font-awesome.css', v=app_config.BUILD_VERSION) }}" media="screen,print">
<link rel="stylesheet" href="{{ url_for('static', filename='ie.css', v=app_config.BUILD_VERSION) }}" media="all and (-ms-high-contrast: none), (-ms-high-contrast: active)">
<!-- <link rel="stylesheet" href="{{ url_for('static', filename='logo-versions.css') }}" media="screen"> -->
{% endblock %}

Expand All @@ -59,7 +59,7 @@
{%- if 'cookie_preferences_set' not in request.cookies or not request.cookies.get('cookie_preferences_set') %}
{{ tnaCookieBanner({
'serviceName': 'The National Archives',
'cookiesUrl': '/cookies/',
'cookiesUrl': '/help/cookies/',
'cookiesDomain': app_config.COOKIE_DOMAIN,
'policies': 'marketing'
}) | indent(6) }}
Expand Down Expand Up @@ -124,7 +124,7 @@
{% block beforeContent %}
{%- if breadcrumbs and breadcrumbs | length > 0 %}
<div class="tna-container">
<div class="tna-column tna-column--full">
<div class="tna-column tna-column--full tna-!--padding-vertical-s">
{{ tnaBreadcrumbs({
'items': breadcrumbs,
'structuredData': True
Expand Down Expand Up @@ -266,7 +266,7 @@
},
{
'text': 'Cookies',
'href': '/cookies/'
'href': '/help/cookies/'
}
],
'classes': 'tna-!--margin-top-l'
Expand All @@ -275,8 +275,8 @@

{% block bodyEnd %}
{%- if app_config.SENTRY_JS_ID and cookie_preference('usage') %}
<script src="{{ url_for('static', filename='sentry.min.js') }}" data-id="{{ app_config.SENTRY_JS_ID }}" data-samplerate="{{ app_config.SENTRY_SAMPLE_RATE }}" data-environment="{{ app_config.ENVIRONMENT }}" data-version="{{ app_config.BUILD_VERSION }}" defer></script>
<script src="{{ url_for('static', filename='sentry.min.js', v=app_config.BUILD_VERSION) }}" data-id="{{ app_config.SENTRY_JS_ID }}" data-samplerate="{{ app_config.SENTRY_SAMPLE_RATE }}" data-environment="{{ app_config.ENVIRONMENT }}" data-version="{{ app_config.BUILD_VERSION }}" defer></script>
{%- endif %}
<script src="{{ url_for('static', filename='main.min.js') }}" defer></script>
<script src="{{ url_for('static', filename='analytics.min.js') }}" defer></script>
<script src="{{ url_for('static', filename='main.min.js', v=app_config.BUILD_VERSION) }}" defer></script>
<script src="{{ url_for('static', filename='analytics.min.js', v=app_config.BUILD_VERSION) }}" defer></script>
{% endblock %}
2 changes: 1 addition & 1 deletion app/templates/blog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

{% block stylesheets %}
{{ super() }}
<link rel="stylesheet" href="{{ url_for('static', filename='blog.css') }}" media="screen,print">
<link rel="stylesheet" href="{{ url_for('static', filename='blog.css', v=app_config.BUILD_VERSION) }}" media="screen,print">
{% endblock %}

{% block content %}
Expand Down
8 changes: 4 additions & 4 deletions app/templates/blog/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

{% block stylesheets %}
{{ super() }}
<link rel="stylesheet" href="{{ url_for('static', filename='blog.css') }}" media="screen,print">
<link rel="stylesheet" href="{{ url_for('static', filename='blog.css', v=app_config.BUILD_VERSION) }}" media="screen,print">
{%- if bodyContainsMedia %}
<link rel="stylesheet" href="{{ url_for('static', filename='media.css') }}" media="screen,print">
<link rel="stylesheet" href="{{ url_for('static', filename='media.css', v=app_config.BUILD_VERSION) }}" media="screen,print">
{%- endif %}
{% endblock %}

Expand All @@ -44,7 +44,7 @@ <h1 class="tna-hgroup__title">{{ page_data.title }}</h1>
<div class="tna-section">
<div class="tna-container tna-container--centred">
<div class="tna-column tna-column--width-2-3 tna-column--width-5-6-medium tna-column--full-small tna-column--full-tiny etna-!--full-width-on-print">
{{ wagtail_body(page_data.body, 2) }}
{{ wagtail_body(page_data.body, 2, page_data.footnotes) }}
</div>
</div>
</div>
Expand All @@ -54,6 +54,6 @@ <h1 class="tna-hgroup__title">{{ page_data.title }}</h1>
{% block bodyEnd %}
{{ super() }}
{%- if bodyContainsMedia %}
<script src="{{ url_for('static', filename='media.min.js') }}" defer></script>
<script src="{{ url_for('static', filename='media.min.js', v=app_config.BUILD_VERSION) }}" defer></script>
{%- endif %}
{% endblock %}
109 changes: 0 additions & 109 deletions app/templates/components/search-filters/macro.html

This file was deleted.

14 changes: 7 additions & 7 deletions app/templates/explore-the-collection/article-focused.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@

{% block stylesheets %}
{{ super() }}
<link rel="stylesheet" href="{{ url_for('static', filename='article.css') }}" media="screen,print">
<link rel="stylesheet" href="{{ url_for('static', filename='article.css', v=app_config.BUILD_VERSION) }}" media="screen,print">
{%- if bodyContainsMedia %}
<link rel="stylesheet" href="{{ url_for('static', filename='media.css') }}" media="screen,print">
<link rel="stylesheet" href="{{ url_for('static', filename='media.css', v=app_config.BUILD_VERSION) }}" media="screen,print">
{%- endif %}
{% endblock %}

{% block beforeContent %}
{%- if breadcrumbs and breadcrumbs | length > 0 %}
<div class="tna-background-accent">
<div class="tna-container">
<div class="tna-column tna-column--full">
<div class="tna-column tna-column--full tna-!--padding-vertical-s">
{{ tnaBreadcrumbs({
'items': breadcrumbs,
'structuredData': True
Expand Down Expand Up @@ -65,7 +65,7 @@
'supertitle': page_data.type_label,
'title': page_data.title,
'imageSrc': page_data.hero_image.jpeg.full_url,
'imageAlt': page_data.hero_image.alt_text,
'imageAlt': page_data.hero_image.alt_text or '',
'imageWidth': page_data.hero_image.jpeg.width,
'imageHeight': page_data.hero_image.jpeg.height,
'imageCaption': hero_image_caption,
Expand Down Expand Up @@ -174,9 +174,9 @@ <h2 class="etna-author-list__heading tna-heading-s">Author{{ 's' if page_data.au

{% block bodyEnd %}
{{ super() }}
<script src="{{ url_for('static', filename='article.min.js') }}" defer></script>
<script src="{{ url_for('static', filename='sidebar.min.js') }}" defer></script>
<script src="{{ url_for('static', filename='article.min.js', v=app_config.BUILD_VERSION) }}" defer></script>
<script src="{{ url_for('static', filename='sidebar.min.js', v=app_config.BUILD_VERSION) }}" defer></script>
{%- if bodyContainsMedia %}
<script src="{{ url_for('static', filename='media.min.js') }}" defer></script>
<script src="{{ url_for('static', filename='media.min.js', v=app_config.BUILD_VERSION) }}" defer></script>
{%- endif %}
{% endblock %}
Loading

0 comments on commit a30f724

Please sign in to comment.