govuk_publishing_components 24.18.0 → 24.18.1

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: 61e7fb8fb022f0732bc0ffdc8626fcce56f7728d3d36027b67ee5a86faef7e63
4
- data.tar.gz: b4e5fc6caa343d11430891f9dfb4ffc575f45a402e3bafea20af2be76ed04e9b
3
+ metadata.gz: 02b26535b07ec186ec09b9ddd4ffb9e2bf6097caa9b7d59e3f0ec9e349fb81b1
4
+ data.tar.gz: 0373e25f45dddff403f478602d5d3bbb8db192265b170ea99fe7fd788b4b602f
5
5
  SHA512:
6
- metadata.gz: 5df1326ef3d37fca25e48f3c7c4abb7aa69b2b787c9c319a1021e7bb2dc912e0ab940abbf3d430207b6b5c8e87d9b35b1cde87921e07471c298c0c16b7a3cab7
7
- data.tar.gz: 9c4ac815e5f75c77a6239abfe5adf448f39c3e93b8b94e27a084233caa0240672a963420ac8ad8a9671c15bb49ba99a34e0b37f8516268e9b140bc2dd8116e87
6
+ metadata.gz: fb00fd4cc2b4288e78404a556af58b9f3de3ffc0155ea4430d0ca4ff08ae3764b9e34ac237e1b82278809b574bf115b30b7f84500f1f1d6f7f71df7f5a5d9568
7
+ data.tar.gz: 8cd996b85dc084669b638f8f9e98559acb1e9280c9b687c47dedd4dbfc0d5de3054ae23cd511e91f123903a3e1e3a01918eab45914afb72db9639c8a22970f7d
@@ -63,6 +63,7 @@
63
63
  'taxon-ids': { dimension: 59, defaultValue: 'other' },
64
64
  'content-has-history': { dimension: 39, defaultValue: 'false' },
65
65
  'publishing-application': { dimension: 89 },
66
+ 'brexit-audience': { dimension: 111 },
66
67
  stepnavs: { dimension: 96 },
67
68
  'relevant-result-shown': { dimension: 83 },
68
69
  'spelling-suggestion': { dimension: 81 }
@@ -1,9 +1,6 @@
1
1
  (function() {
2
- var marker = document.getElementsByTagName('script')[0]
3
- var scripts = [
4
- '<%= path_to_javascript("govuk_publishing_components/vendor/lux/lux-polyfill") %>',
5
- '<%= path_to_javascript("govuk_publishing_components/vendor/lux/lux") %>'
6
- ]
2
+ var scriptSrc = '<%= path_to_javascript("govuk_publishing_components/vendor/lux/lux-reporter") %>'
3
+
7
4
  var parsedCookie = (function() {
8
5
  try {
9
6
  var cookies = document.cookie.split(';')
@@ -23,14 +20,22 @@
23
20
  return {}
24
21
  })()
25
22
 
26
- if (parsedCookie.usage === true) {
27
- for (var i = 0; i < scripts.length; i++) {
28
- var script = document.createElement('script')
29
- script.src = scripts[i]
30
- script.async = true
31
- script.defer = true
23
+ var insertScript = function(source) {
24
+ var marker = document.getElementsByTagName('script')[0]
32
25
 
33
- marker.parentNode.insertBefore(script, marker)
34
- }
26
+ var script = document.createElement('script')
27
+ script.src = source
28
+ script.async = true
29
+ script.defer = true
30
+
31
+ marker.parentNode.insertBefore(script, marker)
32
+ }
33
+
34
+ if (parsedCookie.usage === true) {
35
+ insertScript(scriptSrc)
36
+ } else {
37
+ window.addEventListener('cookie-consent', function() {
38
+ insertScript(scriptSrc)
39
+ })
35
40
  }
36
41
  })()
@@ -39,6 +39,7 @@
39
39
  <meta charset="utf-8" />
40
40
  <title><%= title %></title>
41
41
 
42
+ <%= javascript_include_tag "govuk_publishing_components/vendor/lux/lux-measurer", { async: true } %>
42
43
  <%= javascript_include_tag "govuk_publishing_components/rum-loader", { async: true } %>
43
44
 
44
45
  <%= csrf_meta_tags %>
@@ -8,8 +8,8 @@ Rails.application.config.assets.precompile += %w[
8
8
  component_guide/visual-regression.js
9
9
  component_guide/print.css
10
10
  govuk_publishing_components/rum-loader.js
11
- govuk_publishing_components/vendor/lux.js
12
- govuk_publishing_components/vendor/lux-polyfill.js
11
+ govuk_publishing_components/vendor/lux/lux-reporter.js
12
+ govuk_publishing_components/vendor/lux/lux-measurer.js
13
13
  govuk_publishing_components/all_components.js
14
14
  govuk_publishing_components/ie.js
15
15
  govuk_publishing_components/modules.js
@@ -39,7 +39,16 @@ module GovukPublishingComponents
39
39
  tracking_category: "breadcrumbClicked",
40
40
  tracking_action: tracking_action,
41
41
  tracking_label: content_item["base_path"],
42
- }.merge(custom_dimension_tracking)
42
+ tracking_dimension_enabled: false,
43
+ }
44
+ end
45
+
46
+ def brexit_audience
47
+ {
48
+ PRIORITY_TAXONS[:brexit_business] => "Brexitbusiness",
49
+ PRIORITY_TAXONS[:brexit_individuals] => "Brexitcitizen",
50
+ PRIORITY_TAXONS[:brexit_taxon] => "Brexitbusinessandcitizen",
51
+ }[taxon["content_id"]]
43
52
  end
44
53
 
45
54
  private
@@ -79,38 +88,16 @@ module GovukPublishingComponents
79
88
  [PRIORITY_TAXONS[:brexit_business], PRIORITY_TAXONS[:brexit_individuals]]
80
89
  end
81
90
 
82
- def brexit_taxons
83
- brexit_child_taxons << PRIORITY_TAXONS[:brexit_taxon]
84
- end
85
-
86
91
  def preferred_priority_taxon
87
92
  query_parameters["priority-taxon"] if query_parameters
88
93
  end
89
94
 
90
95
  def tracking_action
91
96
  action = %w[superBreadcrumb]
92
- action << page_name_for_tracking
97
+ action << brexit_audience
93
98
  action.compact.join(" ")
94
99
  end
95
100
 
96
- def custom_dimension_tracking
97
- tracking = { tracking_dimension_enabled: false }
98
- if brexit_taxons.include?(taxon["content_id"])
99
- tracking[:tracking_dimension_enabled] = true
100
- tracking[:tracking_dimension] = page_name_for_tracking
101
- tracking[:tracking_dimension_index] = 111
102
- end
103
- tracking
104
- end
105
-
106
- def page_name_for_tracking
107
- {
108
- PRIORITY_TAXONS[:brexit_business] => "Brexitbusiness",
109
- PRIORITY_TAXONS[:brexit_individuals] => "Brexitcitizen",
110
- PRIORITY_TAXONS[:brexit_taxon] => "Brexitbusinessandcitizen",
111
- }[taxon["content_id"]]
112
- end
113
-
114
101
  def tagged_to_both_brexit_child_taxons?
115
102
  t = priority_taxons.select { |taxon| brexit_child_taxon?(taxon) }
116
103
  t.uniq.count > 1
@@ -20,7 +20,8 @@ module GovukPublishingComponents
20
20
  meta_tags = add_organisation_tags(meta_tags)
21
21
  meta_tags = add_political_tags(meta_tags)
22
22
  meta_tags = add_taxonomy_tags(meta_tags)
23
- add_step_by_step_tags(meta_tags)
23
+ meta_tags = add_step_by_step_tags(meta_tags)
24
+ add_brexit_tags(meta_tags)
24
25
  end
25
26
 
26
27
  private
@@ -111,6 +112,27 @@ module GovukPublishingComponents
111
112
  meta_tags
112
113
  end
113
114
 
115
+ def add_brexit_tags(meta_tags)
116
+ links = content_item[:links]
117
+ taxons = links[:taxons] unless links.nil?
118
+
119
+ return meta_tags if taxons.blank?
120
+ return meta_tags unless tagged_to_priority_taxon?
121
+
122
+ audience = priority_taxon_helper.brexit_audience
123
+ meta_tags["govuk:brexit-audience"] = audience if audience.present?
124
+
125
+ meta_tags
126
+ end
127
+
128
+ def tagged_to_priority_taxon?
129
+ priority_taxon_helper.taxon.present?
130
+ end
131
+
132
+ def priority_taxon_helper
133
+ @priority_taxon_helper ||= ContentBreadcrumbsBasedOnPriority.new(content_item.deep_stringify_keys, request.query_parameters)
134
+ end
135
+
114
136
  def has_content_history?
115
137
  (content_item[:public_updated_at] && details[:first_public_at] && content_item[:public_updated_at] != details[:first_public_at]) ||
116
138
  (details[:change_history] && details[:change_history].size > 1)
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "24.18.0".freeze
2
+ VERSION = "24.18.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 24.18.0
4
+ version: 24.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-01 00:00:00.000000000 Z
11
+ date: 2021-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -198,14 +198,14 @@ dependencies:
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: 3.7.0
201
+ version: 3.8.0
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: 3.7.0
208
+ version: 3.8.0
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: jasmine_selenium_runner
211
211
  requirement: !ruby/object:Gem::Requirement
@@ -503,8 +503,8 @@ files:
503
503
  - app/assets/javascripts/govuk_publishing_components/rum-loader.js.erb
504
504
  - app/assets/javascripts/govuk_publishing_components/vendor/html5shiv-printshiv.js
505
505
  - app/assets/javascripts/govuk_publishing_components/vendor/json2.js
506
- - app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-polyfill.js
507
- - app/assets/javascripts/govuk_publishing_components/vendor/lux/lux.js
506
+ - app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-measurer.js
507
+ - app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js
508
508
  - app/assets/javascripts/govuk_publishing_components/vendor/modernizr.js
509
509
  - app/assets/javascripts/govuk_publishing_components/vendor/polyfills/all.js
510
510
  - app/assets/javascripts/govuk_publishing_components/vendor/polyfills/closest.js