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
This commit is contained in:
Tim Bannister 2024-05-14 02:39:28 +01:00
parent 7b054e8a8a
commit 3ab2d3aeb4
No known key found for this signature in database
GPG Key ID: 31BA93F2DB289EFE
6 changed files with 80 additions and 28 deletions

View File

@ -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;

View File

@ -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"

View File

@ -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

View File

@ -18,7 +18,9 @@
{{ $eolRelease.finalPatchRelease }}
</td>
<td>
{{ $eolRelease.endOfLifeDate }}
{{- with $eolRelease.endOfLifeDate -}}
<time title="{{ time.Format ":date_long" . }}" datetime={{ time.Format "2006-01-02" . }}>{{ time.Format ( T "release_date_format" ) . }}</time>
{{- end -}}
</td>
<td lang="en-US">
{{ $eolRelease.note | markdownify }}

View File

@ -4,23 +4,41 @@
<h3 id="{{ $dataIdVersion }}">{{ $version }}</h3>
<p>
{{- 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 -}}
</p>
<p>
{{ $releaseInfo.next.note | markdownify }}
</p>
<p>
{{ printf (T "release_info_eol")
{{- $maintenance_mode_start_date :=
( printf "<time datetime=%s title=\"%s\">%s</time>"
(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 datetime=%s title=\"%s\">%s</time>"
(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 -}}
<!-- use legacy localization approach -->
{{- printf (T "release_info_eol")
$version
( printf "<time datetime=%s>%s</time>"
(time.Format "2006-01-02" $releaseInfo.maintenanceModeStartDate)
(time.Format ( T "release_date_format") $releaseInfo.maintenanceModeStartDate)
)
( printf "<time datetime=%s>%s</time>"
(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 -}}
</date>
</p>
{{ if $releaseInfo.previousPatches }}
<div>
@ -39,11 +57,21 @@
<td>
{{ $patchReleaseInfo.release }}
</td>
{{- with $patchReleaseInfo.cherryPickDeadline -}}
<td>
{{ $patchReleaseInfo.cherryPickDeadline }}
<time title="{{ time.Format ":date_full" . }}" datetime={{ time.Format "2006-01-02" . }}>{{ time.Format ( T "release_date_format" ) . }}</time>
</td>
{{- else -}}
<td class="value-not-applicable">-</td>
{{- end -}}
{{- with $patchReleaseInfo.targetDate -}}
<td>
{{ $patchReleaseInfo.targetDate }}
<time title="{{ time.Format ":date_full" . }}" datetime={{ time.Format "2006-01-02" .}}>{{ time.Format ( T "release_date_format") . }}</time>
</time>
</td>
{{- else -}}
<td class="value-not-applicable">-</td>
{{- end -}}
</td>
<td lang="en-US">
{{ $patchReleaseInfo.note | markdownify }}

View File

@ -12,13 +12,21 @@
.Site.Data.releases.schedule.upcoming_releases }}
<tr>
<td>
{{ time.Format ( T "release_date_format_month") $patchReleaseInfo.targetDate }}
{{- with $patchReleaseInfo.targetDate -}}
{{ time.Format ( T "release_date_format_month" ) . }}
{{- end -}}
</td>
{{- with $patchReleaseInfo.cherryPickDeadline -}}
<td>
{{ time.Format ( T "release_date_format") $patchReleaseInfo.cherryPickDeadline }}
<time title="{{ time.Format ":date_full" . }}" datetime={{ time.Format "2006-01-02" . }}>{{ time.Format ":date_medium" . }}</time>
</td>
{{- else -}}
<td class="value-not-applicable">-</td>
{{- end -}}
<td>
{{ time.Format ( T "release_date_format") $patchReleaseInfo.targetDate }}
{{- with $patchReleaseInfo.targetDate -}}
<time title="{{ time.Format ":date_full" . }}" datetime={{ time.Format "2006-01-02" . }}>{{ time.Format ":date_medium" . }}</time>
{{- end -}}
</td>
</tr>
{{ end }}