govuk_publishing_components 63.3.1 → 64.1.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.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-form-change-tracker.js +8 -2
  3. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-form-tracker.js +14 -3
  4. data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +8 -34
  5. data/app/assets/javascripts/govuk_publishing_components/dependencies.js +1 -1
  6. data/app/assets/javascripts/govuk_publishing_components/domain-config.js +5 -10
  7. data/app/assets/javascripts/govuk_publishing_components/lib/cookie-settings.js +4 -15
  8. data/app/controllers/govuk_publishing_components/application_controller.rb +0 -5
  9. data/app/controllers/govuk_publishing_components/applications_page_controller.rb +1 -0
  10. data/app/models/govuk_publishing_components/applications_page.rb +12 -7
  11. data/app/models/govuk_publishing_components/audit_applications.rb +0 -4
  12. data/app/models/govuk_publishing_components/audit_comparer.rb +1 -4
  13. data/app/views/govuk_publishing_components/applications_page/_table-content.html.erb +7 -0
  14. data/app/views/govuk_publishing_components/applications_page/show.html.erb +1 -1
  15. data/app/views/govuk_publishing_components/audit/_applications.html.erb +0 -8
  16. data/app/views/govuk_publishing_components/audit/show.html.erb +1 -6
  17. data/app/views/govuk_publishing_components/component_guide/example.html.erb +1 -1
  18. data/app/views/govuk_publishing_components/component_guide/preview.html.erb +1 -1
  19. data/app/views/govuk_publishing_components/component_guide/show.html.erb +1 -1
  20. data/app/views/govuk_publishing_components/components/_accordion.html.erb +0 -2
  21. data/app/views/govuk_publishing_components/components/_action_link.html.erb +0 -2
  22. data/app/views/govuk_publishing_components/components/_add_another.html.erb +0 -1
  23. data/app/views/govuk_publishing_components/components/_app_promo_banner.html.erb +0 -2
  24. data/app/views/govuk_publishing_components/components/_attachment.html.erb +0 -2
  25. data/app/views/govuk_publishing_components/components/_attachment_link.html.erb +0 -2
  26. data/app/views/govuk_publishing_components/components/_back_link.html.erb +0 -2
  27. data/app/views/govuk_publishing_components/components/_back_to_top_link.html.erb +0 -2
  28. data/app/views/govuk_publishing_components/components/_big_number.html.erb +0 -2
  29. data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +0 -2
  30. data/app/views/govuk_publishing_components/components/_button.html.erb +0 -1
  31. data/app/views/govuk_publishing_components/components/_cards.html.erb +0 -1
  32. data/app/views/govuk_publishing_components/components/_character_count.html.erb +0 -3
  33. data/app/views/govuk_publishing_components/components/_checkboxes.html.erb +0 -1
  34. data/app/views/govuk_publishing_components/components/_contents_list.html.erb +0 -2
  35. data/app/views/govuk_publishing_components/components/_contents_list_with_body.html.erb +0 -1
  36. data/app/views/govuk_publishing_components/components/_contextual_guidance.html.erb +0 -2
  37. data/app/views/govuk_publishing_components/components/_contextual_sidebar.html.erb +0 -2
  38. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +0 -2
  39. data/app/views/govuk_publishing_components/components/_cross_service_header.html.erb +0 -2
  40. data/app/views/govuk_publishing_components/components/_date_input.html.erb +0 -2
  41. data/app/views/govuk_publishing_components/components/_details.html.erb +0 -2
  42. data/app/views/govuk_publishing_components/components/_devolved_nations.html.erb +0 -2
  43. data/app/views/govuk_publishing_components/components/_document_list.html.erb +0 -2
  44. data/app/views/govuk_publishing_components/components/_emergency_banner.html.erb +0 -2
  45. data/app/views/govuk_publishing_components/components/_error_alert.html.erb +0 -2
  46. data/app/views/govuk_publishing_components/components/_error_message.html.erb +0 -2
  47. data/app/views/govuk_publishing_components/components/_error_summary.html.erb +0 -2
  48. data/app/views/govuk_publishing_components/components/_feedback.html.erb +0 -3
  49. data/app/views/govuk_publishing_components/components/_fieldset.html.erb +0 -2
  50. data/app/views/govuk_publishing_components/components/_figure.html.erb +0 -1
  51. data/app/views/govuk_publishing_components/components/_file_upload.html.erb +4 -3
  52. data/app/views/govuk_publishing_components/components/_glance_metric.html.erb +0 -2
  53. data/app/views/govuk_publishing_components/components/_global_banner.html.erb +0 -2
  54. data/app/views/govuk_publishing_components/components/_govspeak.html.erb +0 -5
  55. data/app/views/govuk_publishing_components/components/_govspeak_html_publication.html.erb +0 -2
  56. data/app/views/govuk_publishing_components/components/_heading.html.erb +0 -2
  57. data/app/views/govuk_publishing_components/components/_hint.html.erb +0 -2
  58. data/app/views/govuk_publishing_components/components/_image_card.html.erb +0 -2
  59. data/app/views/govuk_publishing_components/components/_input.html.erb +0 -2
  60. data/app/views/govuk_publishing_components/components/_inset_text.html.erb +0 -2
  61. data/app/views/govuk_publishing_components/components/_intervention.html.erb +0 -2
  62. data/app/views/govuk_publishing_components/components/_inverse_header.html.erb +0 -2
  63. data/app/views/govuk_publishing_components/components/_label.html.erb +0 -2
  64. data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +0 -2
  65. data/app/views/govuk_publishing_components/components/_layout_for_admin.html.erb +0 -1
  66. data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +0 -2
  67. data/app/views/govuk_publishing_components/components/_layout_header.html.erb +0 -2
  68. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +0 -2
  69. data/app/views/govuk_publishing_components/components/_lead_paragraph.html.erb +0 -2
  70. data/app/views/govuk_publishing_components/components/_metadata.html.erb +0 -2
  71. data/app/views/govuk_publishing_components/components/_modal_dialogue.html.erb +0 -2
  72. data/app/views/govuk_publishing_components/components/_notice.html.erb +0 -2
  73. data/app/views/govuk_publishing_components/components/_option_select.html.erb +0 -3
  74. data/app/views/govuk_publishing_components/components/_organisation_logo.html.erb +0 -2
  75. data/app/views/govuk_publishing_components/components/_pagination.html.erb +0 -1
  76. data/app/views/govuk_publishing_components/components/_panel.html.erb +0 -2
  77. data/app/views/govuk_publishing_components/components/_password_input.html.erb +0 -2
  78. data/app/views/govuk_publishing_components/components/_phase_banner.html.erb +0 -2
  79. data/app/views/govuk_publishing_components/components/_print_link.html.erb +0 -2
  80. data/app/views/govuk_publishing_components/components/_published_dates.html.erb +0 -2
  81. data/app/views/govuk_publishing_components/components/_radio.html.erb +0 -3
  82. data/app/views/govuk_publishing_components/components/_related_navigation.html.erb +0 -2
  83. data/app/views/govuk_publishing_components/components/_reorderable_list.html.erb +0 -2
  84. data/app/views/govuk_publishing_components/components/_search.html.erb +0 -3
  85. data/app/views/govuk_publishing_components/components/_search_with_autocomplete.html.erb +0 -2
  86. data/app/views/govuk_publishing_components/components/_secondary_navigation.html.erb +0 -2
  87. data/app/views/govuk_publishing_components/components/_select.html.erb +0 -2
  88. data/app/views/govuk_publishing_components/components/_select_with_search.html.erb +0 -2
  89. data/app/views/govuk_publishing_components/components/_service_navigation.html.erb +0 -2
  90. data/app/views/govuk_publishing_components/components/_share_links.html.erb +0 -2
  91. data/app/views/govuk_publishing_components/components/_signup_link.html.erb +0 -2
  92. data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb +0 -2
  93. data/app/views/govuk_publishing_components/components/_skip_link.html.erb +0 -2
  94. data/app/views/govuk_publishing_components/components/_step_by_step_nav.html.erb +0 -2
  95. data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +0 -2
  96. data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +0 -1
  97. data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +0 -2
  98. data/app/views/govuk_publishing_components/components/_success_alert.html.erb +0 -2
  99. data/app/views/govuk_publishing_components/components/_summary_banner.html.erb +0 -2
  100. data/app/views/govuk_publishing_components/components/_summary_card.html.erb +0 -2
  101. data/app/views/govuk_publishing_components/components/_summary_list.html.erb +0 -2
  102. data/app/views/govuk_publishing_components/components/_table.html.erb +0 -2
  103. data/app/views/govuk_publishing_components/components/_tabs.html.erb +0 -2
  104. data/app/views/govuk_publishing_components/components/_tag.html.erb +0 -2
  105. data/app/views/govuk_publishing_components/components/_textarea.html.erb +0 -2
  106. data/app/views/govuk_publishing_components/components/_translation_nav.html.erb +0 -2
  107. data/app/views/govuk_publishing_components/components/_warning_text.html.erb +0 -2
  108. data/app/views/govuk_publishing_components/components/docs/govspeak_html_publication.yml +0 -2
  109. data/app/views/govuk_publishing_components/components/docs/organisation_logo.yml +4 -7
  110. data/lib/govuk_publishing_components/config.rb +0 -6
  111. data/lib/govuk_publishing_components/presenters/machine_readable/faq_page_schema.rb +1 -2
  112. data/lib/govuk_publishing_components/presenters/meta_tags.rb +0 -2
  113. data/lib/govuk_publishing_components/presenters/organisation_logo_helper.rb +11 -13
  114. data/lib/govuk_publishing_components/version.rb +1 -1
  115. data/lib/govuk_publishing_components.rb +0 -5
  116. metadata +2 -10
  117. data/app/assets/javascripts/govuk_publishing_components/single-consent-functions.js +0 -59
  118. data/lib/govuk_publishing_components/app_helpers/asset_helper.rb +0 -78
  119. data/node_modules/govuk-single-consent/README.md +0 -157
  120. data/node_modules/govuk-single-consent/dist/singleconsent.cjs.js +0 -419
  121. data/node_modules/govuk-single-consent/dist/singleconsent.esm.js +0 -417
  122. data/node_modules/govuk-single-consent/dist/singleconsent.iife.js +0 -431
  123. data/node_modules/govuk-single-consent/dist/singleconsent.iife.min.js +0 -1
  124. data/node_modules/govuk-single-consent/package.json +0 -56
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6accce7654a1f778de97ed1e1c305ea2b61ba6e1cd65c18003179d298075dd1f
4
- data.tar.gz: 17f5ec5d9b2ce4f0dac0f16cf3de381b575bd8c24ce5a1d295dc264e14203829
3
+ metadata.gz: 5a36e502c34c34ff4f3d4f3c68b2bdc3c73d2e0063e0681113d6fa86419256a1
4
+ data.tar.gz: e7687186a40332b5fd8466c08bc37eaf061383053d571873b32efb1b19fe2140
5
5
  SHA512:
6
- metadata.gz: f747916bfc169df32c1c8bf40630a8c03855c7666b467072cb1a21cd413d1f5ffacb8117b1c051f98402ad90f8ae8c205a2cacfeeded10d52a5dab37031810de
7
- data.tar.gz: a16291d0bf67efc71960cc73c18d721b7f9d629b72ba23e35dcd3a42e9b84165aa64bb2a5e0817de2826b7175cb5e9adb514bdc7c998201be951226eb51be891
6
+ metadata.gz: 4e0e05ae52393e75403160be9fe4243b498d47f9241ef4245d75aad760093c614a9a6c636fa7b256deb1fb785a020f020142df49a06eb79710955689a71ec981
7
+ data.tar.gz: 0146075f678ac78ee120d4bc495dc7a2251f93b93fd8c0a04478654f29d185151a97fe906db961ee0e46629cd43186031a4474ab95387fe211beca4432c9d2f4
@@ -110,13 +110,19 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
110
110
  let text
111
111
 
112
112
  if (checkableValue) {
113
+ const fieldset = checkableValue.closest('fieldset') || null
114
+ const redactedFieldset = fieldset && fieldset.dataset.ga4Redact
115
+
113
116
  // radio, check, option can have `:checked` pseudo-class
114
117
  if (!checkableValue.matches(':checked')) {
115
118
  action = 'remove'
116
119
  }
117
120
 
118
- text = checkableValue.innerText ||
119
- this.module.querySelector(`label[for='${window.CSS.escape(id)}']`).innerText
121
+ if (redactedFieldset && !checkableValue.dataset.ga4RedactPermit) {
122
+ text = '[REDACTED]'
123
+ } else {
124
+ text = checkableValue.innerText || this.module.querySelector(`label[for='${window.CSS.escape(id)}']`).innerText
125
+ }
120
126
 
121
127
  if (text) {
122
128
  text = text.replace(/\r?\n|\r/g, ' ')
@@ -83,12 +83,17 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
83
83
  for (var i = 0; i < labels.length; i++) {
84
84
  var label = labels[i]
85
85
  var labelFor = label.getAttribute('for')
86
+ var hiddenInput = label.getAttribute('data-ga4-hidden-input')
86
87
  var input = false
87
- if (labelFor) {
88
+
89
+ if (hiddenInput) {
90
+ input = this.module.querySelector('[id="' + hiddenInput + '"]')
91
+ } else if (labelFor) {
88
92
  input = this.module.querySelector('[id="' + labelFor + '"]')
89
93
  } else {
90
94
  input = label.querySelector('input')
91
95
  }
96
+
92
97
  inputs.push({
93
98
  input: input,
94
99
  label: label
@@ -122,9 +127,13 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
122
127
  // don't include conditional field control in text
123
128
  inputs.splice(i, 1)
124
129
  } else if (elem.checked) {
125
- input.answer = labelText
130
+ var fieldset = elem.closest('fieldset') || null
126
131
 
127
- var fieldset = elem.closest('fieldset')
132
+ if (fieldset.dataset.ga4Redact && !elem.dataset.ga4RedactPermit) {
133
+ input.answer = '[REDACTED]'
134
+ } else {
135
+ input.answer = labelText
136
+ }
128
137
 
129
138
  if (fieldset) {
130
139
  var legend = fieldset.querySelector('legend')
@@ -159,6 +168,8 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
159
168
  this.redacted = true
160
169
  }
161
170
  }
171
+ } else if (inputType === 'file') {
172
+ input.answer = elem.files.length + ' files chosen'
162
173
  } else {
163
174
  // remove the input from those gathered as it has no value
164
175
  inputs.splice(i, 1)
@@ -15,12 +15,6 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
15
15
  this.$module.setCookieConsent = this.setCookieConsent.bind(this)
16
16
  this.$module.rejectCookieConsent = this.rejectCookieConsent.bind(this)
17
17
  this.setupCookieMessage()
18
-
19
- if (window.GOVUK.useSingleConsentApi) {
20
- window.addEventListener('hide-cookie-banner', this.$module.hideCookieMessage)
21
- window.addEventListener('show-cookie-banner', this.$module.showCookieMessage)
22
- window.GOVUK.singleConsent.init()
23
- }
24
18
  }
25
19
 
26
20
  CookieBanner.prototype.setupCookieMessage = function () {
@@ -41,13 +35,10 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
41
35
  this.$rejectCookiesButton.addEventListener('click', this.$module.rejectCookieConsent)
42
36
  }
43
37
 
44
- if (!window.GOVUK.useSingleConsentApi) {
45
- this.showCookieMessage()
46
- }
38
+ this.showCookieMessage()
47
39
  }
48
40
 
49
41
  CookieBanner.prototype.showCookieMessage = function () {
50
- window.removeEventListener('show-cookie-banner', this.$module.showCookieMessage)
51
42
  // Show the cookie banner if not in the cookie settings page or in an iframe
52
43
  if (!this.isInCookiesPage() && !this.isInIframe()) {
53
44
  var shouldHaveCookieMessage = (this.$module && window.GOVUK.cookie('cookies_preferences_set') !== 'true')
@@ -57,9 +48,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
57
48
 
58
49
  // Set the default consent cookie if it isn't already present
59
50
  if (!window.GOVUK.cookie('cookies_policy')) {
60
- if (!window.GOVUK.useSingleConsentApi) {
61
- window.GOVUK.setDefaultConsentCookie()
62
- }
51
+ window.GOVUK.setDefaultConsentCookie()
63
52
  }
64
53
 
65
54
  window.GOVUK.deleteUnconsentedCookies()
@@ -68,12 +57,9 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
68
57
  }
69
58
 
70
59
  CookieBanner.prototype.hideCookieMessage = function (event) {
71
- window.removeEventListener('hide-cookie-banner', this.$module.hideCookieMessage)
72
60
  if (this.$module) {
73
61
  this.$module.hidden = true
74
- if (!window.GOVUK.useSingleConsentApi) {
75
- window.GOVUK.cookie('cookies_preferences_set', 'true', { days: 365 })
76
- }
62
+ window.GOVUK.cookie('cookies_preferences_set', 'true', { days: 365 })
77
63
  }
78
64
 
79
65
  if (event.target) {
@@ -85,31 +71,19 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
85
71
  if (this.$acceptCookiesButton.getAttribute('data-cookie-types') === 'all') {
86
72
  this.$module.querySelector('.gem-c-cookie-banner__confirmation-message--accepted').hidden = false
87
73
  }
88
- if (window.GOVUK.useSingleConsentApi) {
89
- window.GOVUK.singleConsent.setPreferences('accept')
90
- } else {
91
- window.GOVUK.approveAllCookieTypes()
92
- window.GOVUK.cookie('cookies_preferences_set', 'true', { days: 365 })
93
- }
94
-
74
+ window.GOVUK.approveAllCookieTypes()
75
+ window.GOVUK.cookie('cookies_preferences_set', 'true', { days: 365 })
95
76
  this.$module.showConfirmationMessage()
96
77
  this.$module.cookieBannerConfirmationMessage.focus()
97
-
98
- if (!window.GOVUK.useSingleConsentApi) {
99
- window.GOVUK.triggerEvent(window, 'cookie-consent')
100
- }
78
+ window.GOVUK.triggerEvent(window, 'cookie-consent')
101
79
  }
102
80
 
103
81
  CookieBanner.prototype.rejectCookieConsent = function () {
104
82
  this.$module.querySelector('.gem-c-cookie-banner__confirmation-message--rejected').hidden = false
105
83
  this.$module.showConfirmationMessage()
106
84
  this.$module.cookieBannerConfirmationMessage.focus()
107
- if (window.GOVUK.useSingleConsentApi) {
108
- window.GOVUK.singleConsent.setPreferences('reject')
109
- } else {
110
- window.GOVUK.setDefaultConsentCookie()
111
- window.GOVUK.cookie('cookies_preferences_set', 'true', { days: 365 })
112
- }
85
+ window.GOVUK.setDefaultConsentCookie()
86
+ window.GOVUK.cookie('cookies_preferences_set', 'true', { days: 365 })
113
87
  }
114
88
 
115
89
  CookieBanner.prototype.showConfirmationMessage = function () {
@@ -1,7 +1,7 @@
1
1
  /* eslint-env */
2
2
 
3
3
  // This adds in javascript that initialises components and dependencies
4
- // that are provided by Slimmer in public frontend applications.
4
+ // in public frontend applications.
5
5
  // = require ./modules.js
6
6
 
7
7
  document.addEventListener('DOMContentLoaded', function () {
@@ -13,8 +13,7 @@ window.GOVUK.vars.domains = [
13
13
  initialiseGA4: true,
14
14
  id: 'GTM-MG7HG5W',
15
15
  auth: 'bRiZ-jiEHtw6hHpGd6dF9w',
16
- preview: 'env-3',
17
- consentApiUrl: 'staging'
16
+ preview: 'env-3'
18
17
  },
19
18
  {
20
19
  name: 'production',
@@ -24,8 +23,7 @@ window.GOVUK.vars.domains = [
24
23
  'assets.publishing.service.gov.uk'
25
24
  ],
26
25
  initialiseGA4: true,
27
- id: 'GTM-MG7HG5W',
28
- consentApiUrl: 'production'
26
+ id: 'GTM-MG7HG5W'
29
27
  },
30
28
  {
31
29
  name: 'staging',
@@ -37,8 +35,7 @@ window.GOVUK.vars.domains = [
37
35
  initialiseGA4: true,
38
36
  id: 'GTM-MG7HG5W',
39
37
  auth: 'oJWs562CxSIjZKn_GlB5Bw',
40
- preview: 'env-5',
41
- consentApiUrl: 'staging'
38
+ preview: 'env-5'
42
39
  },
43
40
  {
44
41
  name: 'integration',
@@ -50,8 +47,7 @@ window.GOVUK.vars.domains = [
50
47
  initialiseGA4: true,
51
48
  id: 'GTM-MG7HG5W',
52
49
  auth: 'C7iYdcsOlYgGmiUJjZKrHQ',
53
- preview: 'env-4',
54
- consentApiUrl: 'staging'
50
+ preview: 'env-4'
55
51
  },
56
52
  {
57
53
  name: 'devdocs',
@@ -59,7 +55,6 @@ window.GOVUK.vars.domains = [
59
55
  'docs.publishing.service.gov.uk'
60
56
  ],
61
57
  initialiseGA4: true,
62
- id: 'GTM-TNKCK97',
63
- consentApiUrl: 'production'
58
+ id: 'GTM-TNKCK97'
64
59
  }
65
60
  ]
@@ -12,18 +12,12 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
12
12
  document.querySelector('form[data-module=cookie-settings]')
13
13
  .addEventListener('submit', this.$module.submitSettingsForm)
14
14
 
15
- if (window.GOVUK.useSingleConsentApi) {
16
- window.GOVUK.singleConsent.init(this.setInitialFormValues.bind(this))
17
- } else {
18
- this.setInitialFormValues()
19
- }
15
+ this.setInitialFormValues()
20
16
  }
21
17
 
22
18
  CookieSettings.prototype.setInitialFormValues = function () {
23
19
  if (!window.GOVUK.cookie('cookies_policy')) {
24
- if (!window.GOVUK.useSingleConsentApi) {
25
- window.GOVUK.setDefaultConsentCookie()
26
- }
20
+ window.GOVUK.setDefaultConsentCookie()
27
21
  }
28
22
 
29
23
  var currentConsentCookie = window.GOVUK.cookie('cookies_policy')
@@ -68,13 +62,8 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
68
62
  }
69
63
  }
70
64
 
71
- if (window.GOVUK.useSingleConsentApi) {
72
- window.GOVUK.singleConsent.setPreferences(null, options)
73
- } else {
74
- window.GOVUK.setConsentCookie(options)
75
- window.GOVUK.setCookie('cookies_preferences_set', true, { days: 365 })
76
- }
77
-
65
+ window.GOVUK.setConsentCookie(options)
66
+ window.GOVUK.setCookie('cookies_preferences_set', true, { days: 365 })
78
67
  this.showConfirmationMessage()
79
68
  return false
80
69
  }
@@ -3,16 +3,11 @@ module GovukPublishingComponents
3
3
  helper ::Rails.application.helpers
4
4
  protect_from_forgery with: :exception
5
5
  before_action :set_x_frame_options_header
6
- before_action :set_disable_slimmer_header
7
6
 
8
7
  private
9
8
 
10
9
  def set_x_frame_options_header
11
10
  response.headers["X-Frame-Options"] = "ALLOWALL"
12
11
  end
13
-
14
- def set_disable_slimmer_header
15
- response.headers["X-Slimmer-Skip"] = "true"
16
- end
17
12
  end
18
13
  end
@@ -40,6 +40,7 @@ module GovukPublishingComponents
40
40
  gem_version: app.gem_version,
41
41
  gem_version_status: app.gem_version == GovukPublishingComponents::VERSION ? "green" : "red",
42
42
  sass_version: app.sass_version,
43
+ ruby_version: app.ruby_version,
43
44
  }
44
45
  end
45
46
  end
@@ -5,7 +5,8 @@ module GovukPublishingComponents
5
5
  def initialize(application)
6
6
  @application = application
7
7
  @dir = get_directory
8
- @gemfilelock = get_gemfile
8
+ @gemfilelock = get_file("Gemfile.lock")
9
+ @rubyfile = get_file(".ruby-version")
9
10
  end
10
11
 
11
12
  def readable_name
@@ -20,6 +21,10 @@ module GovukPublishingComponents
20
21
  parse_file(@gemfilelock, /sass-embedded \(([^)>=~ ]+)\)/)
21
22
  end
22
23
 
24
+ def ruby_version
25
+ @rubyfile.strip if @rubyfile
26
+ end
27
+
23
28
  private
24
29
 
25
30
  def get_directory
@@ -27,20 +32,20 @@ module GovukPublishingComponents
27
32
  Dir.exist?(app_dir) ? app_dir : false
28
33
  end
29
34
 
30
- def get_gemfile
31
- @dir ? get_gemfile_local : get_gemfile_remote
35
+ def get_file(name)
36
+ @dir ? get_local_file(name) : get_remote_file(name)
32
37
  end
33
38
 
34
- def get_gemfile_local
35
- lockfile = "#{@dir}/Gemfile.lock"
39
+ def get_local_file(name)
40
+ lockfile = "#{@dir}/#{name}"
36
41
  return unless File.file?(lockfile)
37
42
 
38
43
  @source = "local"
39
44
  File.read(lockfile)
40
45
  end
41
46
 
42
- def get_gemfile_remote
43
- uri = URI("https://raw.githubusercontent.com/alphagov/#{@application}/main/Gemfile.lock")
47
+ def get_remote_file(name)
48
+ uri = URI("https://raw.githubusercontent.com/alphagov/#{@application}/main/#{name}")
44
49
  result = Net::HTTP.get_response(uri)
45
50
  if result.is_a?(Net::HTTPSuccess)
46
51
  @source = "remote"
@@ -19,8 +19,6 @@ module GovukPublishingComponents
19
19
  find_components = /(?<=govuk_publishing_components\/components\/)[a-zA-Z_-]+(?=['"])/
20
20
 
21
21
  @find_all_stylesheets = /@import ["']{1}govuk_publishing_components\/all_components/ # if using the all stylesheets option
22
- @find_individual_asset_model = /render_component_stylesheets/ # if using per page component asset loading
23
- @uses_individual_asset_model = false
24
22
  find_stylesheets = /(?<=@import ["']{1}govuk_publishing_components\/components\/)(?!print\/)+[a-zA-Z_-]+(?=['"])/
25
23
 
26
24
  @find_all_javascripts = /\/\/ *= require govuk_publishing_components\/all_components/
@@ -80,7 +78,6 @@ module GovukPublishingComponents
80
78
  jquery_references: @jquery_references.flatten.uniq.sort,
81
79
  component_locations: @component_locations,
82
80
  helper_references: @helper_references,
83
- uses_individual_asset_model: @uses_individual_asset_model,
84
81
  application_components: application_components || [],
85
82
  }
86
83
  end
@@ -144,7 +141,6 @@ module GovukPublishingComponents
144
141
  return %w[all] if src.match(@find_all_stylesheets) && type == "stylesheet"
145
142
  return %w[all] if src.match(@find_all_javascripts) && type == "javascript"
146
143
 
147
- @uses_individual_asset_model = true if src.match(@find_individual_asset_model) && type == "template"
148
144
  matches = src.scan(find)
149
145
  return [] unless matches.any?
150
146
 
@@ -23,7 +23,6 @@ module GovukPublishingComponents
23
23
 
24
24
  results.each do |result|
25
25
  if result[:application_found]
26
- @current_uses_individual_asset_model = result[:uses_individual_asset_model]
27
26
  templates = result[:components_found].find { |c| c[:location] == "template" }
28
27
  stylesheets = result[:components_found].find { |c| c[:location] == "stylesheet" }
29
28
  javascripts = result[:components_found].find { |c| c[:location] == "javascript" }
@@ -69,7 +68,6 @@ module GovukPublishingComponents
69
68
  jquery_references: result[:jquery_references],
70
69
  component_locations: result[:component_locations],
71
70
  helper_references: result[:helper_references],
72
- uses_individual_asset_model: result[:uses_individual_asset_model],
73
71
  application_components: result[:application_components],
74
72
  }
75
73
  else
@@ -127,8 +125,7 @@ module GovukPublishingComponents
127
125
  asset_in_gem = false
128
126
  end
129
127
 
130
- suppress_warning = @current_uses_individual_asset_model && second_location == "stylesheet"
131
- raise_warning = asset_in_gem && !suppress_warning
128
+ raise_warning = asset_in_gem
132
129
 
133
130
  # this raises a warning if the asset exists and isn't included in the application
134
131
  warnings << create_warning(component, "Included in #{first_location} but not #{second_location}") if raise_warning
@@ -28,5 +28,12 @@
28
28
  } %>
29
29
  <% end %>
30
30
  </td>
31
+ <td class="govuk-table__cell">
32
+ <% if app[:ruby_version] %>
33
+ <%= render "govuk_publishing_components/components/tag", {
34
+ text: app[:ruby_version],
35
+ } %>
36
+ <% end %>
37
+ </td>
31
38
  </tr>
32
39
  <% end %>
@@ -1,5 +1,4 @@
1
1
  <% content_for :title, "Applications consistency" %>
2
- <% add_gem_component_stylesheet("table") %>
3
2
 
4
3
  <%= render "govuk_publishing_components/components/back_link", {
5
4
  href: "/component-guide",
@@ -25,6 +24,7 @@
25
24
  <th scope="col" class="govuk-table__header sticky-table-header">Source</th>
26
25
  <th scope="col" class="govuk-table__header sticky-table-header">Gem version</th>
27
26
  <th scope="col" class="govuk-table__header sticky-table-header">Sass version</th>
27
+ <th scope="col" class="govuk-table__header sticky-table-header">Ruby version</th>
28
28
  </tr>
29
29
  </thead>
30
30
  <tbody class="govuk-table__body">
@@ -37,12 +37,6 @@
37
37
  <% github_link = "https://github.com/alphagov/" + application[:dir] + "/blob/main/" %>
38
38
 
39
39
  <% if @other_applications %>
40
- <% if application[:uses_individual_asset_model] %>
41
- <%= render "govuk_publishing_components/components/warning_text", {
42
- text: raw("This application uses <a class=\"govuk-link\" href=\"https://github.com/alphagov/govuk_publishing_components/blob/main/docs/set-up-individual-component-css-loading.md\">per page asset loading</a> for components. Warnings about missing stylesheets have been suppressed."),
43
- } %>
44
- <% end %>
45
-
46
40
  <% application[:warnings].each do |warning| %>
47
41
  <p class="govuk-body">
48
42
  <strong class="govuk-tag">Warn</strong>
@@ -67,8 +61,6 @@
67
61
  <% content = capture do %>
68
62
  <% if item[:value].length > 0 %>
69
63
  <%= item[:value].join(", ") %>
70
- <% elsif application[:uses_individual_asset_model] && item[:name] == "In stylesheets" %>
71
- Uses per page component asset loading
72
64
  <% else %>
73
65
  None
74
66
  <% end %>
@@ -1,9 +1,4 @@
1
- <%
2
- add_gem_component_stylesheet("table")
3
- add_gem_component_stylesheet("select")
4
- add_gem_component_stylesheet("summary-list")
5
- content_for :title, "Component audit"
6
- %>
1
+ <% content_for :title, "Component audit" %>
7
2
 
8
3
  <%= render "govuk_publishing_components/components/back_link", {
9
4
  href: "/component-guide",
@@ -1,6 +1,6 @@
1
1
  <% content_for :title, "#{@component_example.name} example - #{@component_doc.name} component" %>
2
2
  <% content_for :application_stylesheet do %>
3
- <% if @component_doc.source == "application" && application_stylesheet_in_use? %>
3
+ <% if @component_doc.source == "application" %>
4
4
  <%= render "application_stylesheet" %>
5
5
  <% end %>
6
6
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <% content_for :application_stylesheet do %>
2
- <% if @component_doc.source == "application" && application_stylesheet_in_use? %>
2
+ <% if @component_doc.source == "application" %>
3
3
  <%= render "application_stylesheet" %>
4
4
  <% end %>
5
5
  <% end %>
@@ -1,6 +1,6 @@
1
1
  <% content_for :title, "#{@component_doc.name} component" %>
2
2
  <% content_for :application_stylesheet do %>
3
- <% if @component_doc.source == "application" && application_stylesheet_in_use? %>
3
+ <% if @component_doc.source == "application" %>
4
4
  <%= render "application_stylesheet" %>
5
5
  <% end %>
6
6
  <% end %>
@@ -1,6 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("accordion")
3
-
4
2
  local_assigns[:margin_bottom] ||= 6
5
3
  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
6
4
  accordion_helper = GovukPublishingComponents::Presenters::AccordionHelper.new()
@@ -1,6 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("action-link")
3
-
4
2
  local_assigns[:margin_bottom] ||= 0
5
3
  text ||= false
6
4
  href ||= false
@@ -1,5 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("add-another")
3
2
  items ||= []
4
3
  empty ||= ""
5
4
  fieldset_legend ||= ""
@@ -1,6 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("app_promo_banner")
3
-
4
2
  disable_ga4 ||= false
5
3
 
6
4
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
@@ -1,6 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("attachment")
3
-
4
2
  attachment = GovukPublishingComponents::Presenters::AttachmentHelper.new(attachment)
5
3
  target ||= "_self"
6
4
  hide_opendocument_metadata ||= false
@@ -1,6 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("attachment-link")
3
-
4
2
  attachment = GovukPublishingComponents::Presenters::AttachmentHelper.new(attachment)
5
3
  target ||= nil
6
4
  url_data_attributes ||= {}
@@ -1,6 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("back-link")
3
-
4
2
  text ||= t("components.back_link.back")
5
3
  data_attributes ||= {}
6
4
  disable_ga4 ||= false
@@ -1,6 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("back-to-top-link")
3
-
4
2
  text ||= t("components.back_to_top_link.contents", default: "Contents")
5
3
 
6
4
  if href.blank? || text.blank?
@@ -1,6 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("big-number")
3
-
4
2
  big_number_helper = GovukPublishingComponents::Presenters::BigNumberHelper.new(local_assigns)
5
3
 
6
4
  number ||= false
@@ -1,6 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("breadcrumbs")
3
-
4
2
  border ||= false
5
3
  breadcrumbs ||= []
6
4
  collapse_on_mobile ||= false
@@ -1,5 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("button")
3
2
  disable_ga4 ||= false
4
3
 
5
4
  # button_helper.css_classes generates "gem-c-button"
@@ -1,5 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("cards")
3
2
  heading ||= nil
4
3
  items ||= nil
5
4
  sub_heading_level ||= 3
@@ -1,7 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("error-message")
3
- add_gem_component_stylesheet("character-count")
4
-
5
2
  id ||= "character-count-#{SecureRandom.hex(4)}"
6
3
  maxlength ||= nil
7
4
  maxwords ||= nil
@@ -1,5 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("checkboxes")
3
2
  cb_helper = GovukPublishingComponents::Presenters::CheckboxesHelper.new(local_assigns)
4
3
  id = cb_helper.id
5
4
  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
@@ -1,6 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("contents-list")
3
-
4
2
  underline_links ||= false
5
3
  format_numbers ||= false
6
4
  alternative_line_style ||= false
@@ -1,4 +1,3 @@
1
- <% add_gem_component_stylesheet("contents-list-with-body") %>
2
1
  <% block = yield %>
3
2
  <% unless block.empty? %>
4
3
  <%
@@ -1,6 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("contextual-guidance")
3
-
4
2
  id ||= nil
5
3
  title ||= nil
6
4
  content ||= nil
@@ -1,6 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("contextual-sidebar")
3
-
4
2
  disable_ga4 ||= false
5
3
  request.query_parameters[:disable_ga4] = disable_ga4
6
4
  navigation = GovukPublishingComponents::Presenters::ContextualNavigation.new(content_item, request)
@@ -1,6 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("cookie-banner")
3
-
4
2
  id ||= "global-cookie-message"
5
3
  title ||= t("components.cookie_banner.title")
6
4
  text ||= t("components.cookie_banner.text")
@@ -1,6 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("cross-service-header")
3
-
4
2
  service_name ||= nil
5
3
  one_login_navigation_items ||= []
6
4
  service_navigation_items ||= []
@@ -1,6 +1,4 @@
1
1
  <%
2
- add_gem_component_stylesheet("date-input")
3
-
4
2
  id ||= "input-#{SecureRandom.hex(4)}"
5
3
  name ||= nil
6
4
  items ||= [