govuk_publishing_components 29.11.0 → 29.12.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 +16 -5
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/gtm-click-tracking.js +22 -10
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/gtm-page-views.js +98 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4.js +3 -0
- data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +13 -1
- data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-measurer.js +2 -2
- data/app/controllers/govuk_publishing_components/audit_controller.rb +0 -1
- data/app/models/govuk_publishing_components/audit_comparer.rb +0 -1
- data/app/views/govuk_publishing_components/components/_attachment.html.erb +1 -3
- data/app/views/govuk_publishing_components/components/_error_alert.html.erb +6 -3
- data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +3 -3
- data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +3 -8
- data/app/views/govuk_publishing_components/components/docs/accordion.yml +7 -5
- data/app/views/govuk_publishing_components/components/docs/attachment.yml +0 -11
- data/app/views/govuk_publishing_components/components/docs/error_alert.yml +4 -0
- data/lib/govuk_publishing_components/presenters/attachment_helper.rb +0 -20
- data/lib/govuk_publishing_components/presenters/meta_tags.rb +6 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3dd3c468990ad57344b60f3268db6600fc77389ec57fa53688699284bef86502
|
|
4
|
+
data.tar.gz: 2dc30bfb1f489e894134032e8d055e694b4ac45e5eb49e3055ceae8ac0f2b0b7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1d147c794de4cd0cb8210584db07fe0e32a3036d68bded430d2c8d9b45a00b50f78a931d21b48be269f971099f8b054881f3b707694b4f52c3dfa7d00aef7ea2
|
|
7
|
+
data.tar.gz: 786de6478e56d31089cb7745914bc5e38e5e8e63043d2b862777a69a5622b19f7f678c2d43559e179eb1701b3222fd1f384d05530c7f403abcccf1f025a005ef
|
data/README.md
CHANGED
|
@@ -35,19 +35,30 @@ yarn run jasmine:browser
|
|
|
35
35
|
yarn run jasmine:ci
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
###
|
|
38
|
+
### Using the gem
|
|
39
39
|
|
|
40
40
|
- [Install and use this gem](docs/install-and-use.md)
|
|
41
41
|
- [Use a component in your application](docs/use-components.md)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
|
|
43
|
+
### Managing the gem
|
|
44
|
+
|
|
45
45
|
- [Publish/release a new version of the gem](docs/publishing-to-rubygems.md)
|
|
46
46
|
- [Keep this gem in sync with the Design System](docs/upgrade-govuk-frontend.md)
|
|
47
|
-
- [
|
|
47
|
+
- [Move a component from an application to the gem](docs/moving-components-upstream-into-this-gem.md)
|
|
48
|
+
|
|
49
|
+
### Making components
|
|
50
|
+
|
|
51
|
+
- [Generate a new component](docs/generate-a-new-component.md)
|
|
48
52
|
- [Component conventions](docs/component_conventions.md)
|
|
49
53
|
- [Component principles](docs/component_principles.md)
|
|
54
|
+
|
|
55
|
+
### Further documentation
|
|
56
|
+
|
|
57
|
+
- [Testing a component](docs/testing-components.md)
|
|
50
58
|
- [Component auditing](docs/auditing.md)
|
|
59
|
+
- [Code documentation on rubydoc.info](http://www.rubydoc.info/gems/govuk_publishing_components)
|
|
60
|
+
|
|
61
|
+
More documentation can be found in the [docs directory](docs/).
|
|
51
62
|
|
|
52
63
|
## Licence
|
|
53
64
|
|
|
@@ -25,11 +25,23 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
25
25
|
link_url: window.location.href.substring(window.location.origin.length),
|
|
26
26
|
ui: JSON.parse(target.getAttribute('data-gtm-attributes')) || {}
|
|
27
27
|
}
|
|
28
|
-
var ariaExpanded = this.
|
|
28
|
+
var ariaExpanded = this.getClosestAttribute(target, 'aria-expanded')
|
|
29
|
+
/*
|
|
30
|
+
the details component uses an 'open' attribute instead of aria-expanded, so we need to check if we're on a details component.
|
|
31
|
+
since details deletes the 'open' attribute when closed, we need this boolean, otherwise every element which
|
|
32
|
+
doesn't contain an 'open' attr would be pushed to gtm as a closed element.
|
|
33
|
+
*/
|
|
34
|
+
var detailsElement = target.closest('details')
|
|
35
|
+
|
|
29
36
|
if (ariaExpanded) {
|
|
30
|
-
data.ui.state = ariaExpanded === 'false' ? 'opened' : 'closed'
|
|
31
37
|
data.ui.text = data.ui.text || target.innerText
|
|
38
|
+
data.ui.state = (ariaExpanded === 'false') ? 'opened' : 'closed'
|
|
39
|
+
} else if (detailsElement) {
|
|
40
|
+
data.ui.text = data.ui.text || detailsElement.textContent
|
|
41
|
+
var openAttribute = detailsElement.getAttribute('open')
|
|
42
|
+
data.ui.state = (openAttribute == null) ? 'opened' : 'closed'
|
|
32
43
|
}
|
|
44
|
+
|
|
33
45
|
window.dataLayer.push(data)
|
|
34
46
|
}
|
|
35
47
|
}
|
|
@@ -43,15 +55,15 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
43
55
|
}
|
|
44
56
|
}
|
|
45
57
|
|
|
46
|
-
// check
|
|
47
|
-
GtmClickTracking.prototype.
|
|
48
|
-
var
|
|
49
|
-
var
|
|
58
|
+
// check if an attribute exists or contains the attribute
|
|
59
|
+
GtmClickTracking.prototype.getClosestAttribute = function (clicked, attribute) {
|
|
60
|
+
var isAttributeOnElement = clicked.getAttribute(attribute)
|
|
61
|
+
var containsAttribute = clicked.querySelector('[' + attribute + ']')
|
|
50
62
|
|
|
51
|
-
if (
|
|
52
|
-
return
|
|
53
|
-
} else if (
|
|
54
|
-
return
|
|
63
|
+
if (isAttributeOnElement || isAttributeOnElement === '') { // checks for "" as some attribute names can contain no value making them falsy
|
|
64
|
+
return isAttributeOnElement
|
|
65
|
+
} else if (containsAttribute) {
|
|
66
|
+
return containsAttribute.getAttribute(attribute)
|
|
55
67
|
}
|
|
56
68
|
}
|
|
57
69
|
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
;(function (global) {
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
var GOVUK = global.GOVUK || {}
|
|
5
|
+
|
|
6
|
+
GOVUK.Gtm = {
|
|
7
|
+
sendPageView: function () {
|
|
8
|
+
if (window.dataLayer) {
|
|
9
|
+
var data = {
|
|
10
|
+
event: 'config_ready',
|
|
11
|
+
page: {
|
|
12
|
+
location: this.getLocation(),
|
|
13
|
+
referrer: this.getReferrer(),
|
|
14
|
+
title: this.getTitle(),
|
|
15
|
+
status_code: this.getStatusCode()
|
|
16
|
+
},
|
|
17
|
+
publishing: {
|
|
18
|
+
document_type: this.getMetaContent('format'),
|
|
19
|
+
publishing_application: this.getMetaContent('publishing-application'),
|
|
20
|
+
rendering_application: this.getMetaContent('rendering-application'),
|
|
21
|
+
schema_name: this.getMetaContent('schema-name'),
|
|
22
|
+
content_id: this.getMetaContent('content-id')
|
|
23
|
+
},
|
|
24
|
+
taxonomy: {
|
|
25
|
+
section: this.getMetaContent('section'),
|
|
26
|
+
taxon_slug: this.getMetaContent('taxon-slug'),
|
|
27
|
+
taxon_id: this.getMetaContent('taxon-id'),
|
|
28
|
+
themes: this.getMetaContent('themes'),
|
|
29
|
+
taxon_slugs: this.getMetaContent('taxon-slugs'),
|
|
30
|
+
taxon_ids: this.getMetaContent('taxon-ids')
|
|
31
|
+
},
|
|
32
|
+
content: {
|
|
33
|
+
language: this.getLanguage(),
|
|
34
|
+
history: this.getHistory(),
|
|
35
|
+
withdrawn: this.getWithDrawn(),
|
|
36
|
+
first_published_at: this.getMetaContent('first-published-at'),
|
|
37
|
+
updated_at: this.getMetaContent('updated-at'),
|
|
38
|
+
public_updated_at: this.getMetaContent('public-updated-at'),
|
|
39
|
+
publishing_government: this.getMetaContent('publishing-government'),
|
|
40
|
+
political_status: this.getMetaContent('political-status'),
|
|
41
|
+
primary_publishing_organisation: this.getMetaContent('primary-publishing-organisation'),
|
|
42
|
+
organisations: this.getMetaContent('analytics:organisations'),
|
|
43
|
+
world_locations: this.getMetaContent('analytics:world-locations')
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
window.dataLayer.push(data)
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
getLocation: function () {
|
|
51
|
+
return document.location.href
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
getReferrer: function () {
|
|
55
|
+
return document.referrer
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
getTitle: function () {
|
|
59
|
+
return document.title
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
// window.httpStatusCode is set in the source of the error page in static
|
|
63
|
+
// https://github.com/alphagov/static/blob/main/app/views/root/_error_page.html.erb#L32
|
|
64
|
+
getStatusCode: function () {
|
|
65
|
+
if (window.httpStatusCode) {
|
|
66
|
+
return window.httpStatusCode
|
|
67
|
+
} else {
|
|
68
|
+
return 200
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
getMetaContent: function (name) {
|
|
73
|
+
var tag = document.querySelector('meta[name="govuk:' + name + '"]')
|
|
74
|
+
if (tag) {
|
|
75
|
+
return tag.getAttribute('content')
|
|
76
|
+
} else {
|
|
77
|
+
return 'n/a'
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
getLanguage: function () {
|
|
82
|
+
var html = document.querySelector('html')
|
|
83
|
+
return html.getAttribute('lang') || 'n/a'
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
getHistory: function () {
|
|
87
|
+
var history = this.getMetaContent('content-has-history')
|
|
88
|
+
return (history === 'true') ? 'true' : 'false'
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
getWithDrawn: function () {
|
|
92
|
+
var withdrawn = this.getMetaContent('withdrawn')
|
|
93
|
+
return (withdrawn === 'withdrawn') ? 'true' : 'false'
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
global.GOVUK = GOVUK
|
|
98
|
+
})(window)
|
|
@@ -91,7 +91,7 @@ window.GOVUK.Modules.GovukAccordion = window.GOVUKFrontend.Accordion;
|
|
|
91
91
|
var $expanded = this.getContainingSection($section)
|
|
92
92
|
var $parent = $header.parentElement
|
|
93
93
|
|
|
94
|
-
//
|
|
94
|
+
// government-frontend features (inherited from manuals-frontend):
|
|
95
95
|
// Should the target anchor link be within the same page, open section - navigate normally
|
|
96
96
|
// Should the target anchor link be within a different, closed section, open this section
|
|
97
97
|
// Should the target anchor link be within a different page and different, closed section open this section
|
|
@@ -144,6 +144,18 @@ window.GOVUK.Modules.GovukAccordion = window.GOVUKFrontend.Accordion;
|
|
|
144
144
|
var action = expanded ? 'accordionOpened' : 'accordionClosed'
|
|
145
145
|
var options = { transport: 'beacon', label: label }
|
|
146
146
|
|
|
147
|
+
// optional parameters are added to the parent
|
|
148
|
+
// heading not the button that is clicked
|
|
149
|
+
var extraOptions = section.parentElement && section.parentElement.getAttribute('data-track-options')
|
|
150
|
+
|
|
151
|
+
// this uses the same logic as track-click.js handleClick
|
|
152
|
+
// means we can add a custom dimensions on click
|
|
153
|
+
// (such as the index of the accordion on the page)
|
|
154
|
+
if (extraOptions) {
|
|
155
|
+
extraOptions = JSON.parse(extraOptions)
|
|
156
|
+
for (var k in extraOptions) options[k] = extraOptions[k]
|
|
157
|
+
}
|
|
158
|
+
|
|
147
159
|
if (window.GOVUK.analytics && window.GOVUK.analytics.trackEvent) {
|
|
148
160
|
window.GOVUK.analytics.trackEvent('pageElementInteraction', action, options)
|
|
149
161
|
}
|
|
@@ -175,8 +175,8 @@ if (
|
|
|
175
175
|
var measureHTTPProtocol = function () {
|
|
176
176
|
var getEntriesByType = performance.getEntriesByType('navigation')
|
|
177
177
|
|
|
178
|
-
if (getEntriesByType.length > 0) {
|
|
179
|
-
var httpProtocol =
|
|
178
|
+
if (typeof getEntriesByType !== 'undefined' && getEntriesByType.length > 0) {
|
|
179
|
+
var httpProtocol = getEntriesByType[0].nextHopProtocol
|
|
180
180
|
LUX.addData("http-protocol", httpProtocol)
|
|
181
181
|
}
|
|
182
182
|
}
|
|
@@ -83,9 +83,7 @@
|
|
|
83
83
|
<% end %>
|
|
84
84
|
<% end %>
|
|
85
85
|
|
|
86
|
-
<% if attachment.
|
|
87
|
-
<%= link_to "Request an accessible format of this document", "/contact/govuk/request-accessible-format?content_id=#{attachment.owning_document_content_id}&attachment_id=#{attachment.attachment_id}", class: "govuk-link" %>
|
|
88
|
-
<% elsif attachment.alternative_format_contact_email %>
|
|
86
|
+
<% if attachment.alternative_format_contact_email %>
|
|
89
87
|
<%= tag.p t("components.attachment.request_format_text"), class: "gem-c-attachment__metadata" %>
|
|
90
88
|
<%= render "govuk_publishing_components/components/details", {
|
|
91
89
|
title: t("components.attachment.request_format_cta")
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
<%
|
|
2
|
-
|
|
1
|
+
<%
|
|
2
|
+
id ||= nil
|
|
3
|
+
description ||= nil
|
|
4
|
+
data_attributes ||= {}
|
|
5
|
+
%>
|
|
3
6
|
|
|
4
|
-
<%= tag.div class: "gem-c-error-alert", data: { module: "initial-focus" }.merge(data_attributes), role: "alert", tabindex: "-1" do %>
|
|
7
|
+
<%= tag.div id: id, class: "gem-c-error-alert", data: { module: "initial-focus" }.merge(data_attributes), role: "alert", tabindex: "-1" do %>
|
|
5
8
|
<% if description.present? %>
|
|
6
9
|
<%= tag.h2 message, class: "gem-c-error-summary__title" %>
|
|
7
10
|
<%= tag.div description, class: "gem-c-error-summary__body" %>
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
classes << "gem-c-layout-footer--border" if with_border
|
|
7
7
|
%>
|
|
8
8
|
<%= tag.footer class: classes, role: "contentinfo" do %>
|
|
9
|
-
<div class="govuk-width-container"
|
|
9
|
+
<div class="govuk-width-container">
|
|
10
10
|
<% if navigation.any? %>
|
|
11
|
-
<div class="govuk-footer__navigation">
|
|
11
|
+
<div class="govuk-footer__navigation" data-module="gem-track-click" data-track-links-only>
|
|
12
12
|
<% navigation.each do |item| %>
|
|
13
13
|
<% if item[:items] %>
|
|
14
14
|
<%
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
<div class="govuk-footer__meta-item govuk-footer__meta-item--grow">
|
|
61
61
|
<% if meta.any? %>
|
|
62
62
|
<h2 class="govuk-visually-hidden"><%= t("components.layout_footer.support_links") %></h2>
|
|
63
|
-
<ul class="govuk-footer__inline-list govuk-!-display-none-print">
|
|
63
|
+
<ul class="govuk-footer__inline-list govuk-!-display-none-print" data-module="gem-track-click" data-track-links-only>
|
|
64
64
|
<% meta[:items].each do |item| %>
|
|
65
65
|
<li class="govuk-footer__inline-list-item">
|
|
66
66
|
<%
|
data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb
CHANGED
|
@@ -15,12 +15,11 @@
|
|
|
15
15
|
hide_navigation_menu_text = t("components.layout_super_navigation_header.menu_toggle_label.hide", :label => "navigation")
|
|
16
16
|
show_navigation_menu_text = t("components.layout_super_navigation_header.menu_toggle_label.show", :label => "navigation")
|
|
17
17
|
%>
|
|
18
|
-
<header role="banner" class="gem-c-layout-super-navigation-header">
|
|
18
|
+
<header role="banner" class="gem-c-layout-super-navigation-header" data-module="gem-track-click" data-track-links-only>
|
|
19
19
|
<div class="gem-c-layout-super-navigation-header__container govuk-width-container govuk-clearfix">
|
|
20
20
|
<div class="gem-c-layout-super-navigation-header__header-logo">
|
|
21
21
|
<a
|
|
22
22
|
class="govuk-header__link govuk-header__link--homepage"
|
|
23
|
-
data-module="gem-track-click"
|
|
24
23
|
data-track-action="logoLink"
|
|
25
24
|
data-track-category="headerClicked"
|
|
26
25
|
data-track-label="<%= logo_link %>"
|
|
@@ -100,7 +99,6 @@
|
|
|
100
99
|
<%= link_to link[:label], link[:href], {
|
|
101
100
|
class: "gem-c-layout-super-navigation-header__navigation-item-link",
|
|
102
101
|
data: {
|
|
103
|
-
module: "gem-track-click",
|
|
104
102
|
track_action: "#{tracking_label}Link",
|
|
105
103
|
track_category: "headerClicked",
|
|
106
104
|
track_label: link[:href],
|
|
@@ -141,9 +139,9 @@
|
|
|
141
139
|
<div class="govuk-grid-row">
|
|
142
140
|
<div class="govuk-grid-column-one-third-from-desktop">
|
|
143
141
|
<% if link[:description].present? %>
|
|
144
|
-
<
|
|
142
|
+
<h3 class="govuk-body-l gem-c-layout-super-navigation-header__menu-description">
|
|
145
143
|
<%= link[:description] %>
|
|
146
|
-
</
|
|
144
|
+
</h3>
|
|
147
145
|
<% end %>
|
|
148
146
|
</div>
|
|
149
147
|
<div class="govuk-grid-column-two-thirds-from-desktop">
|
|
@@ -159,7 +157,6 @@
|
|
|
159
157
|
<%= link_to item[:label], item[:href], {
|
|
160
158
|
class: link_classes,
|
|
161
159
|
data: {
|
|
162
|
-
module: "gem-track-click",
|
|
163
160
|
track_action: "#{tracking_label}Link",
|
|
164
161
|
track_category: "headerClicked",
|
|
165
162
|
track_label: item[:href],
|
|
@@ -183,7 +180,6 @@
|
|
|
183
180
|
"gem-c-layout-super-navigation-header__navigation-second-footer-link",
|
|
184
181
|
],
|
|
185
182
|
data: {
|
|
186
|
-
module: "gem-track-click",
|
|
187
183
|
track_action: "#{tracking_label}Link",
|
|
188
184
|
track_category: "headerClicked",
|
|
189
185
|
track_label: item[:href],
|
|
@@ -312,7 +308,6 @@
|
|
|
312
308
|
"gem-c-layout-super-navigation-header__popular-link",
|
|
313
309
|
],
|
|
314
310
|
data: {
|
|
315
|
-
module: "gem-track-click",
|
|
316
311
|
track_action: "popularLink",
|
|
317
312
|
track_category: "headerClicked",
|
|
318
313
|
track_label: popular_link[:href],
|
|
@@ -195,11 +195,8 @@ examples:
|
|
|
195
195
|
gtm: gtm-accordion
|
|
196
196
|
ga: ga-accordion
|
|
197
197
|
data_attributes_show_all:
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
ui:
|
|
201
|
-
type: test
|
|
202
|
-
text: something
|
|
198
|
+
gtm-event-name: example
|
|
199
|
+
gtm-attributes: "{ 'ui': { 'type': 'type value', 'section': 'section value' } }"
|
|
203
200
|
items:
|
|
204
201
|
- heading:
|
|
205
202
|
text: Writing well for the web
|
|
@@ -337,6 +334,8 @@ examples:
|
|
|
337
334
|
To switch on Google Analytics for each section, on click, pass `track_sections: true` the values passed on open will be
|
|
338
335
|
`Event Action: accordionOpened` / `accordionClosed` `Event Category: pageElementInteraction` and the `Event Label` being the heading text.
|
|
339
336
|
|
|
337
|
+
If `track_options` in an item is set, then it is possible to pass a custom dimension when the section is clicked.
|
|
338
|
+
|
|
340
339
|
(`track_show_all_clicks: true` can be added to track the "Show all sections" button as well, if required)
|
|
341
340
|
data:
|
|
342
341
|
track_sections: true
|
|
@@ -346,6 +345,9 @@ examples:
|
|
|
346
345
|
id: writing-well-for-the-web-3
|
|
347
346
|
content:
|
|
348
347
|
html: <p class="govuk-body">This is content for accordion 1 of 2</p><p class="govuk-body">This content contains a <a href="#anchor-nav-test" class="govuk-link">link</a></p>
|
|
348
|
+
data_attributes:
|
|
349
|
+
track_options:
|
|
350
|
+
dimension114: 1
|
|
349
351
|
- heading:
|
|
350
352
|
text: Writing well for specialists
|
|
351
353
|
content:
|
|
@@ -76,17 +76,6 @@ examples:
|
|
|
76
76
|
content_type: application/pdf
|
|
77
77
|
file_size: 20000
|
|
78
78
|
alternative_format_contact_email: defra.helpline@defra.gsi.gov.uk
|
|
79
|
-
with_link_to_request_accessible_format_form:
|
|
80
|
-
data:
|
|
81
|
-
attachment:
|
|
82
|
-
title: "Department for Transport information asset register"
|
|
83
|
-
url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/747661/department-for-transport-information-asset-register.csv
|
|
84
|
-
filename: department-for-transport-information-asset-register.csv
|
|
85
|
-
content_type: application/pdf
|
|
86
|
-
file_size: 20000
|
|
87
|
-
owning_document_content_id: 456_abc
|
|
88
|
-
attachment_id: 123
|
|
89
|
-
alternative_format_contact_email: govuk_publishing_components@example.com
|
|
90
79
|
with_data_attributes:
|
|
91
80
|
data:
|
|
92
81
|
attachment:
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
module GovukPublishingComponents
|
|
2
2
|
module Presenters
|
|
3
3
|
class AttachmentHelper
|
|
4
|
-
# Various departments are taking part in a pilot to use a form
|
|
5
|
-
# rather than direct email for users to request accessible formats. When the pilot
|
|
6
|
-
# scheme is rolled out further this can be removed.
|
|
7
|
-
# Currently DfE, DWP and DVSA are participating in the pilot.
|
|
8
|
-
EMAILS_IN_ACCESSIBLE_FORMAT_REQUEST_PILOT = %w[govuk_publishing_components@example.com
|
|
9
|
-
alternative.formats@education.gov.uk].freeze
|
|
10
|
-
|
|
11
4
|
delegate :opendocument?, :document?, :spreadsheet?, to: :content_type
|
|
12
5
|
|
|
13
6
|
attr_reader :attachment_data
|
|
@@ -15,7 +8,6 @@ module GovukPublishingComponents
|
|
|
15
8
|
# Expects a hash of attachment data
|
|
16
9
|
# * title and url are required
|
|
17
10
|
# * content_type, filename, file_size, number of pages, alternative_format_contact_email can be provided
|
|
18
|
-
# * attachment_id and owning_document_content_id are required to use the accessible format request form
|
|
19
11
|
def initialize(attachment_data)
|
|
20
12
|
@attachment_data = attachment_data.with_indifferent_access
|
|
21
13
|
end
|
|
@@ -55,14 +47,6 @@ module GovukPublishingComponents
|
|
|
55
47
|
attachment_data[:alternative_format_contact_email]
|
|
56
48
|
end
|
|
57
49
|
|
|
58
|
-
def attachment_id
|
|
59
|
-
attachment_data[:attachment_id]
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def owning_document_content_id
|
|
63
|
-
attachment_data[:owning_document_content_id]
|
|
64
|
-
end
|
|
65
|
-
|
|
66
50
|
def reference
|
|
67
51
|
reference = []
|
|
68
52
|
reference << "ISBN #{attachment_data[:isbn]}" if attachment_data[:isbn].present?
|
|
@@ -87,10 +71,6 @@ module GovukPublishingComponents
|
|
|
87
71
|
attachment_data[:command_paper_number].present? || attachment_data[:hoc_paper_number].present? || attachment_data[:unnumbered_command_paper].eql?(true) || attachment_data[:unnumbered_hoc_paper].eql?(true)
|
|
88
72
|
end
|
|
89
73
|
|
|
90
|
-
def display_accessible_format_request_form_link?
|
|
91
|
-
EMAILS_IN_ACCESSIBLE_FORMAT_REQUEST_PILOT.include?(alternative_format_contact_email) && owning_document_content_id.present? && attachment_id.present?
|
|
92
|
-
end
|
|
93
|
-
|
|
94
74
|
class SupportedContentType
|
|
95
75
|
attr_reader :content_type_data
|
|
96
76
|
|
|
@@ -39,6 +39,12 @@ module GovukPublishingComponents
|
|
|
39
39
|
meta_tags["govuk:content-has-history"] = "true" if has_content_history?
|
|
40
40
|
meta_tags["govuk:static-analytics:strip-dates"] = "true" if should_strip_dates_pii?(content_item, local_assigns)
|
|
41
41
|
meta_tags["govuk:static-analytics:strip-postcodes"] = "true" if should_strip_postcode_pii?(content_item, local_assigns)
|
|
42
|
+
meta_tags["govuk:first-published-at"] = content_item[:first_published_at] if content_item[:first_published_at]
|
|
43
|
+
meta_tags["govuk:updated-at"] = content_item[:updated_at] if content_item[:updated_at]
|
|
44
|
+
meta_tags["govuk:public-updated-at"] = content_item[:public_updated_at] if content_item[:public_updated_at]
|
|
45
|
+
primary_publisher = content_item.dig(:links, :primary_publishing_organisation)
|
|
46
|
+
primary_publisher = primary_publisher.first[:title] if primary_publisher
|
|
47
|
+
meta_tags["govuk:primary-publishing-organisation"] = primary_publisher if primary_publisher
|
|
42
48
|
|
|
43
49
|
meta_tags
|
|
44
50
|
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: 29.
|
|
4
|
+
version: 29.12.0
|
|
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: 2022-
|
|
11
|
+
date: 2022-06-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: govuk_app_config
|
|
@@ -435,6 +435,7 @@ files:
|
|
|
435
435
|
- app/assets/javascripts/govuk_publishing_components/all_components.js
|
|
436
436
|
- app/assets/javascripts/govuk_publishing_components/analytics-ga4.js
|
|
437
437
|
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/gtm-click-tracking.js
|
|
438
|
+
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/gtm-page-views.js
|
|
438
439
|
- app/assets/javascripts/govuk_publishing_components/analytics.js
|
|
439
440
|
- app/assets/javascripts/govuk_publishing_components/analytics/analytics.js
|
|
440
441
|
- app/assets/javascripts/govuk_publishing_components/analytics/auto-scroll-tracker.js
|
|
@@ -1918,7 +1919,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
1918
1919
|
- !ruby/object:Gem::Version
|
|
1919
1920
|
version: '0'
|
|
1920
1921
|
requirements: []
|
|
1921
|
-
rubygems_version: 3.3.
|
|
1922
|
+
rubygems_version: 3.3.16
|
|
1922
1923
|
signing_key:
|
|
1923
1924
|
specification_version: 4
|
|
1924
1925
|
summary: A gem to document components in GOV.UK frontend applications
|