Skip to content

Commit 20afe7f

Browse files
authored
Merge pull request #25769 from sftim/20201222_data_driven_announcements
Implement announcements as data-driven content
2 parents 02c26ab + 0b6280f commit 20afe7f

File tree

10 files changed

+176
-91
lines changed

10 files changed

+176
-91
lines changed

OWNERS_ALIASES

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,12 @@ aliases:
215215
- idvoretskyi
216216
- MaxymVlasov
217217
- Potapy4
218+
# authoritative source: git.k8s.io/community/OWNERS_ALIASES
219+
committee-steering: # provide PR approvals for announcements
220+
- cblecker
221+
- derekwaynecarr
222+
- dims
223+
- liggitt
224+
- mrbobbytables
225+
- nikhita
226+
- parispittman

assets/scss/_custom.scss

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,3 +578,64 @@ body.td-documentation {
578578
color: black;
579579
text-decoration: none !important;
580580
}
581+
582+
@media print {
583+
/* Do not print announcements */
584+
#announcement, section#announcement, #fp-announcement, section#fp-announcement {
585+
display: none;
586+
}
587+
}
588+
589+
#announcement, #fp-announcement {
590+
> * {
591+
color: inherit;
592+
background: inherit;
593+
}
594+
595+
a {
596+
color: inherit;
597+
border-bottom: 1px solid #fff;
598+
}
599+
600+
a:hover {
601+
color: inherit;
602+
border-bottom: none;
603+
}
604+
}
605+
606+
#announcement {
607+
padding-top: 105px;
608+
padding-bottom: 25px;
609+
}
610+
611+
.header-hero {
612+
padding-top: 40px;
613+
}
614+
615+
/* Extra announcement height only for landscape viewports */
616+
@media (min-aspect-ratio: 8/9) {
617+
#fp-announcement {
618+
min-height: 25vh;
619+
}
620+
}
621+
622+
#fp-announcement aside {
623+
padding-top: 115px;
624+
padding-bottom: 25px;
625+
}
626+
627+
.announcement {
628+
.content {
629+
margin-bottom: 0px;
630+
}
631+
632+
633+
> p {
634+
.gridPage #announcement .content p,
635+
.announcement > h4,
636+
.announcement > h3 {
637+
color: #ffffff;
638+
}
639+
}
640+
}
641+

config.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ disableBrowserError = true
1313

1414
disableKinds = ["taxonomy", "taxonomyTerm"]
1515

16-
ignoreFiles = [ "^OWNERS$", "README[-]+[a-z]*\\.md", "^node_modules$", "content/en/docs/doc-contributor-tools" ]
16+
ignoreFiles = [ "(?:^|/)OWNERS$", "README[-]+[a-z]*\\.md", "^node_modules$", "content/en/docs/doc-contributor-tools" ]
1717

1818
timeout = 3000
1919

@@ -154,11 +154,6 @@ githubWebsiteRaw = "raw.githubusercontent.com/kubernetes/website"
154154
# GitHub repository link for editing a page and opening issues.
155155
github_repo = "https://github.com/kubernetes/website"
156156

157-
# param for displaying an announcement block on every page.
158-
# See /i18n/en.toml for message text and title.
159-
announcement = true
160-
announcement_bg = "#000000" #choose a dark color – text is white
161-
162157
#Searching
163158
k8s_search = true
164159

data/announcements/OWNERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# See the OWNERS docs at https://go.k8s.io/owners
2+
3+
# Disable inheritance as content in this dir is scoped to steering approval per
4+
# https://github.com/kubernetes/community/blob/master/communication/website-guidelines.md
5+
options:
6+
no_parent_owners: true
7+
approvers:
8+
- committee-steering # defined in OWNERS_ALIASES

data/announcements/scheduled.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
# For an example of the format, see commented structure below.
3+
#
4+
# 🛈 Changes require approval from @kubernetes/steering-committee
5+
6+
# The order matters: if two schedules overlaps, the announcement
7+
# that comes FIRST in the following list takes precedence.
8+
#
9+
#announcements:
10+
# - startTime: 2020-01-01T00:00:00
11+
# # startTime is optional
12+
# endTime: 2021-04-01T00:00:00
13+
# # endTime is required
14+
# style: >-
15+
# color: #fff; background: #000;
16+
# # style is optional; if using, set both color and background
17+
# # choose a dark color for the background
18+
# title: "Sample 1 announcement"
19+
# # title is optional
20+
# message: |
21+
# Message *one*.
22+
# [Hyperlink](https://en.wikipedia.org/wiki/Hyperlink).
23+
# # message is required. You can use Markdown.
24+
# - name: Sample 2
25+
# startTime: 2020-01-01T00:00:00
26+
# endTime: 2021-04-01T00:00:00
27+
# message: |
28+
# Message *two*.
29+
30+
# leave the "announcements" key in place
31+
announcements:

i18n/en.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
# i18n strings for the English (main) site.
22
# NOTE: Please keep the entries in alphabetical order when editing
3-
[announcement_title]
4-
other = "Black lives matter."
5-
6-
[announcement_message]
7-
other = "We stand in solidarity with the Black community.<br/>Racism is unacceptable.<br/> It conflicts with the [core values of the Kubernetes project](https://git.k8s.io/community/values.md) and our community does not tolerate it."
8-
93
[caution]
104
other = "Caution:"
115

layouts/partials/announcement.html

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
1-
{{ if .Page.Param "announcement" }}
2-
<section lang="en" id="announcement" style="background-color:{{ .Page.Param "announcement_bg" }}">
3-
<aside>
4-
<div class="content announcement main-section" data-nosnippet>
5-
6-
<h4 class="announcement">
7-
{{ T "announcement_title" | markdownify }}
8-
</h4>
9-
<p class="announcement">{{ T "announcement_message" | markdownify }}</p>
10-
11-
</div>
12-
</aside>
13-
</section>
1+
{{ $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])$" }}
2+
{{ $announcementShown := false }}
3+
{{ range $.Site.Data.announcements }}
4+
{{ range .announcements }}
5+
{{ if or ( eq .endTime nil ) ( eq .message nil ) }}
6+
{{ errorf "Invalid announcement: %#v" . }}
7+
{{ end }}
8+
{{ if and (ne .startTime nil ) (lt ( len ( findRE $dateRegExp .startTime ) ) 1 ) }}
9+
{{ errorf "Invalid announcement start time: %#v" .startTime }}
10+
{{ end }}
11+
{{ if lt ( len ( findRE $dateRegExp .endTime ) ) 1 }}
12+
{{ errorf "Invalid announcement end time: %#v" .endTime }}
13+
{{ end }}
14+
{{ if or (eq .startTime nil ) (lt ( time .startTime ) now ) }}
15+
{{- if or (eq .endTime nil ) (gt ( time .endTime ) now ) -}}
16+
{{- if not $announcementShown -}}
17+
{{- $announcementShown = true -}}
18+
<section lang="en" id="announcement" style="background-color: #3371e3; color: #fff; {{ .style | safeCSS }}">
19+
<aside>
20+
<div class="content announcement main-section" data-nosnippet>
21+
{{ if .title }}
22+
<h4 class="announcement">
23+
{{ .title | markdownify }}
24+
</h4>
25+
{{ end }}
26+
<p class="announcement">{{ .message | markdownify }}</p>
27+
</div>
28+
</aside>
29+
</section>
30+
{{- end -}}
31+
{{- end -}}
32+
{{- end -}}
33+
{{ end }}
1434
{{ end }}

layouts/partials/css.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515

1616
<link rel="stylesheet" href="{{ "css/feature-states.css" | relURL }}">
1717

18-
{{- if .Site.Params.announcement }}
19-
<link rel="stylesheet" href="{{ "css/announcement.css" | relURL }}">
20-
{{- end }}
21-
2218
{{- if or (eq .Params.class "gridPage") (eq .Params.class "gridPage gridPageHome") }}
2319
<link rel="stylesheet" href="{{ "css/gridpage.css" | relURL }}">
2420
{{- end }}
Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
1-
{{ if .Page.Param "announcement" }}
2-
<section lang="en" id="fp-announcement" style="background-color:{{ .Page.Param "announcement_bg" }}">
3-
<aside >
4-
<div class="content announcement main-section" data-nosnippet>
5-
6-
<h3>
7-
{{ T "announcement_title" | markdownify }}
8-
</h3>
9-
<p>{{ T "announcement_message" | markdownify }}</p>
10-
11-
</div>
12-
</aside>
13-
</section>
1+
{{ $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])$" }}
2+
{{ $announcementShown := false }}
3+
{{ range $.Site.Data.announcements }}
4+
{{ range .announcements }}
5+
{{ if or ( eq .endTime nil ) ( eq .message nil ) }}
6+
{{ errorf "Invalid announcement: %#v" . }}
7+
{{ end }}
8+
{{ if and (ne .startTime nil ) (lt ( len ( findRE $dateRegExp .startTime ) ) 1 ) }}
9+
{{ errorf "Invalid announcement start time: %#v" .startTime }}
10+
{{ end }}
11+
{{ if lt ( len ( findRE $dateRegExp .endTime ) ) 1 }}
12+
{{ errorf "Invalid announcement end time: %#v" .endTime }}
13+
{{ end }}
14+
{{ if or (eq .startTime nil ) (lt ( time .startTime ) now ) }}
15+
{{- if or (eq .endTime nil ) (gt ( time .endTime ) now ) -}}
16+
{{- if not $announcementShown -}}
17+
{{- $announcementShown = true -}}
18+
<section lang="en" id="fp-announcement" style="background-color: #3371e3; color: #fff; {{ .style | safeCSS }}">
19+
<aside>
20+
<div class="content announcement main-section" data-nosnippet>
21+
{{ if .title }}
22+
<h4 class="announcement">
23+
{{ .title | markdownify }}
24+
</h4>
25+
{{ end }}
26+
<p class="announcement">{{ .message | markdownify }}</p>
27+
</div>
28+
</aside>
29+
</section>
30+
{{- end -}}
31+
{{- end -}}
32+
{{- end -}}
33+
{{ end }}
1434
{{ end }}

static/css/announcement.css

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)