From 16567e29605b534c084f80d842a930857bff99ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Re=CC=81mi=20Be=CC=81tin?= Date: Tue, 24 Sep 2024 01:07:28 +0200 Subject: [PATCH] Support last_updated and last_reviewed dates in footer --- _components/document-notes/document-notes.css | 6 + _components/footer.md | 35 +++-- _includes/footer.html | 140 ++++++++++++------ _includes/t-status.html | 6 +- _includes/translation-note-msg.html | 81 +++++----- assets/css/style.css | 2 +- assets/css/style.css.map | 2 +- content/example-changelog.md | 24 +++ 8 files changed, 188 insertions(+), 108 deletions(-) create mode 100755 content/example-changelog.md diff --git a/_components/document-notes/document-notes.css b/_components/document-notes/document-notes.css index c96ac5a..c71d6c8 100644 --- a/_components/document-notes/document-notes.css +++ b/_components/document-notes/document-notes.css @@ -54,6 +54,7 @@ } .doc-note-translation { + border: 2px solid var(--wai-green); font-size: .8125rem; & p { margin-block-start: 5px; @@ -65,4 +66,9 @@ margin-block-end: 0; } } + & .translation-needs-update { + background-color: var(--gold-light); + padding: 8px; + margin: 0 -8px -8px -8px; + } } \ No newline at end of file diff --git a/_components/footer.md b/_components/footer.md index ca137a1..eb78154 100644 --- a/_components/footer.md +++ b/_components/footer.md @@ -1,25 +1,31 @@ --- title: "Footers (Page and Site)" lang: en -# translators: # Uncomment (remove #) for translations, one - name line per translator. -# - name: Translator 1 -# - name: Translator 2 -# contributors: -# - name: Contributor 1 -# - name: Contributor 2 -footer: > # Text in footer in HTML -

This is the text in the footer

-inline_css: | +custom_changelog: /writing/changelogs/example/ +last_updated: 2024-09-24 --- ***Note:** This is only a visual design reference. [The content is defined in the frontmatter](/writing/frontmatter/#footer-).* ## Page Footer +### With last updated date + + + +### With a more recent date of review + @@ -33,14 +39,15 @@ inline_css: |
-

Copyright © 2019 W3C ® (MIT, ERCIM, Keio, Beihang) Permission to Use WAI Material.

+

Copyright © {{ 'now' | date: "%Y" }} World Wide Web Consortium (W3C®). See Permission to Use WAI Material.

diff --git a/_includes/footer.html b/_includes/footer.html index e277f0f..2a6a0b7 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -1,62 +1,68 @@ -{%- assign col = site.collections | where: "label", page.collection | first -%} -{%- if page.changelog -%} - {%- assign changelogpage=site.documents | where:"ref", page.changelog | first -%} - {%- unless changelogpage.ref -%} - {%- assign changelogpage=site.pages | where:"ref", page.changelog | first -%} - {%- endunless -%} - {% assign changelogpageurl = changelogpage.url | relative_url %} - {%- capture changelogtext -%} - {%- include_cached t.html t="Changelog" lang=page.lang -%} +{%- comment -%} + Find the page language. +{%- endcomment -%} +{%- assign page_lang = 'en' -%} +{%- if page.lang -%} + {%- assign page_lang = page.lang -%} +{%- endif -%} +{%- comment -%} + Get the changelog page: + - Use the `custom_changelog` value when existing. Also supports the legacy `changelog` frontmatter variable for now. + - Else, append "changelog/` to the page `ref` or `url` to check if it matches a page. +{%- endcomment -%} +{%- if page.custom_changelog -%} + {%- assign changelog_url = page.custom_changelog -%} +{%- elsif page.changelog -%} + {%- assign changelog_url = page.changelog -%} +{%- elsif page.ref -%} + {%- assign changelog_url = page.ref | append: "changelog/" -%} +{%- else -%} + {%- assign changelog_url = page.url | append: "changelog/" -%} +{%- endif -%} +{%- assign all_docs = site.documents | concat: site.pages -%} +{%- assign changelog_page = all_docs | where: "url", changelog_url | first -%} +{%- comment -%} + Build the link to the Changelog +{%- endcomment -%} +{%- if changelog_page -%} + {%- capture changelog -%} + {%- include_cached t.html t="Latest changes" lang=page_lang -%} {%- endcapture -%} - {%- assign changelog = '' | append: changelogtext | append: '' -%} {%- else -%} {%- assign changelog = "" -%} {%- endif -%} +{%- comment -%} + Build the link to the Acknowledgements page +{%- endcomment -%} {%- if page.acknowledgements -%} - {%- assign acknowledgementspage=site.documents | where:"ref", page.acknowledgements | first -%} - {%- unless acknowledgementspage.ref -%} - {%- assign acknowledgementspage=site.pages | where:"ref", page.acknowledgements | first -%} - {%- endunless -%} - {% assign acknowledgementspageurl = acknowledgementspage.url | relative_url %} - {%- capture acknowledgementstext -%} - {%- include_cached t.html t="Acknowledgements" lang=page.lang -%} + {%- assign acknowledgements_page = all_docs | where:"ref", page.acknowledgements | first -%} + {%- capture acknowledgements -%} + {%- include_cached t.html t="Acknowledgements" lang=page_lang -%} {%- endcapture -%} - {%- assign acknowledgements = '' | append: acknowledgementstext | append: '' -%} {%- else -%} {%- assign acknowledgements = "" -%} {%- endif -%} -{% if col.footer %} +{%- comment -%} + COLLECTION PAGE FOOTER + For collections, we use the collection footer when set. +{%- endcomment -%} +{%- assign col = site.collections | where: "label", page.collection | first -%} +{%- if col.footer -%} -{% else %} - {% if page.footer %} -
-
- {{ page.footer | replace: "CHANGELOG", changelog | replace: "ACKNOWLEDGEMENTS", acknowledgements }} - {%- if page.license == 'creative-commons' -%}

{% include_cached icon.html name="creative-commons" %} This work is licensed under a Creative Commons Attribution 4.0 International License.

{%- endif -%} -
-
- {% endif %} -{% endif %} - -{% comment %} - +{%- comment -%} META FOOTER - - For the tutorials, we used data to form the footer. This way of constructing the footer is now called “metafooter” and needs to be enabled by setting `metafooter: true` in the frontmatter. Do NOT use with raw html `footer: ` frontmatter. - -{% endcomment %} -{% if page.metafooter %} + For the tutorials, we use multiple frontmatter variables to form the page footer. This way of constructing the footer is called “metafooter” and needs to be enabled by setting `metafooter: true` in the frontmatter. + Do NOT use with raw html `footer: ` frontmatter. +{%- endcomment -%} +{%- elsif page.metafooter -%}
Status: @@ -91,7 +97,6 @@ {% endfor %}   {% if page.update_editors %} - {% include t.html t='Update Editor:' %} {% for updateeditor in page.update_editors %} {% if forloop.first %}
-{% endif %} +{%- comment -%} + DEFAULT PAGE FOOTER + Most pages use this page footer. +{%- endcomment -%} +{%- else -%} + {%- comment -%} + Convert dates into integers to compare them later. + {%- endcomment -%} + {%- assign last_updated = page.last_updated | date: '%s' | plus: 0 | default: 0 -%} + {%- assign last_reviewed = page.last_reviewed | date: '%s' | plus: 0 | default: 0 -%} + {% if page.footer or page.last_updated or page.last_reviewed %} +
+
+ {%- if page.last_updated or page.last_reviewed -%} +

+ {%- if last_updated >= last_reviewed -%} + {%- if page_lang == "en" %}{%- include_cached t.html t="Updated:" lang=page.lang %} {{ page.last_updated | date: '%e %B %Y' }}. + {%- elsif page_lang != "en" -%}{%- include_cached t.html t="English version updated:" lang=page.lang %} {{ page.last_updated | date: '%Y-%m-%d' }}. + {%- endif -%} + {%- elsif last_reviewed > last_updated -%} + {%- if page_lang == "en" -%}{%- include_cached t.html t="This page has been reviewed and is current as of" lang=page.lang %} {{ page.last_reviewed | date: '%e %B %Y' }}. + {%- endif -%} + {%- endif -%} + {%- if changelog_page %} + {{ changelog }}. + {%- endif -%} + {%- if page_lang != 'en' and page.translation.last_updated %} + ({%- include_cached t.html t="Translated:" lang=page.lang %} {{ page.translation.last_updated | date: '%Y-%m-%d' }}). + {%- endif -%} + {%- if page.first_published %} + {{ page.first_published }} + {%- endif -%} +

+ {%- endif -%} + {%- comment -%} + For now, we continue to support replacing "CHANGELOG" with the changelog link. But that should soon be removed. + {%- endcomment -%} + {%- if page.footer -%} + {{ page.footer | replace: "CHANGELOG", changelog | replace: "ACKNOWLEDGEMENTS", acknowledgements }} + {%- endif -%} + {%- if page.license == 'creative-commons' -%}

{% include_cached icon.html name="creative-commons" %} This work is licensed under a Creative Commons Attribution 4.0 International License.

{%- endif -%} +
+
+ {% endif %} +{%- endif -%}