mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-07-12 21:05:19 +02:00
4e98909f11
* Add GitHub Releases modal to backoffice
Shows release notes (fetched from the GitHub API, cached for an hour,
Markdown rendered via league/commonmark) from a top-right nav button
available whether logged in or out, with the current version shown in
the modal header. Also clears cache.app on container start so the
release cache can't carry stale data across redeploys of the
var/ Docker volume.
* Render release notes markdown via twig/markdown-extra instead of manual CommonMark
twig/extra-bundle already wires the markdown filter to league/commonmark
automatically once twig/markdown-extra is installed, so the service no
longer needs to instantiate and call CommonMarkConverter itself.
* Explicitly disallow unsafe link protocols in rendered markdown
twig/extra-bundle's default (allow_unsafe_links: true) permits
javascript:/vbscript:/file:/data: URLs in rendered links, kept for
backwards compatibility. Disable it explicitly since we now render
release note markdown through this filter.
* Autolink bare URLs in rendered release notes
The Twig CommonMark converter only registers CommonMarkCoreExtension by
default, which doesn't turn bare URLs into clickable links (unlike
GitHub's own renderer). Register CommonMark's AutolinkExtension via the
twig.markdown.league_extension tag so PR/compare URLs in release notes
render as actual hyperlinks instead of plain text.
* Address review feedback on GitHubReleasesService and tests
- Extract the cache callback into a named fetchReleases() method instead
of an inline closure with all the fetch/parse logic.
- Simplify the User-Agent header to just "TijdVoorDeTest".
- Add a 5s HTTP timeout so a slow GitHub API can't block the request.
- Cache HTTP failures for only 60s instead of the full hour, so a brief
GitHub outage doesn't suppress releases for as long.
- Replace deprecated word-wrap with overflow-wrap in release-notes CSS.
- Extract duplicated mock setup in ReleasesControllerTest into a helper.
- Reword the "could not load" translation ("Kan" instead of "Kon").
* Address second round of CodeRabbit feedback
- Escape raw HTML embedded in release-note markdown instead of passing
it through, via twig_extra.commonmark.html_input: escape.
- Don't cache GitHub API failures at all (set $save = false in the
cache callback) instead of caching them for a short TTL, so the very
next request retries immediately.
- Sort releases by published_at descending before mapping, so the
first entry (used for the current-version badge and default-expanded
accordion item) is guaranteed to be the newest regardless of the
order GitHub's API happens to return.
41 lines
2.1 KiB
Twig
41 lines
2.1 KiB
Twig
<turbo-frame id="releases-modal-frame">
|
|
<div class="modal-header">
|
|
<h1 class="modal-title fs-5" id="releasesModalLabel">
|
|
{{ 'Releases'|trans }}
|
|
{% if releases[0] is defined %}
|
|
<span class="text-muted fs-6 ms-2">{{ 'Current version'|trans }}: {{ releases[0].tagName }}</span>
|
|
{% endif %}
|
|
</h1>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
{% if releases is empty %}
|
|
<p class="text-muted mb-0">{{ 'Could not load releases from GitHub.'|trans }}</p>
|
|
{% else %}
|
|
<div class="accordion" id="releasesAccordion">
|
|
{% for release in releases %}
|
|
<div class="accordion-item">
|
|
<h2 class="accordion-header">
|
|
<button class="accordion-button{% if not loop.first %} collapsed{% endif %}" type="button"
|
|
data-bs-toggle="collapse" data-bs-target="#release-{{ loop.index }}">
|
|
{{ release.name }}
|
|
{% if release.publishedAt %}
|
|
<span class="text-muted ms-2 small">{{ release.publishedAt|date('d-m-Y') }}</span>
|
|
{% endif %}
|
|
</button>
|
|
</h2>
|
|
<div id="release-{{ loop.index }}"
|
|
class="accordion-collapse collapse{% if loop.first %} show{% endif %}"
|
|
data-bs-parent="#releasesAccordion">
|
|
<div class="accordion-body">
|
|
<div class="release-notes">{{ release.body|markdown_to_html }}</div>
|
|
<a href="{{ release.url }}" target="_blank" rel="noopener noreferrer" class="small">{{ 'View on GitHub'|trans }}</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</turbo-frame>
|