govuk_web_banners 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +34 -1
- data/app/views/govuk_web_banners/_emergency_banner.html.erb +11 -0
- data/app/views/govuk_web_banners/_recruitment_banner.html.erb +1 -1
- data/config/govuk_web_banners/recruitment_banners.yml +25 -26
- 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 +33 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ddede52ca24adcae2aa28d4dc5f449c53be00ab21806415acaaa6b49a740f27a
|
|
4
|
+
data.tar.gz: e87d8c81b5efd160291082c460a7136454be0fc5fc2f981ea065a1dfba10d48d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d2c9d65a8a83b580c26dd1867a06f8cc00e0dae232994c853e43ddcc32818f8dec30346e9486b234d4dc6cb6a97b070f4072b127053b3212f7e1e3a45842f8a9
|
|
7
|
+
data.tar.gz: d87961bc141844b15a3666f0b33a29c023c0c6b9515378497e5a77069a1e70ec873bbb970bc8c165f9fe86e101effc6d4ead173c52b22f1ecb5fce19028283de
|
data/README.md
CHANGED
|
@@ -3,7 +3,7 @@ Proof of Concept for centralising handling of Recruitment, Global, and Emergency
|
|
|
3
3
|
banners (currently spread across apps)
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
|
-
Currently supports recruitment banners
|
|
6
|
+
Currently supports the emergency banner and recruitment banners.
|
|
7
7
|
|
|
8
8
|
## Adding the gem to your application
|
|
9
9
|
Add this line to your application's Gemfile:
|
|
@@ -28,6 +28,39 @@ Add the JS dependencies to your existing asset dependencies file:
|
|
|
28
28
|
//= require govuk_web_banners/dependencies
|
|
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
|
+
|
|
31
64
|
## Adding recruitment banners
|
|
32
65
|
|
|
33
66
|
Add a call to the partial in the layout or view that you want banners to appear
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
<% recruitment_banner = GovukWebBanners::RecruitmentBanner.for_path(request.path) %>
|
|
2
2
|
<% if recruitment_banner.present? %>
|
|
3
|
-
<div class="govuk
|
|
3
|
+
<div class="govuk-!-margin-top-4">
|
|
4
4
|
<%= render "govuk_publishing_components/components/intervention", {
|
|
5
5
|
new_tab: true,
|
|
6
6
|
suggestion_text: recruitment_banner.suggestion_text,
|
|
@@ -16,32 +16,31 @@
|
|
|
16
16
|
# Note that this file must contain a valid banners array, so if there are no banners
|
|
17
17
|
# currently included, the file should at least contain banners: []
|
|
18
18
|
banners:
|
|
19
|
-
- name:
|
|
19
|
+
- name: HMRC banner 03/01/2025
|
|
20
20
|
suggestion_text: "Help improve GOV.UK"
|
|
21
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/
|
|
22
|
+
survey_url: https://survey.take-part-in-research.service.gov.uk/jfe/form/SV_74GjifgnGv6GsMC?Source=BannerList_HMRC_CCG_Compliance
|
|
23
23
|
page_paths:
|
|
24
|
-
# government
|
|
25
|
-
- /
|
|
26
|
-
- /
|
|
27
|
-
- /
|
|
28
|
-
- /
|
|
29
|
-
- /
|
|
30
|
-
- /
|
|
31
|
-
- /
|
|
32
|
-
- /
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
- /
|
|
42
|
-
|
|
43
|
-
- /
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
end_date: 06/01/2025
|
|
24
|
+
# government-frontend
|
|
25
|
+
- /government/collections/tax-compliance-detailed-information
|
|
26
|
+
- /government/collections/hm-revenue-and-customs-compliance-checks-factsheets
|
|
27
|
+
- /difficulties-paying-hmrc
|
|
28
|
+
- /tax-help
|
|
29
|
+
- /get-help-hmrc-extra-support
|
|
30
|
+
- /guidance/voluntary-and-community-sector-organisations-who-can-give-you-extra-support
|
|
31
|
+
- /tax-appeals
|
|
32
|
+
- /guidance/tax-disputes-alternative-dispute-resolution-adr
|
|
33
|
+
start_date: 03/01/2025
|
|
34
|
+
end_date: 31/01/2025
|
|
35
|
+
- name: UKVI banner 30/12/2025
|
|
36
|
+
suggestion_text: "Help improve GOV.UK"
|
|
37
|
+
suggestion_link_text: "Take part in user research (opens in a new tab)"
|
|
38
|
+
survey_url: https://surveys.publishing.service.gov.uk/s/XYVRGN/
|
|
39
|
+
page_paths:
|
|
40
|
+
# frontend
|
|
41
|
+
- /contact-ukvi-inside-outside-uk
|
|
42
|
+
# collections
|
|
43
|
+
- /browse/visas-immigration
|
|
44
|
+
- /government/organisations/uk-visas-and-immigration
|
|
45
|
+
start_date: 30/12/2024
|
|
46
|
+
end_date: 24/02/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,28 @@
|
|
|
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.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- GOV.UK Dev
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 2025-01-20 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: govuk_app_config
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
13
26
|
- !ruby/object:Gem::Dependency
|
|
14
27
|
name: govuk_publishing_components
|
|
15
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -38,6 +51,20 @@ dependencies:
|
|
|
38
51
|
- - ">="
|
|
39
52
|
- !ruby/object:Gem::Version
|
|
40
53
|
version: '7'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: redis
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
type: :runtime
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
41
68
|
- !ruby/object:Gem::Dependency
|
|
42
69
|
name: byebug
|
|
43
70
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -148,9 +175,11 @@ files:
|
|
|
148
175
|
- Rakefile
|
|
149
176
|
- app/assets/config/govuk_web_banners_manifest.js
|
|
150
177
|
- app/assets/javascripts/govuk_web_banners/dependencies.js
|
|
178
|
+
- app/views/govuk_web_banners/_emergency_banner.html.erb
|
|
151
179
|
- app/views/govuk_web_banners/_recruitment_banner.html.erb
|
|
152
180
|
- config/govuk_web_banners/recruitment_banners.yml
|
|
153
181
|
- lib/govuk_web_banners.rb
|
|
182
|
+
- lib/govuk_web_banners/emergency_banner.rb
|
|
154
183
|
- lib/govuk_web_banners/engine.rb
|
|
155
184
|
- lib/govuk_web_banners/recruitment_banner.rb
|
|
156
185
|
- lib/govuk_web_banners/version.rb
|
|
@@ -161,7 +190,6 @@ metadata:
|
|
|
161
190
|
homepage_uri: https://github.com/alphagov/govuk_web_banners
|
|
162
191
|
source_code_uri: https://www.github.com/alphagov/govuk_web_banners
|
|
163
192
|
changelog_uri: https://www.github.com/alphagov/govuk_web_banners/CHANGELOG.md
|
|
164
|
-
post_install_message:
|
|
165
193
|
rdoc_options: []
|
|
166
194
|
require_paths:
|
|
167
195
|
- lib
|
|
@@ -176,8 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
176
204
|
- !ruby/object:Gem::Version
|
|
177
205
|
version: '0'
|
|
178
206
|
requirements: []
|
|
179
|
-
rubygems_version: 3.
|
|
180
|
-
signing_key:
|
|
207
|
+
rubygems_version: 3.6.3
|
|
181
208
|
specification_version: 4
|
|
182
209
|
summary: A gem to support banners on GOV.UK frontend applications
|
|
183
210
|
test_files: []
|