Skip to content

Commit 3ab2d3a

Browse files
author
Tim Bannister
committed
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
1 parent 7b054e8 commit 3ab2d3a

File tree

6 files changed

+80
-28
lines changed

6 files changed

+80
-28
lines changed

assets/scss/_custom.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ body {
7575
}
7676
}
7777

78+
table td.value-not-applicable {
79+
text-align: center;
80+
}
81+
7882
/* Emphasize first paragraph of running text on site front page */
7983
body.td-home main[role="main"] > section:first-of-type .content p:first-child {
8084
line-height: 1.3em;

data/i18n/en/en.toml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,13 @@ other = ")"
532532
other = "(released: "
533533

534534
# See https://gohugo.io/functions/format/#gos-layout-string
535-
# Use a suitable format for your locale
535+
# Use a suitable format for your locale. Avoid using :date_short
536536
[release_date_format]
537+
# example: other = ":date_medium"
537538
other = "2006-01-02"
538539

540+
# See https://gohugo.io/functions/format/#gos-layout-string
541+
# Use a suitable format for your locale.
539542
[release_date_format_month]
540543
other = "January 2006"
541544

@@ -545,6 +548,17 @@ other = "Cherry Pick Deadline"
545548
[release_end_of_life_date]
546549
other = "End Of Life Date"
547550

551+
# Also see release_maintenance_and_end_of_life_details_past
552+
[release_maintenance_and_end_of_life_details_current]
553+
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 }}."
554+
555+
# Used if the maintenance mode date is in the past, otherwise
556+
# see release_maintenance_and_end_of_life_details_current
557+
[release_maintenance_and_end_of_life_details_past]
558+
other = """ℹ️ **Kubernetes {{ .minor_version }} entered maintenance mode on {{ .maintenance_mode_start_date }}**.
559+
560+
The End of Life date for Kubernetes {{ .minor_version }} is {{ .release_eol_date }}."""
561+
548562
[release_full_details_initial_text]
549563
other = "Complete"
550564

@@ -557,16 +571,13 @@ other = "Minor Version"
557571
[release_info_next_patch]
558572
other = "Next patch release is **%s**."
559573

560-
# Localization note: You can use Markdown here.
561-
# The three placeholders (in order) are:
562-
# Kubernetes minor version
563-
# maintenance mode date
564-
# end of life date
565-
#
566-
# Keep this order. It is OK to use more than one sentence, and it's also OK to change the
567-
# tense of the text so long as the meaning is clear.
574+
575+
# Deprecated. Set release_maintenance_and_end_of_life_details_current
576+
# and release_maintenance_and_end_of_life_details_past instead.
577+
# OK to remove once all localizations have switched to the new strings.
568578
[release_info_eol]
569-
other = "**%s** enters maintenance mode on **%s** and End of Life is on **%s**."
579+
# Set this to "" if your localization implements the new strings.
580+
other = ""
570581

571582
[release_note]
572583
other = "Note"

data/releases/schedule.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ schedules:
128128
- cherryPickDeadline: "2023-09-08"
129129
release: 1.28.2
130130
targetDate: "2023-09-13"
131-
- cherryPickDeadline: N/A
132-
note: Unplanned release to include CVE fixes
131+
- note: Unplanned release to include CVE fixes
133132
release: 1.28.1
134133
targetDate: "2023-08-23"
135134
- release: 1.28.0

layouts/shortcodes/eol-releases.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
{{ $eolRelease.finalPatchRelease }}
1919
</td>
2020
<td>
21-
{{ $eolRelease.endOfLifeDate }}
21+
{{- with $eolRelease.endOfLifeDate -}}
22+
<time title="{{ time.Format ":date_long" . }}" datetime={{ time.Format "2006-01-02" . }}>{{ time.Format ( T "release_date_format" ) . }}</time>
23+
{{- end -}}
2224
</td>
2325
<td lang="en-US">
2426
{{ $eolRelease.note | markdownify }}

layouts/shortcodes/release-branches.html

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,41 @@
44

55
<h3 id="{{ $dataIdVersion }}">{{ $version }}</h3>
66
<p>
7+
{{- if gt (time.Format "2006-01-02" $releaseInfo.maintenanceModeStartDate) (time.Format "2006-01-02" now) -}}
78
{{ printf (T "release_info_next_patch") $releaseInfo.next.release | markdownify }}
9+
{{- end -}}
810
</p>
911
<p>
1012
{{ $releaseInfo.next.note | markdownify }}
1113
</p>
1214
<p>
13-
{{ printf (T "release_info_eol")
15+
{{- $maintenance_mode_start_date :=
16+
( printf "<time datetime=%s title=\"%s\">%s</time>"
17+
(time.Format "2006-01-02" $releaseInfo.maintenanceModeStartDate)
18+
(time.Format ":date_full" $releaseInfo.maintenanceModeStartDate)
19+
(time.Format ":date_medium" $releaseInfo.maintenanceModeStartDate)
20+
) | safeHTML -}}
21+
{{- $release_eol_date :=
22+
( printf "<time datetime=%s title=\"%s\">%s</time>"
23+
(time.Format "2006-01-02" $releaseInfo.endOfLifeDate)
24+
(time.Format ":date_full" $releaseInfo.endOfLifeDate)
25+
(time.Format ":date_medium" $releaseInfo.endOfLifeDate)
26+
) | safeHTML -}}
27+
{{- if eq (T "release_info_eol") "" -}}
28+
{{- if gt (time.Format "2006-01-02" $releaseInfo.maintenanceModeStartDate) (time.Format "2006-01-02" now) -}}
29+
{{- 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 -}}
30+
{{- else -}}
31+
{{- 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 -}}
32+
{{- end -}}
33+
{{- else -}}
34+
<!-- use legacy localization approach -->
35+
{{- printf (T "release_info_eol")
1436
$version
15-
( printf "<time datetime=%s>%s</time>"
16-
(time.Format "2006-01-02" $releaseInfo.maintenanceModeStartDate)
17-
(time.Format ( T "release_date_format") $releaseInfo.maintenanceModeStartDate)
18-
)
19-
( printf "<time datetime=%s>%s</time>"
20-
(time.Format "2006-01-02" $releaseInfo.endOfLifeDate)
21-
(time.Format ( T "release_date_format") $releaseInfo.endOfLifeDate)
22-
)
23-
| safeHTML | markdownify }}
37+
$maintenance_mode_start_date
38+
$release_eol_date
39+
| markdownify -}}
40+
{{- end -}}
41+
</date>
2442
</p>
2543
{{ if $releaseInfo.previousPatches }}
2644
<div>
@@ -39,11 +57,21 @@ <h3 id="{{ $dataIdVersion }}">{{ $version }}</h3>
3957
<td>
4058
{{ $patchReleaseInfo.release }}
4159
</td>
60+
{{- with $patchReleaseInfo.cherryPickDeadline -}}
4261
<td>
43-
{{ $patchReleaseInfo.cherryPickDeadline }}
62+
<time title="{{ time.Format ":date_full" . }}" datetime={{ time.Format "2006-01-02" . }}>{{ time.Format ( T "release_date_format" ) . }}</time>
4463
</td>
64+
{{- else -}}
65+
<td class="value-not-applicable">-</td>
66+
{{- end -}}
67+
{{- with $patchReleaseInfo.targetDate -}}
4568
<td>
46-
{{ $patchReleaseInfo.targetDate }}
69+
<time title="{{ time.Format ":date_full" . }}" datetime={{ time.Format "2006-01-02" .}}>{{ time.Format ( T "release_date_format") . }}</time>
70+
</time>
71+
</td>
72+
{{- else -}}
73+
<td class="value-not-applicable">-</td>
74+
{{- end -}}
4775
</td>
4876
<td lang="en-US">
4977
{{ $patchReleaseInfo.note | markdownify }}

layouts/shortcodes/upcoming-releases.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,21 @@
1212
.Site.Data.releases.schedule.upcoming_releases }}
1313
<tr>
1414
<td>
15-
{{ time.Format ( T "release_date_format_month") $patchReleaseInfo.targetDate }}
15+
{{- with $patchReleaseInfo.targetDate -}}
16+
{{ time.Format ( T "release_date_format_month" ) . }}
17+
{{- end -}}
1618
</td>
19+
{{- with $patchReleaseInfo.cherryPickDeadline -}}
1720
<td>
18-
{{ time.Format ( T "release_date_format") $patchReleaseInfo.cherryPickDeadline }}
21+
<time title="{{ time.Format ":date_full" . }}" datetime={{ time.Format "2006-01-02" . }}>{{ time.Format ":date_medium" . }}</time>
1922
</td>
23+
{{- else -}}
24+
<td class="value-not-applicable">-</td>
25+
{{- end -}}
2026
<td>
21-
{{ time.Format ( T "release_date_format") $patchReleaseInfo.targetDate }}
27+
{{- with $patchReleaseInfo.targetDate -}}
28+
<time title="{{ time.Format ":date_full" . }}" datetime={{ time.Format "2006-01-02" . }}>{{ time.Format ":date_medium" . }}</time>
29+
{{- end -}}
2230
</td>
2331
</tr>
2432
{{ end }}

0 commit comments

Comments
 (0)