govuk_publishing_components 16.22.0 → 16.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/_contents-list.scss +7 -7
- data/app/assets/stylesheets/govuk_publishing_components/components/_document-list.scss +13 -13
- data/app/assets/stylesheets/govuk_publishing_components/components/_error-alert.scss +9 -9
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_contents-list.scss +1 -1
- data/app/views/govuk_publishing_components/components/_attachment.html.erb +5 -2
- data/app/views/govuk_publishing_components/components/_attachment_link.html.erb +6 -1
- data/app/views/govuk_publishing_components/components/docs/attachment.yml +10 -0
- data/app/views/govuk_publishing_components/components/docs/attachment_link.yml +7 -0
- data/app/views/govuk_publishing_components/components/docs/error_alert.yml +1 -1
- data/config/locales/cy.yml +2 -0
- data/lib/govuk_publishing_components/presenters/button_helper.rb +2 -1
- data/lib/govuk_publishing_components/presenters/machine_readable/article_schema.rb +9 -121
- data/lib/govuk_publishing_components/presenters/machine_readable/creative_work_schema.rb +141 -0
- data/lib/govuk_publishing_components/presenters/machine_readable/organisation_schema.rb +15 -2
- data/lib/govuk_publishing_components/presenters/machine_readable/page.rb +8 -0
- data/lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb +32 -0
- data/lib/govuk_publishing_components/presenters/machine_readable/search_results_page_schema.rb +1 -1
- data/lib/govuk_publishing_components/presenters/schema_org.rb +2 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/accessible-autocomplete/package.json +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 499dc46add59311a3228553f892592d6bd315d5c887065a8f9c081e624a17e2e
|
4
|
+
data.tar.gz: f783e7aa840aea99df1f17df0004fd384c24188729b84b5a85b21888fd958df1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58f75ee4333cf62f89c8dca38bba7307e011397d8dad70469cc91e23add2a38e72951a0010365551358d71d14a41168d4fd8420a78ba8dd930510b0a3cf00136
|
7
|
+
data.tar.gz: d92eb082c8e43725c177f7852d85b1dc23cc0eaf9cc4c2d7722c0335425b4f89233750ba590197f1079b08e0d6a45cdf6d8665a8003c482ec897c6913ecb7e5e
|
@@ -4,10 +4,10 @@
|
|
4
4
|
// Always render the contents list above a
|
5
5
|
// back to contents link
|
6
6
|
position: relative;
|
7
|
-
margin: 0 0
|
7
|
+
margin: 0 0 govuk-spacing(4) 0;
|
8
8
|
z-index: 1;
|
9
|
-
background:
|
10
|
-
box-shadow: 0 20px 15px -10px
|
9
|
+
background: govuk-colour("white");
|
10
|
+
box-shadow: 0 20px 15px -10px govuk-colour("white");
|
11
11
|
}
|
12
12
|
|
13
13
|
.gem-c-contents-list__title {
|
@@ -49,17 +49,17 @@
|
|
49
49
|
}
|
50
50
|
|
51
51
|
.gem-c-contents-list__list-item {
|
52
|
-
padding-top:
|
52
|
+
padding-top: govuk-spacing(2);
|
53
53
|
line-height: 1.3;
|
54
54
|
list-style-type: none;
|
55
55
|
|
56
|
-
@include media(tablet) {
|
57
|
-
padding-top:
|
56
|
+
@include govuk-media-query($from: tablet) {
|
57
|
+
padding-top: govuk-spacing(6) / 4;
|
58
58
|
}
|
59
59
|
}
|
60
60
|
|
61
61
|
.gem-c-contents-list__list-item--dashed {
|
62
|
-
$contents-spacing:
|
62
|
+
$contents-spacing: govuk-spacing(5);
|
63
63
|
margin-left: $contents-spacing;
|
64
64
|
padding-right: $contents-spacing;
|
65
65
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
.gem-c-document-list {
|
2
2
|
@include govuk-text-colour;
|
3
|
-
@include
|
3
|
+
@include govuk-font(19);
|
4
4
|
margin: 0;
|
5
5
|
padding: 0;
|
6
6
|
}
|
7
7
|
|
8
8
|
.gem-c-document-list__item {
|
9
9
|
overflow: hidden;
|
10
|
-
margin-bottom:
|
11
|
-
padding-bottom:
|
12
|
-
border-bottom: 1px solid $border-colour;
|
10
|
+
margin-bottom: govuk-spacing(2);
|
11
|
+
padding-bottom: govuk-spacing(2);
|
12
|
+
border-bottom: 1px solid $govuk-border-colour;
|
13
13
|
list-style: none;
|
14
14
|
|
15
15
|
&:last-child {
|
@@ -20,21 +20,21 @@
|
|
20
20
|
.gem-c-document-list__item-title {
|
21
21
|
@include govuk-link-common;
|
22
22
|
@include govuk-link-style-default;
|
23
|
-
@include
|
23
|
+
@include govuk-font($size: 19, $weight: bold);
|
24
24
|
display: inline-block;
|
25
25
|
}
|
26
26
|
|
27
27
|
.gem-c-document-list__item-title--context {
|
28
|
-
margin-right:
|
28
|
+
margin-right: govuk-spacing(2);
|
29
29
|
|
30
30
|
.direction-rtl & {
|
31
31
|
margin-right: 0;
|
32
|
-
margin-left:
|
32
|
+
margin-left: govuk-spacing(2);
|
33
33
|
}
|
34
34
|
}
|
35
35
|
|
36
36
|
.gem-c-document-list__item-context {
|
37
|
-
color:
|
37
|
+
color: govuk-colour("grey-1");
|
38
38
|
}
|
39
39
|
|
40
40
|
.gem-c-document-list__item-description {
|
@@ -49,23 +49,23 @@
|
|
49
49
|
|
50
50
|
.gem-c-document-list__attribute {
|
51
51
|
@include govuk-text-colour;
|
52
|
-
@include
|
52
|
+
@include govuk-font(14);
|
53
53
|
display: inline-block;
|
54
54
|
list-style: none;
|
55
|
-
padding-right:
|
55
|
+
padding-right: govuk-spacing(4);
|
56
56
|
|
57
57
|
.direction-rtl & {
|
58
58
|
padding-right: 0;
|
59
|
-
padding-left:
|
59
|
+
padding-left: govuk-spacing(4);
|
60
60
|
}
|
61
61
|
}
|
62
62
|
|
63
63
|
.gem-c-document-list--bottom-margin {
|
64
|
-
margin-bottom:
|
64
|
+
margin-bottom: govuk-spacing(4);
|
65
65
|
}
|
66
66
|
|
67
67
|
.gem-c-document-list--top-margin {
|
68
|
-
margin-top:
|
68
|
+
margin-top: govuk-spacing(4);
|
69
69
|
}
|
70
70
|
|
71
71
|
.gem-c-document-list__multi-list {
|
@@ -1,33 +1,33 @@
|
|
1
1
|
.gem-c-error-alert {
|
2
2
|
color: $gem-text-colour;
|
3
|
-
padding:
|
3
|
+
padding: govuk-spacing(3);
|
4
4
|
border: $gem-border-width-mobile solid $gem-error-colour;
|
5
5
|
@include govuk-responsive-margin(8, "bottom");
|
6
6
|
|
7
|
-
@include media(tablet) {
|
8
|
-
padding:
|
7
|
+
@include govuk-media-query($from: tablet) {
|
8
|
+
padding: govuk-spacing(4);
|
9
9
|
border-width: $gem-border-width-tablet;
|
10
10
|
}
|
11
11
|
}
|
12
12
|
|
13
13
|
.gem-c-error-alert__message {
|
14
|
-
@include
|
14
|
+
@include govuk-font(19, $weight: bold);
|
15
15
|
margin: 0;
|
16
16
|
}
|
17
17
|
|
18
18
|
.gem-c-error-summary__title {
|
19
19
|
margin-top: 0;
|
20
|
-
margin-bottom:
|
20
|
+
margin-bottom: govuk-spacing(3);
|
21
21
|
|
22
|
-
@include media(tablet) {
|
23
|
-
margin-bottom:
|
22
|
+
@include govuk-media-query($from: tablet) {
|
23
|
+
margin-bottom: govuk-spacing(4);
|
24
24
|
}
|
25
25
|
|
26
|
-
@include
|
26
|
+
@include govuk-font(24, $weight: bold);
|
27
27
|
}
|
28
28
|
|
29
29
|
.gem-c-error-summary__body {
|
30
|
-
@include
|
30
|
+
@include govuk-font(19);
|
31
31
|
margin: 0;
|
32
32
|
}
|
33
33
|
|
@@ -3,6 +3,7 @@
|
|
3
3
|
target ||= "_self"
|
4
4
|
hide_opendocument_metadata ||= false
|
5
5
|
attributes = []
|
6
|
+
data_attributes ||= {}
|
6
7
|
|
7
8
|
if attachment.content_type_name
|
8
9
|
content = if attachment.content_type_abbr
|
@@ -35,7 +36,8 @@
|
|
35
36
|
class: "govuk-link",
|
36
37
|
target: target,
|
37
38
|
tabindex: "-1",
|
38
|
-
"aria-hidden": true
|
39
|
+
"aria-hidden": true,
|
40
|
+
data: data_attributes do %>
|
39
41
|
<% if attachment.document? %>
|
40
42
|
<%= render "govuk_publishing_components/components/attachment/thumbnail_document.svg" %>
|
41
43
|
<% elsif attachment.spreadsheet? %>
|
@@ -50,7 +52,8 @@
|
|
50
52
|
<%= tag.h2 class: "gem-c-attachment__title" do %>
|
51
53
|
<%= link_to attachment.title, attachment.url,
|
52
54
|
class: "govuk-link",
|
53
|
-
target: target
|
55
|
+
target: target,
|
56
|
+
data: data_attributes %>
|
54
57
|
<% end %>
|
55
58
|
|
56
59
|
<% if attributes.any? %>
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<%
|
2
2
|
attachment = GovukPublishingComponents::Presenters::Attachment.new(attachment)
|
3
3
|
target ||= nil
|
4
|
+
data_attributes ||= {}
|
4
5
|
attributes = []
|
5
6
|
if attachment.content_type_name
|
6
7
|
content = if attachment.content_type_abbr
|
@@ -29,6 +30,10 @@
|
|
29
30
|
end
|
30
31
|
%>
|
31
32
|
<%= tag.span(class: "gem-c-attachment-link") do %>
|
32
|
-
<%= link_to(attachment.title, attachment.url,
|
33
|
+
<%= link_to(attachment.title, attachment.url,
|
34
|
+
class: "govuk-link",
|
35
|
+
target: target,
|
36
|
+
data: data_attributes) %>
|
37
|
+
|
33
38
|
<%= raw("(#{attributes.join(', ')})") if attributes.any? %>
|
34
39
|
<% end %>
|
@@ -78,3 +78,13 @@ examples:
|
|
78
78
|
content_type: application/pdf
|
79
79
|
file_size: 20000
|
80
80
|
alternative_format_contact_email: defra.helpline@defra.gsi.gov.uk
|
81
|
+
with_data_attributes:
|
82
|
+
data:
|
83
|
+
attachment:
|
84
|
+
title: "Department for Transport information asset register"
|
85
|
+
url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/747661/department-for-transport-information-asset-register.csv
|
86
|
+
filename: department-for-transport-information-asset-register.csv
|
87
|
+
content_type: application/pdf
|
88
|
+
file_size: 20000
|
89
|
+
data_attributes:
|
90
|
+
gtm: "attachment-preview"
|
@@ -60,3 +60,10 @@ examples:
|
|
60
60
|
title: "Temporary snow ploughs: guidance note"
|
61
61
|
url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/259634/temporary-snow-ploughs.pdf
|
62
62
|
target: _blank
|
63
|
+
with_data_attributes:
|
64
|
+
data:
|
65
|
+
attachment:
|
66
|
+
title: "Temporary snow ploughs: guidance note"
|
67
|
+
url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/259634/temporary-snow-ploughs.pdf
|
68
|
+
data_attributes:
|
69
|
+
gtm: "attachment-preview"
|
data/config/locales/cy.yml
CHANGED
@@ -4,7 +4,8 @@ module GovukPublishingComponents
|
|
4
4
|
module Presenters
|
5
5
|
class ButtonHelper
|
6
6
|
attr_reader :href, :text, :title, :info_text, :rel, :data_attributes,
|
7
|
-
|
7
|
+
:margin_bottom, :inline_layout, :target, :type, :start,
|
8
|
+
:secondary, :secondary_quiet, :destructive
|
8
9
|
|
9
10
|
def initialize(local_assigns)
|
10
11
|
@href = local_assigns[:href]
|
@@ -5,38 +5,19 @@ module GovukPublishingComponents
|
|
5
5
|
|
6
6
|
def initialize(page)
|
7
7
|
@page = page
|
8
|
-
@pages = {}
|
9
8
|
end
|
10
9
|
|
11
10
|
def structured_data
|
12
11
|
# http://schema.org/Article
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
"@id" => page.canonical_url,
|
19
|
-
},
|
20
|
-
"headline" => page.title,
|
21
|
-
"datePublished" => page.content_item["first_published_at"],
|
22
|
-
"dateModified" => page.content_item["public_updated_at"],
|
23
|
-
"description" => page.description,
|
24
|
-
"publisher" => {
|
25
|
-
"@type" => "Organization",
|
26
|
-
"name" => "GOV.UK",
|
27
|
-
"url" => "https://www.gov.uk",
|
28
|
-
"logo" => {
|
29
|
-
"@type" => "ImageObject",
|
30
|
-
"url" => page.logo_url,
|
31
|
-
}
|
32
|
-
}
|
33
|
-
}.merge(image_schema).merge(author_schema).merge(body).merge(is_part_of).merge(about).merge(has_part)
|
12
|
+
data = CreativeWorkSchema.new(@page).structured_data
|
13
|
+
.merge(body)
|
14
|
+
.merge(search_action)
|
15
|
+
data["@type"] = "Article"
|
16
|
+
data
|
34
17
|
end
|
35
18
|
|
36
19
|
private
|
37
20
|
|
38
|
-
attr_reader :presenter
|
39
|
-
|
40
21
|
# Not all formats have a `body` - some have their content split over
|
41
22
|
# multiple fields. In this case we'll skip the `articleBody` field
|
42
23
|
def body
|
@@ -47,104 +28,11 @@ module GovukPublishingComponents
|
|
47
28
|
}
|
48
29
|
end
|
49
30
|
|
50
|
-
def
|
51
|
-
{
|
52
|
-
"image" => page.has_image? ? [page.image_url] : page.image_placeholders
|
53
|
-
}
|
54
|
-
end
|
55
|
-
|
56
|
-
def author_schema
|
57
|
-
return {} unless publishing_organisation
|
58
|
-
|
59
|
-
{
|
60
|
-
"author" => {
|
61
|
-
"@type" => "Organization",
|
62
|
-
"name" => publishing_organisation["title"],
|
63
|
-
"url" => Plek.current.website_root + publishing_organisation["base_path"],
|
64
|
-
}
|
65
|
-
}
|
66
|
-
end
|
67
|
-
|
68
|
-
def publishing_organisation
|
69
|
-
page.content_item.dig("links", "primary_publishing_organisation").to_a.first
|
70
|
-
end
|
71
|
-
|
72
|
-
def is_part_of
|
73
|
-
return {} unless step_by_step_schemas.any? || document_collections.any?
|
74
|
-
|
75
|
-
{
|
76
|
-
"isPartOf" => document_collections + step_by_step_schemas
|
77
|
-
}
|
78
|
-
end
|
79
|
-
|
80
|
-
def step_by_step_schemas
|
81
|
-
# We could include `related_to_step_navs` eventually too, but initially
|
82
|
-
# link to those that we render in the "step_by_step_nav_related" component
|
83
|
-
@step_by_step_schemas ||= fetch_step_by_step_schemas
|
84
|
-
end
|
85
|
-
|
86
|
-
def fetch_step_by_step_schemas
|
87
|
-
page.content_item.dig("links", "part_of_step_navs").to_a.map do |step_by_step|
|
88
|
-
step_by_step_page = linked_page(step_by_step)
|
89
|
-
structured_data = HowToSchema.new(step_by_step_page.canonical_url).structured_data
|
90
|
-
|
91
|
-
structured_data.merge(image_schema)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def linked_page(step_by_step)
|
96
|
-
Page.new(
|
97
|
-
content_item: step_by_step,
|
98
|
-
schema: :article,
|
99
|
-
logo_url: page.logo_url,
|
100
|
-
image_placeholders: page.image_placeholders
|
101
|
-
)
|
102
|
-
end
|
103
|
-
|
104
|
-
def has_part
|
105
|
-
return {} unless collection_pages("documents").any?
|
106
|
-
|
107
|
-
{
|
108
|
-
"hasPart" => collection_pages("documents").map { |document| HasPartSchema.new(document).structured_data }
|
109
|
-
}
|
110
|
-
end
|
111
|
-
|
112
|
-
def document_collections
|
113
|
-
@document_collections ||= collection_pages("document_collections")
|
114
|
-
.map { |document| IsPartOfSchema.new(document).structured_data }
|
115
|
-
end
|
116
|
-
|
117
|
-
def collection_pages(linked_type)
|
118
|
-
@pages[linked_type] ||= fetch_collection_pages(linked_type)
|
119
|
-
end
|
120
|
-
|
121
|
-
def fetch_collection_pages(linked_type)
|
122
|
-
page.content_item.dig("links", linked_type).to_a.map { |document| document["web_url"] }
|
123
|
-
end
|
124
|
-
|
125
|
-
def about
|
126
|
-
return {} unless live_taxons.any?
|
127
|
-
|
128
|
-
{
|
129
|
-
"about" => linked_taxons
|
130
|
-
}
|
131
|
-
end
|
132
|
-
|
133
|
-
def live_taxons
|
134
|
-
taxons = page.content_item.dig("links", "taxons")
|
135
|
-
return [] unless taxons
|
136
|
-
|
137
|
-
taxons.select { |taxon| taxon["phase"] == "live" }
|
138
|
-
end
|
31
|
+
def search_action
|
32
|
+
return {} unless page.document_type == "manual"
|
139
33
|
|
140
|
-
|
141
|
-
|
142
|
-
{
|
143
|
-
"@context" => "http://schema.org",
|
144
|
-
"@type" => "Thing",
|
145
|
-
"sameAs" => taxon["web_url"]
|
146
|
-
}
|
147
|
-
end
|
34
|
+
manuals_facet_params = { manual: page.base_path }
|
35
|
+
PotentialSearchActionSchema.new(manuals_facet_params).structured_data
|
148
36
|
end
|
149
37
|
end
|
150
38
|
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
module GovukPublishingComponents
|
2
|
+
module Presenters
|
3
|
+
class CreativeWorkSchema
|
4
|
+
attr_reader :page
|
5
|
+
|
6
|
+
def initialize(page)
|
7
|
+
@page = page
|
8
|
+
@pages = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def structured_data
|
12
|
+
# http://schema.org/CreativeWork
|
13
|
+
{
|
14
|
+
"@context" => "http://schema.org",
|
15
|
+
"@type" => "CreativeWork",
|
16
|
+
"mainEntityOfPage" => {
|
17
|
+
"@type" => "WebPage",
|
18
|
+
"@id" => page.canonical_url,
|
19
|
+
},
|
20
|
+
"headline" => page.title,
|
21
|
+
"datePublished" => page.content_item["first_published_at"],
|
22
|
+
"dateModified" => page.content_item["public_updated_at"],
|
23
|
+
"description" => page.description,
|
24
|
+
"publisher" => {
|
25
|
+
"@type" => "Organization",
|
26
|
+
"name" => "GOV.UK",
|
27
|
+
"url" => "https://www.gov.uk",
|
28
|
+
"logo" => {
|
29
|
+
"@type" => "ImageObject",
|
30
|
+
"url" => page.logo_url,
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}.merge(image_schema).merge(author_schema).merge(is_part_of).merge(about).merge(has_part)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
attr_reader :presenter
|
39
|
+
|
40
|
+
def image_schema
|
41
|
+
{
|
42
|
+
"image" => page.has_image? ? [page.image_url] : page.image_placeholders
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def author_schema
|
47
|
+
return {} unless publishing_organisation
|
48
|
+
|
49
|
+
{
|
50
|
+
"author" => {
|
51
|
+
"@type" => "Organization",
|
52
|
+
"name" => publishing_organisation["title"],
|
53
|
+
"url" => Plek.current.website_root + publishing_organisation["base_path"],
|
54
|
+
}
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
def publishing_organisation
|
59
|
+
page.content_item.dig("links", "primary_publishing_organisation").to_a.first
|
60
|
+
end
|
61
|
+
|
62
|
+
def is_part_of
|
63
|
+
return {} unless step_by_step_schemas.any? || document_collections.any?
|
64
|
+
|
65
|
+
{
|
66
|
+
"isPartOf" => document_collections + step_by_step_schemas
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
def step_by_step_schemas
|
71
|
+
# We could include `related_to_step_navs` eventually too, but initially
|
72
|
+
# link to those that we render in the "step_by_step_nav_related" component
|
73
|
+
@step_by_step_schemas ||= fetch_step_by_step_schemas
|
74
|
+
end
|
75
|
+
|
76
|
+
def fetch_step_by_step_schemas
|
77
|
+
page.content_item.dig("links", "part_of_step_navs").to_a.map do |step_by_step|
|
78
|
+
step_by_step_page = linked_page(step_by_step)
|
79
|
+
structured_data = HowToSchema.new(step_by_step_page.canonical_url).structured_data
|
80
|
+
|
81
|
+
structured_data.merge(image_schema)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def linked_page(step_by_step)
|
86
|
+
Page.new(
|
87
|
+
content_item: step_by_step,
|
88
|
+
schema: :article,
|
89
|
+
logo_url: page.logo_url,
|
90
|
+
image_placeholders: page.image_placeholders
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
94
|
+
def has_part
|
95
|
+
return {} unless collection_pages("documents").any?
|
96
|
+
|
97
|
+
{
|
98
|
+
"hasPart" => collection_pages("documents").map { |document| HasPartSchema.new(document).structured_data }
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
def document_collections
|
103
|
+
@document_collections ||= collection_pages("document_collections")
|
104
|
+
.map { |document| IsPartOfSchema.new(document).structured_data }
|
105
|
+
end
|
106
|
+
|
107
|
+
def collection_pages(linked_type)
|
108
|
+
@pages[linked_type] ||= fetch_collection_pages(linked_type)
|
109
|
+
end
|
110
|
+
|
111
|
+
def fetch_collection_pages(linked_type)
|
112
|
+
page.content_item.dig("links", linked_type).to_a.map { |document| document["web_url"] }
|
113
|
+
end
|
114
|
+
|
115
|
+
def about
|
116
|
+
return {} unless live_taxons.any?
|
117
|
+
|
118
|
+
{
|
119
|
+
"about" => linked_taxons
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
123
|
+
def live_taxons
|
124
|
+
taxons = page.content_item.dig("links", "taxons")
|
125
|
+
return [] unless taxons
|
126
|
+
|
127
|
+
taxons.select { |taxon| taxon["phase"] == "live" }
|
128
|
+
end
|
129
|
+
|
130
|
+
def linked_taxons
|
131
|
+
live_taxons.map do |taxon|
|
132
|
+
{
|
133
|
+
"@context" => "http://schema.org",
|
134
|
+
"@type" => "Thing",
|
135
|
+
"sameAs" => taxon["web_url"]
|
136
|
+
}
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -17,8 +17,8 @@ module GovukPublishingComponents
|
|
17
17
|
"@id" => page.canonical_url,
|
18
18
|
},
|
19
19
|
"name" => page.title,
|
20
|
-
"description" => page.description || page.body
|
21
|
-
}.merge(parent_organisations).merge(sub_organisations)
|
20
|
+
"description" => page.description || page.body,
|
21
|
+
}.merge(parent_organisations).merge(sub_organisations).merge(search_action)
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
@@ -53,6 +53,19 @@ module GovukPublishingComponents
|
|
53
53
|
"sameAs" => url
|
54
54
|
}
|
55
55
|
end
|
56
|
+
|
57
|
+
def search_action
|
58
|
+
PotentialSearchActionSchema.new(organisation_facet_params).structured_data
|
59
|
+
end
|
60
|
+
|
61
|
+
def slug
|
62
|
+
uri = URI.parse(page.canonical_url)
|
63
|
+
File.basename(uri.path)
|
64
|
+
end
|
65
|
+
|
66
|
+
def organisation_facet_params
|
67
|
+
{ organisations: [slug] }
|
68
|
+
end
|
56
69
|
end
|
57
70
|
end
|
58
71
|
end
|
@@ -43,6 +43,14 @@ module GovukPublishingComponents
|
|
43
43
|
local_assigns[:image_placeholders]
|
44
44
|
end
|
45
45
|
|
46
|
+
def document_type
|
47
|
+
content_item["document_type"]
|
48
|
+
end
|
49
|
+
|
50
|
+
def base_path
|
51
|
+
content_item["base_path"]
|
52
|
+
end
|
53
|
+
|
46
54
|
def content_item
|
47
55
|
local_assigns[:content_item]
|
48
56
|
end
|
data/lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'plek'
|
2
|
+
|
3
|
+
module GovukPublishingComponents
|
4
|
+
module Presenters
|
5
|
+
class PotentialSearchActionSchema
|
6
|
+
attr_reader :facet_params
|
7
|
+
|
8
|
+
BASE_SEARCH_URL = "#{Plek.current.website_root}/search/all?keywords={query}&order=relevance".freeze
|
9
|
+
|
10
|
+
def initialize(facet_params)
|
11
|
+
@facet_params = facet_params
|
12
|
+
end
|
13
|
+
|
14
|
+
def structured_data
|
15
|
+
# http://schema.org/SearchAction - minimal
|
16
|
+
{
|
17
|
+
"potentialAction" => {
|
18
|
+
"@type": "SearchAction",
|
19
|
+
"target": search_template,
|
20
|
+
"query": "required"
|
21
|
+
}
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def search_template
|
28
|
+
"#{BASE_SEARCH_URL}&#{facet_params.to_query}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'govuk_publishing_components/presenters/machine_readable/page'
|
2
2
|
require 'govuk_publishing_components/presenters/machine_readable/article_schema'
|
3
|
+
require 'govuk_publishing_components/presenters/machine_readable/creative_work_schema'
|
3
4
|
require 'govuk_publishing_components/presenters/machine_readable/how_to_schema'
|
4
5
|
require 'govuk_publishing_components/presenters/machine_readable/has_part_schema'
|
5
6
|
require 'govuk_publishing_components/presenters/machine_readable/is_part_of_schema'
|
6
7
|
require 'govuk_publishing_components/presenters/machine_readable/news_article_schema'
|
7
8
|
require 'govuk_publishing_components/presenters/machine_readable/organisation_schema'
|
8
9
|
require 'govuk_publishing_components/presenters/machine_readable/person_schema'
|
10
|
+
require 'govuk_publishing_components/presenters/machine_readable/potential_search_action_schema'
|
9
11
|
require 'govuk_publishing_components/presenters/machine_readable/search_results_page_schema'
|
10
12
|
|
11
13
|
module GovukPublishingComponents
|
@@ -49,7 +49,7 @@
|
|
49
49
|
"/"
|
50
50
|
],
|
51
51
|
"_resolved": "git://github.com/alphagov/accessible-autocomplete.git#0c518b4fa79b9a95b544410858486ed9e6403c84",
|
52
|
-
"_shasum": "
|
52
|
+
"_shasum": "0e8451ecad5df899dfb32b674eaf77890c7654ef",
|
53
53
|
"_shrinkwrap": null,
|
54
54
|
"_spec": "accessible-autocomplete@git://github.com/alphagov/accessible-autocomplete.git#add-multiselect-support",
|
55
55
|
"_where": "/var/lib/jenkins/workspace/ublishing_components_master-N4FWJIUY4CIFHKGZOAAEVVXODRY3YBORQOPIBBXWX72VUPSGJRRQ",
|
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: 16.
|
4
|
+
version: 16.23.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: 2019-05-
|
11
|
+
date: 2019-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gds-api-adapters
|
@@ -660,6 +660,7 @@ files:
|
|
660
660
|
- lib/govuk_publishing_components/presenters/highlight_boxes_helper.rb
|
661
661
|
- lib/govuk_publishing_components/presenters/image_card_helper.rb
|
662
662
|
- lib/govuk_publishing_components/presenters/machine_readable/article_schema.rb
|
663
|
+
- lib/govuk_publishing_components/presenters/machine_readable/creative_work_schema.rb
|
663
664
|
- lib/govuk_publishing_components/presenters/machine_readable/has_part_schema.rb
|
664
665
|
- lib/govuk_publishing_components/presenters/machine_readable/how_to_schema.rb
|
665
666
|
- lib/govuk_publishing_components/presenters/machine_readable/is_part_of_schema.rb
|
@@ -667,6 +668,7 @@ files:
|
|
667
668
|
- lib/govuk_publishing_components/presenters/machine_readable/organisation_schema.rb
|
668
669
|
- lib/govuk_publishing_components/presenters/machine_readable/page.rb
|
669
670
|
- lib/govuk_publishing_components/presenters/machine_readable/person_schema.rb
|
671
|
+
- lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
|
670
672
|
- lib/govuk_publishing_components/presenters/machine_readable/search_results_page_schema.rb
|
671
673
|
- lib/govuk_publishing_components/presenters/meta_tags.rb
|
672
674
|
- lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
|