govuk_publishing_components 21.36.1 → 21.37.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/app/assets/stylesheets/govuk_publishing_components/components/_warning-text.scss +4 -0
- data/app/views/govuk_publishing_components/components/_warning_text.html.erb +13 -1
- data/app/views/govuk_publishing_components/components/docs/machine_readable_metadata.yml +21 -0
- data/app/views/govuk_publishing_components/components/docs/warning_text.yml +4 -0
- data/lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb +34 -1
- data/lib/govuk_publishing_components/presenters/machine_readable/page.rb +4 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e7343e4fe7a73cac6e8c139f06e54a8691a15cc4f6964595c4dac999d3186106
|
|
4
|
+
data.tar.gz: 1fee051d18738e77725e74464527b67eb9e7a99e2eceae382aee64e0acdcfb46
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 34e961e66d8957202a7e8c89755f7959b53793ae2181ecb4de104080a7f5e6f92f06002ed296c2c774f47f9a2555be68dfc50362dac4022181467aae4b844f3b
|
|
7
|
+
data.tar.gz: d04a0d287874c62a7b3a9b4399155944715a21c6c695412a6b42384b29667067f7479d7fba2e538c9f3f84ef493606b3a691fb084d9403e552cfb6935af192a3
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
text_icon ||= '!'
|
|
5
5
|
large_font ||= false
|
|
6
6
|
highlight_text ||= false
|
|
7
|
+
heading_level ||= 0
|
|
8
|
+
|
|
9
|
+
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
|
7
10
|
|
|
8
11
|
text_classes = %w(govuk-warning-text__text)
|
|
9
12
|
text_classes << "gem-c-warning-text__text--no-indent" if text_icon.empty?
|
|
@@ -15,8 +18,17 @@
|
|
|
15
18
|
<% unless text_icon.empty? %>
|
|
16
19
|
<%= tag.span text_icon, class: "govuk-warning-text__icon", "aria-hidden": "true" %>
|
|
17
20
|
<% end %>
|
|
18
|
-
|
|
21
|
+
<% inner_text = capture do %>
|
|
19
22
|
<%= tag.span text_assistive, class: "govuk-warning-text__assistive" %>
|
|
20
23
|
<%= text %>
|
|
21
24
|
<% end %>
|
|
25
|
+
<% if heading_level > 0 %>
|
|
26
|
+
<%= content_tag(shared_helper.get_heading_level, class: text_classes) do %>
|
|
27
|
+
<%= inner_text %>
|
|
28
|
+
<% end %>
|
|
29
|
+
<% else %>
|
|
30
|
+
<%= tag.strong class: text_classes do %>
|
|
31
|
+
<%= inner_text %>
|
|
32
|
+
<% end %>
|
|
33
|
+
<% end %>
|
|
22
34
|
<% end %>
|
|
@@ -134,3 +134,24 @@ examples:
|
|
|
134
134
|
base_path: "government/statistical-data-sets/hogwarts-data"
|
|
135
135
|
details: {}
|
|
136
136
|
schema: :dataset
|
|
137
|
+
dataset_schema_with_attachments:
|
|
138
|
+
data:
|
|
139
|
+
content_item:
|
|
140
|
+
title: "All the data about Hogwarts"
|
|
141
|
+
base_path: "government/statistical-data-sets/hogwarts-data"
|
|
142
|
+
details:
|
|
143
|
+
attachments:
|
|
144
|
+
- attachment_type: "file"
|
|
145
|
+
url: "https://assets.publishing.service.gov.uk/hogwarts-data/headmasters.csv"
|
|
146
|
+
title: "List of headmasters"
|
|
147
|
+
content_type: "text/csv"
|
|
148
|
+
id: "headmasters.csv"
|
|
149
|
+
- attachment_type: "html"
|
|
150
|
+
url: "https://www.gov.uk/government/statistical-data-sets/hogwarts-data/houses"
|
|
151
|
+
title: "Houses of Hogwarts"
|
|
152
|
+
id: "houses"
|
|
153
|
+
- attachment_type: "external"
|
|
154
|
+
url: "https://hogwarts.gov.uk/datasets/dungeon-cleaning-schedule"
|
|
155
|
+
title: "Dungeon cleaning shedule"
|
|
156
|
+
id: "dungeon-cleaning-schedule"
|
|
157
|
+
schema: :dataset
|
|
@@ -10,6 +10,7 @@ module GovukPublishingComponents
|
|
|
10
10
|
def structured_data
|
|
11
11
|
# http://schema.org/Dataset
|
|
12
12
|
data = CreativeWorkSchema.new(@page).structured_data
|
|
13
|
+
.merge(distribution)
|
|
13
14
|
.merge(description)
|
|
14
15
|
.merge(name)
|
|
15
16
|
data["@type"] = "Dataset"
|
|
@@ -18,9 +19,20 @@ module GovukPublishingComponents
|
|
|
18
19
|
|
|
19
20
|
private
|
|
20
21
|
|
|
22
|
+
def distribution
|
|
23
|
+
return {} unless page.attachments
|
|
24
|
+
|
|
25
|
+
{
|
|
26
|
+
"distribution" => page.attachments.map { |a| present_attachment(a.with_indifferent_access) }.compact,
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
|
|
21
30
|
def description
|
|
31
|
+
descr = page.body || page.description
|
|
32
|
+
return {} unless descr
|
|
33
|
+
|
|
22
34
|
{
|
|
23
|
-
"description" =>
|
|
35
|
+
"description" => descr.slice(0..4999),
|
|
24
36
|
}
|
|
25
37
|
end
|
|
26
38
|
|
|
@@ -29,6 +41,27 @@ module GovukPublishingComponents
|
|
|
29
41
|
"name" => page.title,
|
|
30
42
|
}
|
|
31
43
|
end
|
|
44
|
+
|
|
45
|
+
def present_attachment(attachment)
|
|
46
|
+
title = attachment[:title]
|
|
47
|
+
url = attachment[:url]
|
|
48
|
+
return unless title
|
|
49
|
+
return unless url
|
|
50
|
+
|
|
51
|
+
case attachment[:attachment_type]
|
|
52
|
+
when "external", "html"
|
|
53
|
+
{
|
|
54
|
+
"name" => title,
|
|
55
|
+
"url" => url,
|
|
56
|
+
}
|
|
57
|
+
when "file"
|
|
58
|
+
{
|
|
59
|
+
"name" => title,
|
|
60
|
+
"contentUrl" => url,
|
|
61
|
+
"encodingFormat" => attachment[:content_type],
|
|
62
|
+
}.compact
|
|
63
|
+
end
|
|
64
|
+
end
|
|
32
65
|
end
|
|
33
66
|
end
|
|
34
67
|
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: 21.
|
|
4
|
+
version: 21.37.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: 2020-
|
|
11
|
+
date: 2020-04-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: gds-api-adapters
|