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 */ /* Emphasize first paragraph of running text on site front page */
body.td-home main[role="main"] > section:first-of-type .content p:first-child { body.td-home main[role="main"] > section:first-of-type .content p:first-child {
line-height: 1.3em; line-height: 1.3em;

View File

@ -532,10 +532,13 @@ other = ")"
other = "(released: " other = "(released: "
# See https://gohugo.io/functions/format/#gos-layout-string # 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] [release_date_format]
# example: other = ":date_medium"
other = "2006-01-02" other = "2006-01-02"
# See https://gohugo.io/functions/format/#gos-layout-string
# Use a suitable format for your locale.
[release_date_format_month] [release_date_format_month]
other = "January 2006" other = "January 2006"
@ -545,6 +548,17 @@ other = "Cherry Pick Deadline"
[release_end_of_life_date] [release_end_of_life_date]
other = "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] [release_full_details_initial_text]
other = "Complete" other = "Complete"
@ -557,16 +571,13 @@ other = "Minor Version"
[release_info_next_patch] [release_info_next_patch]
other = "Next patch release is **%s**." other = "Next patch release is **%s**."
# Localization note: You can use Markdown here.
# The three placeholders (in order) are: # Deprecated. Set release_maintenance_and_end_of_life_details_current
# Kubernetes minor version # and release_maintenance_and_end_of_life_details_past instead.
# maintenance mode date # OK to remove once all localizations have switched to the new strings.
# 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.
[release_info_eol] [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] [release_note]
other = "Note" other = "Note"

View File

@ -128,8 +128,7 @@ schedules:
- cherryPickDeadline: "2023-09-08" - cherryPickDeadline: "2023-09-08"
release: 1.28.2 release: 1.28.2
targetDate: "2023-09-13" 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 release: 1.28.1
targetDate: "2023-08-23" targetDate: "2023-08-23"
- release: 1.28.0 - release: 1.28.0

View File

@ -18,7 +18,9 @@
{{ $eolRelease.finalPatchRelease }} {{ $eolRelease.finalPatchRelease }}
</td> </td>
<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>
<td lang="en-US"> <td lang="en-US">
{{ $eolRelease.note | markdownify }} {{ $eolRelease.note | markdownify }}

View File

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

View File

@ -12,13 +12,21 @@
.Site.Data.releases.schedule.upcoming_releases }} .Site.Data.releases.schedule.upcoming_releases }}
<tr> <tr>
<td> <td>
{{ time.Format ( T "release_date_format_month") $patchReleaseInfo.targetDate }} {{- with $patchReleaseInfo.targetDate -}}
{{ time.Format ( T "release_date_format_month" ) . }}
{{- end -}}
</td> </td>
{{- with $patchReleaseInfo.cherryPickDeadline -}}
<td> <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> </td>
{{- else -}}
<td class="value-not-applicable">-</td>
{{- end -}}
<td> <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> </td>
</tr> </tr>
{{ end }} {{ end }}