govuk_web_banners 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e90dcafd54461fe4a723458faccd96d342d6d4d4ad26451ea38431b94d56c2b4
4
- data.tar.gz: c12a85485ac267611ca6096fd3185bbb9c84123fb106f0102d9f88e872aeda11
3
+ metadata.gz: 812e2ba243433622af29da5ae03a118d2eeca1b92b2f1a293fd9faa7c7c7d8be
4
+ data.tar.gz: cc707567b6715229a8c68efa4bf3ad3b447a30a7fe2301ac739d740fe3f4edea
5
5
  SHA512:
6
- metadata.gz: 68690f93a35d664a9d6ed0103b6082987196a190b8089005ca0b6fe7a0cf3892106836f6e27c1f0bd033edf33dc9c9ddc5994cad80cca419ea5c2cf95cee6d1c
7
- data.tar.gz: a40d8c454e7b64ade2254e18c6ef09965b0023b1d79223771177c703d0182b9ffb14e7db63d3048223b1f054d4431b0bdee3aa589bf8f432895fea9600148a84
6
+ metadata.gz: 5608eaab07cfb7c5e5f6da27c6db19310fae258986e1334ff33cb54f8a2a9c3d9fcd6cadc95f6e0175f43bb60698bc0ae821957808ffe8ae06553d664b0f0701
7
+ data.tar.gz: dd2726aacb5d69fd888169ca167fb08f9f1b297789993c57c6b9b5d6aa35f0ad2315cc7f0e099be83e47e2d889f7e09b0a2ef5812f7d265e71083097b892b358
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 %>
@@ -45,3 +45,31 @@ banners:
45
45
  - /business-finance-support
46
46
  start_date: 11/11/2024
47
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
@@ -1,3 +1,3 @@
1
1
  module GovukWebBanners
2
- VERSION = "0.2.0".freeze
2
+ VERSION = "0.3.0".freeze
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require "govuk_publishing_components"
2
2
 
3
+ require "govuk_web_banners/emergency_banner"
3
4
  require "govuk_web_banners/engine"
4
5
  require "govuk_web_banners/recruitment_banner"
5
6
  require "govuk_web_banners/version"
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.2.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-12-10 00:00:00.000000000 Z
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.5.23
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: []