From 3ab2d3aeb433f2ff7a355dc9cc7167f7dd367c86 Mon Sep 17 00:00:00 2001 From: Tim Bannister Date: Tue, 14 May 2024 02:39:28 +0100 Subject: [PATCH] Tweak date formats in patch releases page - Use Hugo's built-in support for localizing dates - Allow customizing date formats separately - Make more dates machine readable - Add a tooltip for dates --- assets/scss/_custom.scss | 4 ++ data/i18n/en/en.toml | 31 +++++++++----- data/releases/schedule.yaml | 3 +- layouts/shortcodes/eol-releases.html | 4 +- layouts/shortcodes/release-branches.html | 52 +++++++++++++++++------ layouts/shortcodes/upcoming-releases.html | 14 ++++-- 6 files changed, 80 insertions(+), 28 deletions(-) diff --git a/assets/scss/_custom.scss b/assets/scss/_custom.scss index 6c93361e52..8aab4ad0dd 100644 --- a/assets/scss/_custom.scss +++ b/assets/scss/_custom.scss @@ -75,6 +75,10 @@ body { } } +table td.value-not-applicable { + text-align: center; +} + /* Emphasize first paragraph of running text on site front page */ body.td-home main[role="main"] > section:first-of-type .content p:first-child { line-height: 1.3em; diff --git a/data/i18n/en/en.toml b/data/i18n/en/en.toml index 0029e53b5e..7ae3d4b46f 100644 --- a/data/i18n/en/en.toml +++ b/data/i18n/en/en.toml @@ -532,10 +532,13 @@ other = ")" other = "(released: " # See https://gohugo.io/functions/format/#gos-layout-string -# Use a suitable format for your locale +# Use a suitable format for your locale. Avoid using :date_short [release_date_format] +# example: other = ":date_medium" other = "2006-01-02" +# See https://gohugo.io/functions/format/#gos-layout-string +# Use a suitable format for your locale. [release_date_format_month] other = "January 2006" @@ -545,6 +548,17 @@ other = "Cherry Pick Deadline" [release_end_of_life_date] other = "End Of Life Date" +# Also see release_maintenance_and_end_of_life_details_past +[release_maintenance_and_end_of_life_details_current] +other = "Kubernetes {{ .minor_version }} enters maintenance mode on {{ .maintenance_mode_start_date }}; the End of Life date for Kubernetes {{ .minor_version }} is {{ .release_eol_date }}." + +# Used if the maintenance mode date is in the past, otherwise +# see release_maintenance_and_end_of_life_details_current +[release_maintenance_and_end_of_life_details_past] +other = """ℹ️ **Kubernetes {{ .minor_version }} entered maintenance mode on {{ .maintenance_mode_start_date }}**. + +The End of Life date for Kubernetes {{ .minor_version }} is {{ .release_eol_date }}.""" + [release_full_details_initial_text] other = "Complete" @@ -557,16 +571,13 @@ other = "Minor Version" [release_info_next_patch] other = "Next patch release is **%s**." -# Localization note: You can use Markdown here. -# The three placeholders (in order) are: -# Kubernetes minor version -# maintenance mode date -# end of life date -# -# Keep this order. It is OK to use more than one sentence, and it's also OK to change the -# tense of the text so long as the meaning is clear. + +# Deprecated. Set release_maintenance_and_end_of_life_details_current +# and release_maintenance_and_end_of_life_details_past instead. +# OK to remove once all localizations have switched to the new strings. [release_info_eol] -other = "**%s** enters maintenance mode on **%s** and End of Life is on **%s**." +# Set this to "" if your localization implements the new strings. +other = "" [release_note] other = "Note" diff --git a/data/releases/schedule.yaml b/data/releases/schedule.yaml index 074557597b..c7f2841206 100644 --- a/data/releases/schedule.yaml +++ b/data/releases/schedule.yaml @@ -128,8 +128,7 @@ schedules: - cherryPickDeadline: "2023-09-08" release: 1.28.2 targetDate: "2023-09-13" - - cherryPickDeadline: N/A - note: Unplanned release to include CVE fixes + - note: Unplanned release to include CVE fixes release: 1.28.1 targetDate: "2023-08-23" - release: 1.28.0 diff --git a/layouts/shortcodes/eol-releases.html b/layouts/shortcodes/eol-releases.html index c349751bef..046f79a022 100644 --- a/layouts/shortcodes/eol-releases.html +++ b/layouts/shortcodes/eol-releases.html @@ -18,7 +18,9 @@ {{ $eolRelease.finalPatchRelease }} - {{ $eolRelease.endOfLifeDate }} + {{- with $eolRelease.endOfLifeDate -}} + + {{- end -}} {{ $eolRelease.note | markdownify }} diff --git a/layouts/shortcodes/release-branches.html b/layouts/shortcodes/release-branches.html index 0ee1617c47..30880f7dd0 100644 --- a/layouts/shortcodes/release-branches.html +++ b/layouts/shortcodes/release-branches.html @@ -4,23 +4,41 @@

{{ $version }}

+ {{- if gt (time.Format "2006-01-02" $releaseInfo.maintenanceModeStartDate) (time.Format "2006-01-02" now) -}} {{ printf (T "release_info_next_patch") $releaseInfo.next.release | markdownify }} + {{- end -}}

{{ $releaseInfo.next.note | markdownify }}

- {{ printf (T "release_info_eol") + {{- $maintenance_mode_start_date := + ( printf "" + (time.Format "2006-01-02" $releaseInfo.maintenanceModeStartDate) + (time.Format ":date_full" $releaseInfo.maintenanceModeStartDate) + (time.Format ":date_medium" $releaseInfo.maintenanceModeStartDate) + ) | safeHTML -}} + {{- $release_eol_date := + ( printf "" + (time.Format "2006-01-02" $releaseInfo.endOfLifeDate) + (time.Format ":date_full" $releaseInfo.endOfLifeDate) + (time.Format ":date_medium" $releaseInfo.endOfLifeDate) + ) | safeHTML -}} + {{- if eq (T "release_info_eol") "" -}} + {{- if gt (time.Format "2006-01-02" $releaseInfo.maintenanceModeStartDate) (time.Format "2006-01-02" now) -}} + {{- T "release_maintenance_and_end_of_life_details_current" (dict "minor_version" $version "maintenance_mode_start_date" $maintenance_mode_start_date "release_eol_date" $release_eol_date ) | markdownify -}} + {{- else -}} + {{- T "release_maintenance_and_end_of_life_details_past" (dict "minor_version" $version "maintenance_mode_start_date" $maintenance_mode_start_date "release_eol_date" $release_eol_date ) | markdownify -}} + {{- end -}} + {{- else -}} + + {{- printf (T "release_info_eol") $version - ( printf "" - (time.Format "2006-01-02" $releaseInfo.maintenanceModeStartDate) - (time.Format ( T "release_date_format") $releaseInfo.maintenanceModeStartDate) - ) - ( printf "" - (time.Format "2006-01-02" $releaseInfo.endOfLifeDate) - (time.Format ( T "release_date_format") $releaseInfo.endOfLifeDate) - ) - | safeHTML | markdownify }} + $maintenance_mode_start_date + $release_eol_date + | markdownify -}} + {{- end -}} +

{{ if $releaseInfo.previousPatches }}
@@ -39,11 +57,21 @@ {{ $patchReleaseInfo.release }} + {{- with $patchReleaseInfo.cherryPickDeadline -}} - {{ $patchReleaseInfo.cherryPickDeadline }} + + {{- else -}} + - + {{- end -}} + {{- with $patchReleaseInfo.targetDate -}} - {{ $patchReleaseInfo.targetDate }} + + + + {{- else -}} + - + {{- end -}} {{ $patchReleaseInfo.note | markdownify }} diff --git a/layouts/shortcodes/upcoming-releases.html b/layouts/shortcodes/upcoming-releases.html index 67e87cabb9..20d5c9ccfc 100644 --- a/layouts/shortcodes/upcoming-releases.html +++ b/layouts/shortcodes/upcoming-releases.html @@ -12,13 +12,21 @@ .Site.Data.releases.schedule.upcoming_releases }} - {{ time.Format ( T "release_date_format_month") $patchReleaseInfo.targetDate }} + {{- with $patchReleaseInfo.targetDate -}} + {{ time.Format ( T "release_date_format_month" ) . }} + {{- end -}} + {{- with $patchReleaseInfo.cherryPickDeadline -}} - {{ time.Format ( T "release_date_format") $patchReleaseInfo.cherryPickDeadline }} + + {{- else -}} + - + {{- end -}} - {{ time.Format ( T "release_date_format") $patchReleaseInfo.targetDate }} + {{- with $patchReleaseInfo.targetDate -}} + + {{- end -}} {{ end }}