-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement announcements as data-driven content #25769
Implement announcements as data-driven content #25769
Conversation
✔️ Deploy preview for kubernetes-io-master-staging ready! 🔨 Explore the source changes: 0b6280f 🔍 Inspect the deploy logs: https://app.netlify.com/sites/kubernetes-io-master-staging/deploys/5ff712162a9b520007bf08da 😎 Browse the preview: https://deploy-preview-25769--kubernetes-io-master-staging.netlify.app |
BTW |
9f54245
to
9e14354
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A big +1 for time bound announcements! This is a great implementation and improvement, @sftim! Thank you for working on this 🌟
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: onlydole The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
{{ if .Page.Param "announcement" }} | ||
<section lang="en" id="fp-announcement" style="background-color:{{ .Page.Param "announcement_bg" }}"> | ||
<aside > | ||
{{ $announcementShown := false }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered refactoring this to be a single layout or partial that sets a different ID for the front page, or even making the HTML the same for both cases and using CSS to adjust styling. I decided that'd be best saved for a different PR; this one already has an potential impact on every page on the site(!) so let's keep it narrow.
(forced a Netlify retry after a Hugo concurrency error) |
The other part of this change is PR #25771: set up GitHub Actions to trigger a deploy for this website, twice per day. |
👀 |
layouts/partials/announcement.html
Outdated
{{ $announcementShown := false }} | ||
|
||
{{ $announcements := $.Site.Data.announcements }} | ||
{{ range sort $announcements "spec.priority" "desc" }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sftim, Some initial feedback/questions about the data and how to use this content:
- You envision a number of unique, reusable announcement files stored as data. Each file must be parsed in these partial templates in order to find the single announcement to publish? Any contributor can create a data file and have their announcement published based on the dates set in the file?
- Do you need to set a priority? Seems complicated and possibly error prone. Could you use a boolean (publish = true)? How many announcements can you publish at one time?
- It might be nice to have a base data file for all announcements and then have other announcements
override fields as needed. - I see an overlap of code in the two partial templates. Could you write another template that is used by both templates?
- If these are defaults,
style="background-color: #3371e3; color: #fff;
, could add to a base (announcement) data file? - How will the announcement be removed? Could the announcement have start and expiration dates? Is that described in the fields:
notAfter
andnotBefore
? When an announcement expires, the "default" or base announcement (could be nothing) is displayed. - Can the announcement message be localized?
- Will a periodic job read data files (or some other job configuration files) to determine what/when to publish (blog page)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You envision a number of unique, reusable announcement files stored as data. Each file must be parsed in these partial templates in order to find the single announcement to publish? Any contributor can create a data file and have their announcement published based on the dates set in the file?
I could add a note to the website contributor guide about how to set and review announcements. Maybe that'd work.
Only the steering committee can approve these announcements (see issue #25759 for details). This PR doesn't implement any enforcement mechanism for details messages.
Do you need to set a priority? Seems complicated and possibly error prone.
We have had announcements override other announcements (eg: KubeCon, overriding the current banner on the topic of Black Lives Matter). To me it seems like the override case is easier than the alternative: splitting the outer announcement into two and having three defined announcements that just avoid overlapping.
It might be nice to have a base data file for all announcements and then have other announcements
override fields as needed.
There's one required field, .spec.message
. I don't think there's a sensible default to set for that.
As with the current implementation, the default is not to show an announcement.
I see an overlap of code in the two partial templates. Could you write another template that is used by both templates?
I explained my thinking in #25769 (comment)
If these are defaults, style="background-color: #3371e3; color: #fff;, could add to a base (announcement) data file?
That sounds like more complexity for a really niche case. I envisage an implementation of that covering an override mechanism for every other field to ensure a override mechanism for one. I don't think it's justified, especially as CSS is the easiest field to define overrides for (it's kind of built-in).
How will the announcement be removed?
Removal is optional; it'll improve site build time but I suspect not by much.
Could the announcement have start and expiration dates? Is that described in the fields:
notAfter
andnotBefore
?
Yes. Those fields are optional.
When an announcement expires, the "default" or base announcement (could be nothing) is displayed.
As with the current implementation, the default is not to show an announcement.
Can the announcement message be localized?
I haven't implemented this. Instead, as with the current implementation, we mark the HTML elements for the announcement as English (overriding any page-level setting, and helping any web crawlers that care).
Will a periodic job read data files (or some other job configuration files) to determine what/when to publish (blog page)?
For blog articles, Hugo has built-in support for not publishing articles before their publication date. PR #25771 implements an automatic build trigger.
Those two mechanisms combined would make blog articles go live when ready (we use a similar mechanism for https://www.scalefactory.com/blog/).
This PR together with #25771 would make announcements go live or disappear as needed. See that PR for details about the approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverse-sorting by start date seems like it would be a simpler than a separate priority field, and I think it would do what you want in the case of a long-lived announcement being temporarily overridden by a short-lived announcement
Can the announcement message be localized?
I also had this question, though the current localization had very limited utilization (only korean localized it, looks like), and the short-lived nature of announcements seem unlikely to mesh well with slower translation cycles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverse-sorting by start date
There could be some gotchas around sorting on start date; Hugo date parsing and handling is there, but it is a bit raw. New Hugo releases are adding useful time and date features so the topic is definitely getting attention.
To be honest I already implemented priority and I known that'll work. The start date thing seems like it could be a surprise to people who want to work out which announcement will show when a current one elapses, whereas a priority value is easy to teach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I don't feel strongly. I don't really expect there to be more than 1-2 at any given time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the site will not substitute an "empty" section when there are no announcements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kbhawkey examples of the priority
field:
---
priority: 10
dateConstraints:
startTime: 2020-01-01T00:00:00
endTime: 2022-07-01T00:00:00
message: |-
Kubernetes all through 2020 _and_ the first half of 2021.
and
---
priority: 20
dateConstraints:
startTime: 2021-03-20T09:00:00
endTime: 2021-04-02T00:00:00
style: >-
color: #fff; background: #505;
title: KubeCon Offworld 2021
message: |-
Kubecon Offworld 2021 will be held on the planet Marklar from the first of April
to the first of April.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Kubecon banner would override the “Kubernetes all through 2020 and the first half of 2021.” banner for the configured duration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the site will not substitute an "empty" section when there are no announcements?
If there is no active announcement then there's no section#announcement
emitted; that's the same as what the current mechanism does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I understand that you want to sort by priority instead of looking for a "publish" field.
BTW, merging this PR as it stands removes the existing banner. I can / will add another commit that retains it, when that's useful to do. |
data/announcements/example.yaml
Outdated
apiVersion: docs.k8s.io/v1alpha1 | ||
kind: Announcement | ||
spec: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this do anything currently? if not, suggest removing it... it'll just get copy/pasted and not add much value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example.yaml
? It's an example.
If you mean .spec
then you can't omit it with the current code. IMO it makes the Hugo layout code a bit nicer because I can {{ with .spec }}
to bring just those fields into scope.
If you mean the apiVersion
and kind
then the current code enforces that you are using this particular format, but we can remove that validation if it's not useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the apiVersion/kind/spec bits... I didn't see any enforcement there, so it didn't seem like it was accomplishing anything
a flat structure seemed easier to read, but maybe that's just me:
# priority is required
# Largest number wins tie break if there are multiple announcements
priority: 0
# start/stop are required, and must be in format YYYY-MM-DDTHH:MM:SS
startDateTime: "2020-01-01T00:00:00"
stopDateTime: "2020-04-01T00:00:00"
# message is required
message: |-
Marklar marklar marklar marklar marklar.
Marklar marklar.
[Marklar](https://en.wikipedia.org/wiki/Starvin%27_Marvin_in_Space#Plot)!
# title is optional
title: Sample announcement
# style is optional; if using, set both color and background
style: "color: #fff; background: #000;"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this do anything currently? if not, suggest removing it... it'll just get copy/pasted and not add much value
+1 for removing any unused fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I can try to simplify it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I did have validation in before but must have left that out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's too bad that the title and message are not localized. I assume you can use a template in the data file.
I have not thought this through ...
[announcement]
[announcement.<name>]
title = "Kubernetes Europe"
message = "Come to Kubecon"
this still is looking at the old config value:
|
Ah, good spot. |
538dbe0
to
728e590
Compare
data/announcements/scheduled.yaml
Outdated
# 🛈 Changes require approval from @kubernetes/steering-committee | ||
|
||
# This is just an example. For the actual announcements, see | ||
# announcements.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to have this file (template and docs) and a separate file for the announcement data?
What do you think about combining the instructions and template with the data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about combining the instructions and template with the data?
Agree, especially if the data has to be a in a single list in a single file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible to have multiple files, though, I find it easier if the data is in one place or presented as a single view.
I probably won't have much time to spend on improvements to this PR. If it's pretty much good enough to merge, let's ship it and be prepared to follow up with any important tweaks. |
da1f784
to
9c0f9fa
Compare
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 <[email protected]>
9c0f9fa
to
2bdc11d
Compare
/hold cancel the automatic builds from PR #25771 are now working This PR looks ready to supersede the implementation from PR #16210. ℹ️ I have updated to include the existing banner text. As the new mechanism enforces a future expiry date, I picked one. Once this merges, further changes to announcements need authorization from by @kubernetes/steering-committee. |
data/announcements/scheduled.yaml
Outdated
|
||
# leave the "announcements" key in place | ||
announcements: | ||
- startTime: 2020-06-04T23:04:39 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sftim,
Is there a good reason to keep the existing announcement or should this PR only include the example template?
I don't see a strong case to place an announcement with this PR.
An announcement can be added in a separate PR (and approved separately by the Steering Committee).
This change is about changing the way the announcements are created and approved by setting up the announcements in a data file and processing the delivery of the announcements.
I said I'd revise this PR to retain the existing announcement. |
You are referring to this, I think that is confusing. I read through this PR (many times) and found that you only proposed sample data. |
I agree.
Per the announcement policy, the current banner, re-enabled on 11/23/2020, should have an expiry of 12/14/2020. |
I'll revise the expiry date, thanks @liggitt |
Actually not much point adding an expired banner! |
2bdc11d
to
0b6280f
Compare
@@ -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." | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Could add this announcement data into the announcement template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see discussion of current announcement data in #25769 (comment)
@sftim , thanks for working on this. |
LGTM label has been added. Git tree hash: 89addbd4d5f5fd0a18f1972923ea91592af4f3c2
|
/lgtm |
This looks reviewed to me. #25769 (comment) is an LGTMing review from a steering committee member, and https://github.com/kubernetes/website/pulls#pullrequestreview-557411184 is an approving review from a SIG Docs tech lead. /unhold |
Also see PR #27274 |
Rather than configuring announcements in the
config.toml
, add a mechanism to handle these as data driven content.This change allows announcements to have an expiry date and / or a “do not show until” date. You can also have multiple announcements, for example to have a Kubecon announcement that takes priority but only until the end of the conference.
Part of the implementation for issue #25759. Preview (but it doesn't show any current announcement).
/kind feature
/area web-development
/hold
because to make the expiry date mechanism work, we should also set up triggered builds. That'll be a separate pull request.