From 20d8b28e1bed1f018279ec8c6fb251814694a1e2 Mon Sep 17 00:00:00 2001 From: Tim Bannister Date: Tue, 22 Dec 2020 21:57:33 +0000 Subject: [PATCH 1/4] Implement announcements as data-driven content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change allows announcements to have an expiry date and / or a “do not show until” date. Separating this out also leaves room for future changes to enforce a set of approvers. Co-Authored-By: Karen Bradshaw --- data/announcements/scheduled.yaml | 31 +++++++++++++ layouts/partials/announcement.html | 46 ++++++++++++++------ layouts/partials/frontpage-announcement.html | 46 ++++++++++++++------ 3 files changed, 97 insertions(+), 26 deletions(-) create mode 100644 data/announcements/scheduled.yaml diff --git a/data/announcements/scheduled.yaml b/data/announcements/scheduled.yaml new file mode 100644 index 0000000000..b6e41d5c1d --- /dev/null +++ b/data/announcements/scheduled.yaml @@ -0,0 +1,31 @@ +--- +# For an example of the format, see commented structure below. +# +# 🛈 Changes require approval from @kubernetes/steering-committee + +# The order matters: if two schedules overlaps, the announcement +# that comes FIRST in the following list takes precedence. +# +#announcements: +# - startTime: 2020-01-01T00:00:00 +# # startTime is optional +# endTime: 2021-04-01T00:00:00 +# # endTime is required +# style: >- +# color: #fff; background: #000; +# # style is optional; if using, set both color and background +# # choose a dark color for the background +# title: "Sample 1 announcement" +# # title is optional +# message: | +# Message *one*. +# [Hyperlink](https://en.wikipedia.org/wiki/Hyperlink). +# # message is required. You can use Markdown. +# - name: Sample 2 +# startTime: 2020-01-01T00:00:00 +# endTime: 2021-04-01T00:00:00 +# message: | +# Message *two*. + +# leave the "announcements" key in place +announcements: diff --git a/layouts/partials/announcement.html b/layouts/partials/announcement.html index 2ec2e96e35..b1d68292db 100644 --- a/layouts/partials/announcement.html +++ b/layouts/partials/announcement.html @@ -1,14 +1,34 @@ -{{ if .Page.Param "announcement" }} -
- -
+{{ $dateRegExp := "^[0-9]{4}-1[0-2]|0[1-9]-(?:3[01]|0[1-9]|[12][0-9])T(?:2[0-3]|[01][0-9]):(?:[0-5][0-9]):(?:60|[0-5][0-9])$" }} +{{ $announcementShown := false }} +{{ range $.Site.Data.announcements }} + {{ range .announcements }} + {{ if or ( eq .endTime nil ) ( eq .message nil ) }} + {{ errorf "Invalid announcement: %#v" . }} + {{ end }} + {{ if and (ne .startTime nil ) (lt ( len ( findRE $dateRegExp .startTime ) ) 1 ) }} + {{ errorf "Invalid announcement start time: %#v" .startTime }} + {{ end }} + {{ if lt ( len ( findRE $dateRegExp .endTime ) ) 1 }} + {{ errorf "Invalid announcement end time: %#v" .endTime }} + {{ end }} + {{ if or (eq .startTime nil ) (lt ( time .startTime ) now ) }} + {{- if or (eq .endTime nil ) (gt ( time .endTime ) now ) -}} + {{- if not $announcementShown -}} + {{- $announcementShown = true -}} +
+ +
+ {{- end -}} + {{- end -}} + {{- end -}} + {{ end }} {{ end }} \ No newline at end of file diff --git a/layouts/partials/frontpage-announcement.html b/layouts/partials/frontpage-announcement.html index 5dce29e035..e70a387301 100644 --- a/layouts/partials/frontpage-announcement.html +++ b/layouts/partials/frontpage-announcement.html @@ -1,14 +1,34 @@ -{{ if .Page.Param "announcement" }} -
- -
+{{ $dateRegExp := "^[0-9]{4}-1[0-2]|0[1-9]-(?:3[01]|0[1-9]|[12][0-9])T(?:2[0-3]|[01][0-9]):(?:[0-5][0-9]):(?:60|[0-5][0-9])$" }} +{{ $announcementShown := false }} +{{ range $.Site.Data.announcements }} + {{ range .announcements }} + {{ if or ( eq .endTime nil ) ( eq .message nil ) }} + {{ errorf "Invalid announcement: %#v" . }} + {{ end }} + {{ if and (ne .startTime nil ) (lt ( len ( findRE $dateRegExp .startTime ) ) 1 ) }} + {{ errorf "Invalid announcement start time: %#v" .startTime }} + {{ end }} + {{ if lt ( len ( findRE $dateRegExp .endTime ) ) 1 }} + {{ errorf "Invalid announcement end time: %#v" .endTime }} + {{ end }} + {{ if or (eq .startTime nil ) (lt ( time .startTime ) now ) }} + {{- if or (eq .endTime nil ) (gt ( time .endTime ) now ) -}} + {{- if not $announcementShown -}} + {{- $announcementShown = true -}} +
+ +
+ {{- end -}} + {{- end -}} + {{- end -}} + {{ end }} {{ end }} \ No newline at end of file From c02410db2446840afe660882a9fadae283a938b4 Mon Sep 17 00:00:00 2001 From: Tim Bannister Date: Wed, 23 Dec 2020 19:03:48 +0000 Subject: [PATCH 2/4] Move announcement styles into Sass --- assets/scss/_custom.scss | 61 +++++++++++++++++++++++++++++++++++++ layouts/partials/css.html | 4 --- static/css/announcement.css | 49 ----------------------------- 3 files changed, 61 insertions(+), 53 deletions(-) delete mode 100644 static/css/announcement.css diff --git a/assets/scss/_custom.scss b/assets/scss/_custom.scss index 5eb26c2e54..568a258a1c 100644 --- a/assets/scss/_custom.scss +++ b/assets/scss/_custom.scss @@ -578,3 +578,64 @@ body.td-documentation { color: black; text-decoration: none !important; } + +@media print { + /* Do not print announcements */ + #announcement, section#announcement, #fp-announcement, section#fp-announcement { + display: none; + } +} + +#announcement, #fp-announcement { + > * { + color: inherit; + background: inherit; + } + + a { + color: inherit; + border-bottom: 1px solid #fff; + } + + a:hover { + color: inherit; + border-bottom: none; + } +} + +#announcement { + padding-top: 105px; + padding-bottom: 25px; +} + +.header-hero { + padding-top: 40px; +} + +/* Extra announcement height only for landscape viewports */ +@media (min-aspect-ratio: 8/9) { + #fp-announcement { + min-height: 25vh; + } +} + +#fp-announcement aside { + padding-top: 115px; + padding-bottom: 25px; +} + +.announcement { + .content { + margin-bottom: 0px; + } + + + > p { + .gridPage #announcement .content p, + .announcement > h4, + .announcement > h3 { + color: #ffffff; + } + } +} + diff --git a/layouts/partials/css.html b/layouts/partials/css.html index 7abfb21e72..19951b8839 100644 --- a/layouts/partials/css.html +++ b/layouts/partials/css.html @@ -15,10 +15,6 @@ -{{- if .Site.Params.announcement }} - -{{- end }} - {{- if or (eq .Params.class "gridPage") (eq .Params.class "gridPage gridPageHome") }} {{- end }} diff --git a/static/css/announcement.css b/static/css/announcement.css deleted file mode 100644 index 816d7c1fc0..0000000000 --- a/static/css/announcement.css +++ /dev/null @@ -1,49 +0,0 @@ -@media print { - /* Do not print announcements */ - #announcement, section#announcement, #fp-announcement, section#fp-announcement { - display: none; - } -} - -.announcement.content { - margin-bottom: 0px; -} - -.announcement > p, -.gridPage #announcement .content p, -.announcement > h4, -.announcement > h3 { - color: #ffffff; -} - -#announcement a, -#fp-announcement a { - color: #fff; - border-bottom: 1px solid #fff; -} - -#announcement a:hover, -#fp-announcement a:hover { - border-bottom: none; -} - -#announcement { - padding-top: 105px; - padding-bottom: 25px; -} - -.header-hero { - padding-top: 40px; -} - -/* Extra announcement height only for landscape viewports */ -@media (min-aspect-ratio: 8/9) { - #fp-announcement { - min-height: 25vh; - } -} - -#fp-announcement aside { - padding-top: 115px; - padding-bottom: 25px; -} From db4f1d5844b416078196973a9d64a1891f679b8e Mon Sep 17 00:00:00 2001 From: Tim Bannister Date: Tue, 22 Dec 2020 22:26:49 +0000 Subject: [PATCH 3/4] Remove legacy announcement config --- config.toml | 5 ----- i18n/en.toml | 6 ------ 2 files changed, 11 deletions(-) diff --git a/config.toml b/config.toml index c0fdb72acf..ac1c1845fb 100644 --- a/config.toml +++ b/config.toml @@ -154,11 +154,6 @@ githubWebsiteRaw = "raw.githubusercontent.com/kubernetes/website" # GitHub repository link for editing a page and opening issues. github_repo = "https://github.com/kubernetes/website" -# param for displaying an announcement block on every page. -# See /i18n/en.toml for message text and title. -announcement = true -announcement_bg = "#000000" #choose a dark color – text is white - #Searching k8s_search = true diff --git a/i18n/en.toml b/i18n/en.toml index 899ffdd4bf..c6f24f8e2e 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -1,11 +1,5 @@ # i18n strings for the English (main) site. # NOTE: Please keep the entries in alphabetical order when editing -[announcement_title] -other = "Black lives matter." - -[announcement_message] -other = "We stand in solidarity with the Black community.
Racism is unacceptable.
It conflicts with the [core values of the Kubernetes project](https://git.k8s.io/community/values.md) and our community does not tolerate it." - [caution] other = "Caution:" From 0b6280f43e9e5a514a23843a2c2bb9f4dc66f904 Mon Sep 17 00:00:00 2001 From: Tim Bannister Date: Wed, 23 Dec 2020 17:47:52 +0000 Subject: [PATCH 4/4] Require steering committee approval for announcement changes --- OWNERS_ALIASES | 9 +++++++++ config.toml | 2 +- data/announcements/OWNERS | 8 ++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 data/announcements/OWNERS diff --git a/OWNERS_ALIASES b/OWNERS_ALIASES index 3d1ae50afa..863703e250 100644 --- a/OWNERS_ALIASES +++ b/OWNERS_ALIASES @@ -215,3 +215,12 @@ aliases: - idvoretskyi - MaxymVlasov - Potapy4 + # authoritative source: git.k8s.io/community/OWNERS_ALIASES + committee-steering: # provide PR approvals for announcements + - cblecker + - derekwaynecarr + - dims + - liggitt + - mrbobbytables + - nikhita + - parispittman diff --git a/config.toml b/config.toml index ac1c1845fb..d77c315331 100644 --- a/config.toml +++ b/config.toml @@ -13,7 +13,7 @@ disableBrowserError = true disableKinds = ["taxonomy", "taxonomyTerm"] -ignoreFiles = [ "^OWNERS$", "README[-]+[a-z]*\\.md", "^node_modules$", "content/en/docs/doc-contributor-tools" ] +ignoreFiles = [ "(?:^|/)OWNERS$", "README[-]+[a-z]*\\.md", "^node_modules$", "content/en/docs/doc-contributor-tools" ] timeout = 3000 diff --git a/data/announcements/OWNERS b/data/announcements/OWNERS new file mode 100644 index 0000000000..602afd0322 --- /dev/null +++ b/data/announcements/OWNERS @@ -0,0 +1,8 @@ +# See the OWNERS docs at https://go.k8s.io/owners + +# Disable inheritance as content in this dir is scoped to steering approval per +# https://github.com/kubernetes/community/blob/master/communication/website-guidelines.md +options: + no_parent_owners: true +approvers: +- committee-steering # defined in OWNERS_ALIASES