Skip to content

Commit

Permalink
Merge pull request #18 from nationalarchives/feature/exhibition-pages
Browse files Browse the repository at this point in the history
Exhibition pages
  • Loading branch information
ahosgood authored Dec 5, 2024
2 parents 3882123 + d40e3c6 commit 3395273
Show file tree
Hide file tree
Showing 14 changed files with 730 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ jobs:
latest: ${{ github.ref == 'refs/heads/main' }}
github-token: ${{ secrets.GITHUB_TOKEN }}
docker-image-name: ${{ vars.DOCKER_IMAGE_NAME }}
- name: Update version and push
if: github.ref == 'refs/heads/main'
run: |
git tag v${{ needs.version.outputs.version }} -m "Version ${{ needs.version.outputs.version }}"
git push origin --tags
update-ds-infrastructure-web:
runs-on: ubuntu-latest
Expand Down
7 changes: 5 additions & 2 deletions app/lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ def add_parameters(self, params):
self.params = self.params | params

def get(self, path="/"):
url = f"{self.api_url}/{path.lstrip(" / ")}"
url = f"{self.api_url}/{path.lstrip('/')}"
try:
response = requests.get(
url,
params=self.params,
headers={"Cache-Control": "no-cache"},
headers={
"Cache-Control": "no-cache",
"Accept": "application/json",
},
)
except ConnectionError:
current_app.logger.error(
Expand Down
30 changes: 17 additions & 13 deletions app/lib/context_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,38 @@ def get_date_from_string(s):
return None


def pretty_date_range(s_from, s_to):
def pretty_date_range(s_from, s_to, show_days=True):
date_from = get_date_from_string(s_from)
date_to = get_date_from_string(s_to)
if date_from and date_to:
date_to_string = date_to.strftime("%d %B %Y")
date_to_string = date_to.strftime("%d %B %Y" if show_days else "%B %Y")
if (
date_from.day == 1
and date_from.month == 1
and (
(date_to.day == 31 and date_to.month == 12)
or (date_to.day == 1 and date_to.month == 1)
)
and date_to.day == 31
and date_to.month == 12
):
if date_from.year == date_to.year:
return date_from.year
return str(date_from.year)
return f"{date_from.year}{date_to.year}"
if date_from.year == date_to.year:
if date_from.month == date_to.month:
if date_from.day == date_to.day:
return date_from.strftime("%d %B %Y")
else:
return date_from.strftime(
"%d %B %Y" if show_days else "%B %Y"
)
elif show_days:
return f"{date_from.strftime('%d')}{date_to_string}"
else:
return date_to_string
else:
return f"{date_from.strftime('%d %B')} to {date_to_string}"
return f"{date_from.strftime('%d %B' if show_days else "%B")} to {date_to_string}"
else:
return f"{date_from.strftime('%d %B %Y')} to {date_to_string}"
return f"{date_from.strftime('%d %B %Y' if show_days else "%B %Y")} to {date_to_string}"
if date_from:
return f"From {date_from.strftime('%d %B %Y')}"
return (
f"From {date_from.strftime('%d %B %Y' if show_days else "%B %Y")}"
)
if date_to:
return f"To {date_to.strftime('%d %B %Y')}"
return f"To {date_to.strftime('%d %B %Y' if show_days else "%B %Y")}"
return f"{s_from}{s_to}"
4 changes: 2 additions & 2 deletions app/templates/macros/wagtail_blocks/media.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</div>
</div>
<audio id="{{ id }}" class="etna-audio video-js" controls{%- if block_value.media.transcript %} aria-label="Transcript provided below"{%- endif %}>
<source itemprop="contentUrl" src="{{ block_value.media.full_url }}" type="{{ block_value.media.mime }}" itemprop="contentUrl">
<source src="{{ block_value.media.full_url }}" type="{{ block_value.media.mime }}" itemprop="contentUrl">
<p>Your browser doesn't support HTML5 audio. <a href="{{ block_value.media.full_url }}">Download the audio file</a>.</p>
</audio>
<meta itemprop="encodingFormat" content="{{ block_value.media.mime }}">
Expand All @@ -40,7 +40,7 @@
{{ block_value.media.description | tna_html | safe }}
</div>
<video id="{{ id }}" class="etna-video etna-video--selfhosted video-js vjs-16-9" controls{%- if block_value.media.transcript %} aria-label="Transcript provided below"{%- endif %}>
<source itemprop="contentUrl" src="{{ block_value.media.full_url }}" type="{{ block_value.media.mime }}" itemprop="contentUrl">
<source src="{{ block_value.media.full_url }}" type="{{ block_value.media.mime }}" itemprop="contentUrl">
{% if block_value.media.subtitles_file_full_url %}
<track kind="captions" src="{{ block_value.media.subtitles_file_full_url }}" srclang="en" label="English" default>
{% endif %}
Expand Down
Loading

0 comments on commit 3395273

Please sign in to comment.