govuk_web_banners 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +81 -24
- data/app/views/govuk_web_banners/_emergency_banner.html.erb +11 -0
- data/config/govuk_web_banners/recruitment_banners.yml +59 -1
- data/lib/govuk_web_banners/emergency_banner.rb +37 -0
- data/lib/govuk_web_banners/version.rb +1 -1
- data/lib/govuk_web_banners.rb +1 -0
- metadata +34 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 812e2ba243433622af29da5ae03a118d2eeca1b92b2f1a293fd9faa7c7c7d8be
|
4
|
+
data.tar.gz: cc707567b6715229a8c68efa4bf3ad3b447a30a7fe2301ac739d740fe3f4edea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5608eaab07cfb7c5e5f6da27c6db19310fae258986e1334ff33cb54f8a2a9c3d9fcd6cadc95f6e0175f43bb60698bc0ae821957808ffe8ae06553d664b0f0701
|
7
|
+
data.tar.gz: dd2726aacb5d69fd888169ca167fb08f9f1b297789993c57c6b9b5d6aa35f0ad2315cc7f0e099be83e47e2d889f7e09b0a2ef5812f7d265e71083097b892b358
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# GovukWebBanners
|
2
|
-
Proof of Concept for centralising handling of Recruitment, Global, and Emergency
|
2
|
+
Proof of Concept for centralising handling of Recruitment, Global, and Emergency
|
3
|
+
banners (currently spread across apps)
|
3
4
|
|
4
5
|
## Usage
|
5
|
-
Currently
|
6
|
+
Currently supports the emergency banner and recruitment banners.
|
6
7
|
|
7
8
|
## Adding the gem to your application
|
8
9
|
Add this line to your application's Gemfile:
|
@@ -27,20 +28,68 @@ Add the JS dependencies to your existing asset dependencies file:
|
|
27
28
|
//= require govuk_web_banners/dependencies
|
28
29
|
```
|
29
30
|
|
30
|
-
|
31
|
+
## Adding emergency banners
|
32
|
+
|
33
|
+
Emergency banners are passed to the [Layout for Public](https://components.publishing.service.gov.uk/component-guide/layout_for_public) component, which is currently applied to each frontend app by the slimmer/static wrapping code - so you will only need to handle emergency banners in your app when Slimmer is removed from it. Once Slimmer is removed and you are calling the layout_for_public component directly in your app, add the emergency banner partial to the component's `emergency_banner:` key:
|
34
|
+
|
35
|
+
```
|
36
|
+
<%= render "govuk_publishing_components/components/layout_for_public", {
|
37
|
+
draft_watermark: draft_environment,
|
38
|
+
emergency_banner: render("govuk_web_banners/emergency_banner"), # <-- Add this line
|
39
|
+
full_width: false,
|
40
|
+
...etc
|
41
|
+
```
|
42
|
+
|
43
|
+
if you want the homepage variant of the banner, you can add `homepage: true` to the render call:
|
44
|
+
|
45
|
+
```
|
46
|
+
<%= render "govuk_publishing_components/components/layout_for_public", {
|
47
|
+
draft_watermark: draft_environment,
|
48
|
+
emergency_banner: render("govuk_web_banners/emergency_banner", homepage: true), # <-- Add this line
|
49
|
+
full_width: full_width,
|
50
|
+
...etc
|
51
|
+
```
|
52
|
+
|
53
|
+
Your app will also need access to the whitehall shared redis cluster (which is used to signal the emergency banner is up), via the `EMERGENCY_BANNER_REDIS_URL` environment variable (here is an example of [setting this in govuk-helm-charts](https://github.com/alphagov/govuk-helm-charts/blob/7818eaa22fc194d21548f316bcc5a46c2023dcb6/charts/app-config/values-staging.yaml#L3337-L3338)). You'll need to allow this in all three environments.
|
54
|
+
|
55
|
+
Finally, you'll need to configure a connection to the redis cluster, available at `Rails.application.config.emergency_banner_redis_client`. The suggested way of doing this is creating an initializer at `/config/initializers/govuk_web_banners.rb` with the content:
|
56
|
+
|
57
|
+
```
|
58
|
+
Rails.application.config.emergency_banner_redis_client = Redis.new(
|
59
|
+
url: ENV["EMERGENCY_BANNER_REDIS_URL"],
|
60
|
+
reconnect_attempts: [15, 30, 45, 60],
|
61
|
+
)
|
62
|
+
```
|
63
|
+
|
64
|
+
## Adding recruitment banners
|
65
|
+
|
66
|
+
Add a call to the partial in the layout or view that you want banners to appear
|
67
|
+
in (typically recruitment banners should be in the layout, below the breadcrumbs
|
68
|
+
and just above the `main` element):
|
31
69
|
|
32
70
|
```
|
33
71
|
<%= render "govuk_web_banners/recruitment_banner" %>
|
34
72
|
```
|
35
73
|
|
36
|
-
|
37
|
-
|
74
|
+
### Required stylesheets
|
75
|
+
|
76
|
+
If you are using individual component stylesheets in your app, you should make
|
77
|
+
sure the call to the recruitment_banner partial is above the call to
|
78
|
+
render_component_stylesheets in your layout.
|
79
|
+
|
80
|
+
If you are _not_ using individual component stylesheets in your app, you will
|
81
|
+
have to make sure the intervention component's styles are included in your
|
82
|
+
application stylesheet:
|
83
|
+
|
84
|
+
`@import "govuk_publishing_components/components/intervention"`
|
38
85
|
|
39
86
|
## Updating banner information in the gem
|
40
87
|
|
41
|
-
Data for the current set of live banners can be found at
|
42
|
-
add a banner to the
|
43
|
-
|
88
|
+
Data for the current set of live banners can be found at
|
89
|
+
`config/govuk_web_banners/recruitment_banners.yml`. To add a banner to the
|
90
|
+
config, add an entry under the banners: array. Note that this array must always
|
91
|
+
be valid, so if there are no banners in the file, it must contain at least
|
92
|
+
`banners: []`
|
44
93
|
|
45
94
|
### Example banner entry
|
46
95
|
|
@@ -57,32 +106,40 @@ banners:
|
|
57
106
|
end_date: 18/11/2024
|
58
107
|
```
|
59
108
|
|
60
|
-
The required keys are `suggestion_text`, `suggestion_link_text`, and
|
61
|
-
banner), and `page_paths` (an array of
|
109
|
+
The required keys are `suggestion_text`, `suggestion_link_text`, and
|
110
|
+
`survey_url` (the values to appear in the banner), and `page_paths` (an array of
|
111
|
+
paths on which the banner should be shown).
|
62
112
|
|
63
|
-
Optional keys are `name` (an identifying name for this banner, not rendered
|
64
|
-
|
65
|
-
specified as `
|
113
|
+
Optional keys are `name` (an identifying name for this banner, not rendered
|
114
|
+
anywhere), and `start_date` / `end_date` (the banner becomes active at the start
|
115
|
+
of the day specified as `start_date`, and stops at the *start* of the day
|
116
|
+
specified as `end_date`). Start and end dates must be in the DD/MM/YYYY format
|
117
|
+
parsable as a YAML -> Date.
|
66
118
|
|
67
119
|
### Keeping the config file valid and tidy
|
68
120
|
|
69
|
-
The config file will be checked during CI, so an invalid file can't be released
|
70
|
-
to make sure it's kept tidy. These checks include:
|
121
|
+
The config file will be checked during CI, so an invalid file can't be released
|
122
|
+
as a gem and we are forced to make sure it's kept tidy. These checks include:
|
71
123
|
|
72
124
|
* the banners array must be a valid YAML array
|
73
|
-
* all banners have a suggestion_text, suggestion_link_text, survey_url and
|
74
|
-
|
125
|
+
* all banners have a suggestion_text, suggestion_link_text, survey_url and
|
126
|
+
page_paths
|
127
|
+
* the same page_path is not present on two banners that are active at the same
|
128
|
+
time
|
75
129
|
* paths must start with a forward-slash (/)
|
76
130
|
|
77
131
|
It will also display warnings (but not fail CI)
|
78
132
|
|
79
|
-
* if there are banners that have expired - you are encouraged to remove obsolete
|
80
|
-
prevent you merging changes.
|
81
|
-
* if page_paths point to pages that are not currently live on GOV.UK - this may
|
82
|
-
is for a page that isn't yet published), or it
|
133
|
+
* if there are banners that have expired - you are encouraged to remove obsolete
|
134
|
+
config, but it will not prevent you merging changes.
|
135
|
+
* if page_paths point to pages that are not currently live on GOV.UK - this may
|
136
|
+
be intentional (if the banner is for a page that isn't yet published), or it
|
137
|
+
may indicate a typo in the path.
|
83
138
|
|
84
|
-
Note that some of this validation code is in the
|
85
|
-
should be tested to ensure the
|
139
|
+
Note that some of this validation code is in the
|
140
|
+
lib/govuk_web_banners/validators path, which should be tested to ensure the
|
141
|
+
checking is valid, but will not be bundled into the released gem.
|
86
142
|
|
87
143
|
## License
|
88
|
-
The gem is available as open source under the terms of the [MIT
|
144
|
+
The gem is available as open source under the terms of the [MIT
|
145
|
+
License](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<% emergency_banner = GovukWebBanners::EmergencyBanner.new %>
|
2
|
+
<% if emergency_banner.active? %>
|
3
|
+
<%= render "govuk_publishing_components/components/emergency_banner", {
|
4
|
+
campaign_class: emergency_banner.campaign_class,
|
5
|
+
heading: emergency_banner.heading,
|
6
|
+
link: emergency_banner.link,
|
7
|
+
link_text: emergency_banner.link_text,
|
8
|
+
short_description: emergency_banner.short_description,
|
9
|
+
homepage: local_assigns[:homepage] || false,
|
10
|
+
} %>
|
11
|
+
<% end %>
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# Example usage of adding a banner to the banners list
|
2
2
|
|
3
|
+
# banners:
|
3
4
|
# - name: Banner 1
|
4
5
|
# suggestion_text: "Help improve GOV.UK"
|
5
6
|
# suggestion_link_text: "Sign up to take part in user research (opens in a new tab)"
|
@@ -14,4 +15,61 @@
|
|
14
15
|
#
|
15
16
|
# Note that this file must contain a valid banners array, so if there are no banners
|
16
17
|
# currently included, the file should at least contain banners: []
|
17
|
-
banners:
|
18
|
+
banners:
|
19
|
+
- name: AI banner 11/11/2024
|
20
|
+
suggestion_text: "Help improve GOV.UK"
|
21
|
+
suggestion_link_text: "Sign up to take part in user research (opens in a new tab)"
|
22
|
+
survey_url: https://survey.take-part-in-research.service.gov.uk/jfe/form/SV_2bggmg6xlelrO0S
|
23
|
+
page_paths:
|
24
|
+
# government frontend:
|
25
|
+
- /self-assessment-tax-returns
|
26
|
+
- /working-for-yourself
|
27
|
+
- /self-employed-records
|
28
|
+
- /expenses-if-youre-self-employed
|
29
|
+
- /first-company-accounts-and-return
|
30
|
+
- /what-is-the-construction-industry-scheme
|
31
|
+
- /capital-allowances
|
32
|
+
- /simpler-income-tax-cash-basis
|
33
|
+
- /expenses-and-benefits-a-to-z
|
34
|
+
- /capital-gains-tax
|
35
|
+
- /directors-loans
|
36
|
+
- /self-assessment-tax-return-forms
|
37
|
+
- /running-a-limited-company
|
38
|
+
- /calculate-tax-on-company-cars
|
39
|
+
- /introduction-to-business-rates
|
40
|
+
- /calculate-your-business-rates
|
41
|
+
- /apply-for-business-rate-relief
|
42
|
+
- /stop-being-self-employed
|
43
|
+
- /tax-codes
|
44
|
+
# finder-frontend:
|
45
|
+
- /business-finance-support
|
46
|
+
start_date: 11/11/2024
|
47
|
+
end_date: 06/01/2025
|
48
|
+
- name: HMRC banner 03/01/2025
|
49
|
+
suggestion_text: "Help improve GOV.UK"
|
50
|
+
suggestion_link_text: "Sign up to take part in user research (opens in a new tab)"
|
51
|
+
survey_url: https://survey.take-part-in-research.service.gov.uk/jfe/form/SV_74GjifgnGv6GsMC?Source=BannerList_HMRC_CCG_Compliance
|
52
|
+
page_paths:
|
53
|
+
# government-frontend
|
54
|
+
- /government/collections/tax-compliance-detailed-information
|
55
|
+
- /government/collections/hm-revenue-and-customs-compliance-checks-factsheets
|
56
|
+
- /difficulties-paying-hmrc
|
57
|
+
- /tax-help
|
58
|
+
- /get-help-hmrc-extra-support
|
59
|
+
- /guidance/voluntary-and-community-sector-organisations-who-can-give-you-extra-support
|
60
|
+
- /tax-appeals
|
61
|
+
- /guidance/tax-disputes-alternative-dispute-resolution-adr
|
62
|
+
start_date: 03/01/2025
|
63
|
+
end_date: 31/01/2025
|
64
|
+
- name: UKVI banner 30/12/2025
|
65
|
+
suggestion_text: "Help improve GOV.UK"
|
66
|
+
suggestion_link_text: "Take part in user research (opens in a new tab)"
|
67
|
+
survey_url: https://surveys.publishing.service.gov.uk/s/XYVRGN/
|
68
|
+
page_paths:
|
69
|
+
# frontend
|
70
|
+
- /contact-ukvi-inside-outside-uk
|
71
|
+
# collections
|
72
|
+
- /browse/visas-immigration
|
73
|
+
- /government/organisations/uk-visas-and-immigration
|
74
|
+
start_date: 30/12/2024
|
75
|
+
end_date: 27/01/2025
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "govuk_app_config/govuk_error"
|
2
|
+
require "redis"
|
3
|
+
|
4
|
+
module GovukWebBanners
|
5
|
+
class EmergencyBanner
|
6
|
+
attr_reader :campaign_class, :heading, :short_description, :link, :link_text
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
content = content_from_redis
|
10
|
+
|
11
|
+
@campaign_class = content[:campaign_class].presence
|
12
|
+
@heading = content[:heading].presence
|
13
|
+
@short_description = content[:short_description].presence
|
14
|
+
@link = content[:link].presence
|
15
|
+
@link_text = content[:link_text].presence
|
16
|
+
end
|
17
|
+
|
18
|
+
def active?
|
19
|
+
[campaign_class, heading].all?
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def redis_client
|
25
|
+
Rails.application.config.emergency_banner_redis_client
|
26
|
+
end
|
27
|
+
|
28
|
+
def content_from_redis
|
29
|
+
Rails.cache.fetch("#emergency_banner/config", expires_in: 1.minute) do
|
30
|
+
redis_client.hgetall("emergency_banner").try(:symbolize_keys)
|
31
|
+
end
|
32
|
+
rescue StandardError => e
|
33
|
+
GovukError.notify(e, extra: { context: "Emergency Banner Redis" })
|
34
|
+
{}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/govuk_web_banners.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_web_banners
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
|
+
original_platform: ''
|
6
7
|
authors:
|
7
8
|
- GOV.UK Dev
|
8
|
-
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: govuk_app_config
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: govuk_publishing_components
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +52,20 @@ dependencies:
|
|
38
52
|
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: redis
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: byebug
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,9 +176,11 @@ files:
|
|
148
176
|
- Rakefile
|
149
177
|
- app/assets/config/govuk_web_banners_manifest.js
|
150
178
|
- app/assets/javascripts/govuk_web_banners/dependencies.js
|
179
|
+
- app/views/govuk_web_banners/_emergency_banner.html.erb
|
151
180
|
- app/views/govuk_web_banners/_recruitment_banner.html.erb
|
152
181
|
- config/govuk_web_banners/recruitment_banners.yml
|
153
182
|
- lib/govuk_web_banners.rb
|
183
|
+
- lib/govuk_web_banners/emergency_banner.rb
|
154
184
|
- lib/govuk_web_banners/engine.rb
|
155
185
|
- lib/govuk_web_banners/recruitment_banner.rb
|
156
186
|
- lib/govuk_web_banners/version.rb
|
@@ -161,7 +191,6 @@ metadata:
|
|
161
191
|
homepage_uri: https://github.com/alphagov/govuk_web_banners
|
162
192
|
source_code_uri: https://www.github.com/alphagov/govuk_web_banners
|
163
193
|
changelog_uri: https://www.github.com/alphagov/govuk_web_banners/CHANGELOG.md
|
164
|
-
post_install_message:
|
165
194
|
rdoc_options: []
|
166
195
|
require_paths:
|
167
196
|
- lib
|
@@ -176,8 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
205
|
- !ruby/object:Gem::Version
|
177
206
|
version: '0'
|
178
207
|
requirements: []
|
179
|
-
rubygems_version: 3.
|
180
|
-
signing_key:
|
208
|
+
rubygems_version: 3.6.1
|
181
209
|
specification_version: 4
|
182
210
|
summary: A gem to support banners on GOV.UK frontend applications
|
183
211
|
test_files: []
|