govuk_publishing_components 21.36.1 → 21.37.0

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: 97f4e780c9b3f27f06d6aee281982ba45b61f4d5c33004f486eb1200c9bb5b0f
4
- data.tar.gz: ef54a714d226943bbdb1aad4092991bdd772cd6a084ef77036c420d1a49b7123
3
+ metadata.gz: e7343e4fe7a73cac6e8c139f06e54a8691a15cc4f6964595c4dac999d3186106
4
+ data.tar.gz: 1fee051d18738e77725e74464527b67eb9e7a99e2eceae382aee64e0acdcfb46
5
5
  SHA512:
6
- metadata.gz: 64e7a5809d24381576e81d8c508de4b16dc6186ce8ede46bd1905c1226a2622552e99e89aeec4a8af2fdffbb6dcc62b4eb19290cfc3db070754c0d25113fecc2
7
- data.tar.gz: 8dd0576161ca46ef0b41c433ce8f17163eee5e12e5f3ba0ad35e366ae02b74e25260749d92d3788c37b66b6b18da09802fb3042674a4cb6fcca47f6289814613
6
+ metadata.gz: 34e961e66d8957202a7e8c89755f7959b53793ae2181ecb4de104080a7f5e6f92f06002ed296c2c774f47f9a2555be68dfc50362dac4022181467aae4b844f3b
7
+ data.tar.gz: d04a0d287874c62a7b3a9b4399155944715a21c6c695412a6b42384b29667067f7479d7fba2e538c9f3f84ef493606b3a691fb084d9403e552cfb6935af192a3
@@ -1,5 +1,9 @@
1
1
  @import "govuk/components/warning-text/warning-text";
2
2
 
3
+ .gem-c-warning-text .govuk-warning-text__text {
4
+ margin: 0;
5
+ }
6
+
3
7
  .gem-c-warning-text__text--no-indent {
4
8
  padding-left: 0;
5
9
  margin-left: 0;
@@ -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
- <%= tag.strong class: text_classes do %>
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
@@ -29,3 +29,7 @@ examples:
29
29
  data:
30
30
  text: "This content has changed"
31
31
  highlight_text: true
32
+ as_a_heading:
33
+ data:
34
+ text: "This is a heading 3"
35
+ heading_level: 3
@@ -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" => (page.body || page.description).slice(0..4999),
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
@@ -51,6 +51,10 @@ module GovukPublishingComponents
51
51
  content_item["base_path"]
52
52
  end
53
53
 
54
+ def attachments
55
+ content_item.dig("details", "attachments")
56
+ end
57
+
54
58
  def content_item
55
59
  local_assigns[:content_item]
56
60
  end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "21.36.1".freeze
2
+ VERSION = "21.37.0".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: 21.36.1
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-03-31 00:00:00.000000000 Z
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