govuk_publishing_components 9.1.0 → 9.1.1

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: d8a4912cbff99d020d6e61c3a9e4e8b7a32b21b91f0031fd3784876bbc1b3f8b
4
- data.tar.gz: 9196ea412a372cf4ad8ec6abb466682bea18736aea6cdcc273c6f881de36f1a1
3
+ metadata.gz: db15d537c17313a0793b88dc3ccac1f8ba3496e4a74b90243c0727e7b978354a
4
+ data.tar.gz: 61a1abf7b80c7d18a6279ac941cced1642389918dbd4b5cef98d98d24b522d53
5
5
  SHA512:
6
- metadata.gz: 81f31e5c4026ac11ddce146d66b6afa59e64af064fea257e9aab78e68b6f041696e29729b6290d58dd2358946eb6948787ff7f204be79aac6656744a799de836
7
- data.tar.gz: 4e79ba08990e88c7c848db1c44fecb0fdcff85f408494538e56b06e7e65039a6bff8a01b1b2f731065b2c8b475e8a3527bd91915de10d6ed05381d6d6010aafb
6
+ metadata.gz: 6128034653da026744dc30526dda393da4d0ee1ed124d700b36b4e8833c244b8db785050af8ef35d313e50ec09ae31c1841d05f492a5af4c781ec57d9cb492bf
7
+ data.tar.gz: 026ba2c40a3a797853af4586a29f2f9a82b02b1b887eef5364f7db7d8155af74d84988c22160f900c03a0f47f179866955a675a23e30272c90e00026b3d88557
@@ -3,7 +3,7 @@
3
3
 
4
4
  <div class="component-show">
5
5
  <div class="component-doc">
6
- <%= render "govuk_publishing_components/components/govspeak", content: @component_example.html_description %>
6
+ <%= render "govuk_publishing_components/components/govspeak", content: raw(@component_example.html_description) %>
7
7
  <h2 class="component-doc-h2">How to call this example</h2>
8
8
  <%= render partial: "govuk_publishing_components/component_guide/component_doc/call", locals: { component_doc: @component_doc, example: @component_example } %>
9
9
 
@@ -13,7 +13,7 @@
13
13
  <%= render 'govuk_publishing_components/components/lead_paragraph', text: @component_doc.description %>
14
14
  <% if @component_doc.body.present? %>
15
15
  <div class="component-body">
16
- <%= render 'govuk_publishing_components/components/govspeak', content: @component_doc.html_body %>
16
+ <%= render 'govuk_publishing_components/components/govspeak', content: raw(@component_doc.html_body) %>
17
17
  </div>
18
18
  <% end %>
19
19
  </div>
@@ -32,7 +32,7 @@
32
32
  <div class="grid-row component-accessibility-criteria">
33
33
  <div class="column-two-thirds">
34
34
  <h2 class="component-doc-h2">Accessibility acceptance criteria</h2>
35
- <%= render 'govuk_publishing_components/components/govspeak', content: @component_doc.html_accessibility_criteria %>
35
+ <%= render 'govuk_publishing_components/components/govspeak', content: raw(@component_doc.html_accessibility_criteria) %>
36
36
  </div>
37
37
  </div>
38
38
  <% end %>
@@ -48,7 +48,7 @@
48
48
  <a href="<%= component_example_path(@component_doc.id, example.id) %>"><%= example.name %></a>
49
49
  <small>(<a href="<%= component_preview_path(@component_doc.id, example.id) %>">preview</a>)</small>
50
50
  </h3>
51
- <%= render "govuk_publishing_components/components/govspeak", content: example.html_description %>
51
+ <%= render "govuk_publishing_components/components/govspeak", content: raw(example.html_description) %>
52
52
  <%= render "govuk_publishing_components/component_guide/component_doc/call", component_doc: @component_doc, example: example %>
53
53
  <%= render "govuk_publishing_components/component_guide/component_doc/preview", component_doc: @component_doc, example: example %>
54
54
  </div>
@@ -10,5 +10,28 @@
10
10
  %>
11
11
 
12
12
  <div class="gem-c-govspeak govuk-govspeak <%= classes.join(" ") %>">
13
- <%= raw content %>
13
+ <% if local_assigns.include?(:content) %>
14
+ <% if content.html_safe? %>
15
+ <%= content %>
16
+ <% else %>
17
+ <% puts "
18
+ You've passed in unsanitised HTML into the govspeak component as the
19
+ `content` param.
20
+
21
+ Passing in unsafe HTML is deprecated and will be removed in a future
22
+ version. You need to pass in a block instead or use the `capture` helper.
23
+
24
+ See the component guide for examples.
25
+
26
+ If you're 100% sure there's no unsanitised user input in the string you
27
+ could also call `.html_safe` on the string or use the `raw` helper before
28
+ passing it in.
29
+
30
+ Called from #{caller_locations.find { |l| l.to_s.include?('.erb') }}
31
+ " %>
32
+ <%= raw content %>
33
+ <% end %>
34
+ <% elsif block_given? %>
35
+ <%= yield %>
36
+ <% end %>
14
37
  </div>
@@ -1,9 +1,12 @@
1
1
  <%
2
- govspeak_locals = { content: content }
2
+ govspeak_locals = {}
3
+ govspeak_locals[:content] = local_assigns.fetch(:content) if local_assigns.include?(:content)
3
4
  govspeak_locals[:direction] = local_assigns.fetch(:direction) if local_assigns.include?(:direction)
4
5
  govspeak_locals[:rich_govspeak] = local_assigns.fetch(:rich_govspeak) if local_assigns.include?(:rich_govspeak)
5
6
  govspeak_locals[:disable_youtube_expansions] = local_assigns.fetch(:disable_youtube_expansions) if local_assigns.include?(:disable_youtube_expansions)
6
7
  %>
7
8
  <div class="gem-c-govspeak-html-publication">
8
- <%= render 'govuk_publishing_components/components/govspeak', govspeak_locals %>
9
+ <%= render 'govuk_publishing_components/components/govspeak', govspeak_locals do %>
10
+ <%= yield %>
11
+ <% end %>
9
12
  </div>
@@ -1,4 +1,9 @@
1
1
  <% local_assigns[:logo_url] = image_url("govuk_publishing_components/govuk-logo.png") %>
2
+ <% local_assigns[:image_placeholders] = [
3
+ image_url("govuk_publishing_components/govuk-schema-placeholder-1x1.png"),
4
+ image_url("govuk_publishing_components/govuk-schema-placeholder-4x3.png"),
5
+ image_url("govuk_publishing_components/govuk-schema-placeholder-16x9.png"),
6
+ ] %>
2
7
  <% page = GovukPublishingComponents::Presenters::Page.new(local_assigns) %>
3
8
  <% structured_data = GovukPublishingComponents::Presenters::SchemaOrg.new(page).structured_data %>
4
9
 
@@ -20,13 +20,18 @@ shared_accessibility_criteria:
20
20
  - link
21
21
  examples:
22
22
  basic_content:
23
+ data:
24
+ block: |
25
+ <h2>This is a title</h2>
26
+ <p>This is some body text with <a href=#>a link</a></p>
27
+ with_content:
23
28
  data:
24
29
  content: |
25
30
  <h2>This is a title</h2>
26
31
  <p>This is some body text with <a href=#>a link</a></p>
27
32
  heading_levels:
28
33
  data:
29
- content: |
34
+ block: |
30
35
  <h2>This is a h2 title</h2>
31
36
  <h3>This is a h3 title</h3>
32
37
  <h4>This is a h4 title</h4>
@@ -34,7 +39,7 @@ examples:
34
39
  <h6>This is a h6 title</h6>
35
40
  lists:
36
41
  data:
37
- content: |
42
+ block: |
38
43
  <h2>ordered list:</h2>
39
44
  <ol>
40
45
  <li>one</li>
@@ -49,7 +54,7 @@ examples:
49
54
  </ul>
50
55
  nested_lists:
51
56
  data:
52
- content: |
57
+ block: |
53
58
  <h2>ordered list:</h2>
54
59
  <ol>
55
60
  <li>
@@ -72,7 +77,7 @@ examples:
72
77
  </ul>
73
78
  legislative_lists:
74
79
  data:
75
- content: |
80
+ block: |
76
81
  <h2>ordered list:</h2>
77
82
  <ol class="legislative-list">
78
83
  <li>one</li>
@@ -81,7 +86,7 @@ examples:
81
86
  </ol>
82
87
  image_fractions:
83
88
  data:
84
- content: |
89
+ block: |
85
90
  <h3 id="number---fractions-1">Number - fractions</h3>
86
91
 
87
92
  <p>Pupils should be taught to:</p>
@@ -127,18 +132,18 @@ examples:
127
132
  </div>
128
133
  text_fractions:
129
134
  data:
130
- content: |
135
+ block: |
131
136
  <p>If an image is not available for a particular fraction, then we'll fallback to text based fraction using <code>sup</code>/<code>sub</code>, like this <span class="fraction"><sup>1</sup>&frasl;<sub>100</sub></span> example.</p>
132
137
  blockquote:
133
138
  data:
134
- content: |
139
+ block: |
135
140
  <blockquote>
136
141
  <p>My quote</p>
137
142
  <p class="last-child">about things</p>
138
143
  </blockquote>
139
144
  tables:
140
145
  data:
141
- content: |
146
+ block: |
142
147
  <table>
143
148
  <caption>A table with data</caption>
144
149
  <thead>
@@ -157,7 +162,7 @@ examples:
157
162
  </table>
158
163
  charts:
159
164
  data:
160
- content: |
165
+ block: |
161
166
  <table class='js-barchart-table mc-auto-outdent'>
162
167
  <caption>A table with numerical data</caption>
163
168
  <tbody>
@@ -171,7 +176,7 @@ examples:
171
176
  </table>
172
177
  address:
173
178
  data:
174
- content: |
179
+ block: |
175
180
  <div class="address">
176
181
  <div class="adr org fn">
177
182
  <p>
@@ -187,7 +192,7 @@ examples:
187
192
  <p>Addresses are generated when using the `$A` markdown pattern.</p>
188
193
  contact:
189
194
  data:
190
- content: |
195
+ block: |
191
196
  <div class="contact" id="contact_1017">
192
197
  <div class="content">
193
198
  <h3>Media enquiries</h3>
@@ -206,7 +211,7 @@ examples:
206
211
  </div>
207
212
  contact_with_surrounding_text:
208
213
  data:
209
- content: |
214
+ block: |
210
215
  <h2>This is a title</h2>
211
216
  <div class="contact" id="contact_1018">
212
217
  <div class="content">
@@ -243,7 +248,7 @@ examples:
243
248
  </div>
244
249
  footnotes:
245
250
  data:
246
- content: |
251
+ block: |
247
252
  <p>This is a text with a footnote<sup id="fnref:1a"><a href="#fn:1a" class="footnote">1</a></sup>.</p>
248
253
 
249
254
  <div class="footnotes">
@@ -253,10 +258,10 @@ examples:
253
258
  </li>
254
259
  </ol>
255
260
  </div>
256
- rtl_content:
261
+ rtl_block:
257
262
  data:
258
263
  direction: rtl
259
- content: |
264
+ block: |
260
265
  <p>قال وزير الخارجية، ويليام هيغ:</p>
261
266
  <blockquote>
262
267
  <p>مع بدء هذا الشهر الفضيل أتمنى للمسلمين في أنحاء العالم - في آسيا وأفريقيا والشرق الأوسط وأوروبا وغيرها من مناطق العالم - شهر رمضان مبارك.</p>
@@ -276,27 +281,27 @@ examples:
276
281
  </ul>
277
282
  with_bold_unstyled:
278
283
  data:
279
- content: |
284
+ block: |
280
285
  <p>This content has <strong>text in strong tags</strong>, but they are not styled as bold</p>
281
286
  with_rich_govspeak:
282
287
  data:
283
288
  rich_govspeak: true
284
- content: |
289
+ block: |
285
290
  <p>This content uses rich govspeak and has <strong>text in strong tags</strong> that are styled as bold</p>
286
291
  with_youtube_embed:
287
292
  data:
288
- content: |
293
+ block: |
289
294
  <p>This content has a YouTube video link, converted to an accessible embedded player by component JavaScript.</p>
290
295
  <p><a href="https://www.youtube.com/watch?v=y6hbrS3DheU">Operations: a developer's guide, by Anna Shipman</a></p>
291
296
  with_youtube_embed_disabled:
292
297
  data:
293
298
  disable_youtube_expansions: true
294
- content: |
299
+ block: |
295
300
  <p>This content has a YouTube video link, where the govspeak expansion has been disabled</p>
296
301
  <p><a href="https://www.youtube.com/watch?v=y6hbrS3DheU">Operations: a developer's guide, by Anna Shipman</a></p>
297
302
  statistic_headlines:
298
303
  data:
299
- content: |
304
+ block: |
300
305
  <aside class="stat-headline">
301
306
  <p><em>£6bn</em>
302
307
  Total Departmental Expenditure Limit (<abbr title="Departmental Expenditure Limit">DEL</abbr>) in financial year 2015 to 2016</p>
@@ -309,7 +314,7 @@ examples:
309
314
  </aside>
310
315
  specialist_content:
311
316
  data:
312
- content: |
317
+ block: |
313
318
  <h2 id="bisphosphonates">Bisphosphonates</h2>
314
319
  <p>Bisphosphonates are used to treat osteoporosis, Paget’s disease, and as part of some cancer regimens, particularly for metastatic bone cancer and multiple myeloma. Individual bisphosphonates have different indications (see individual Summaries of Product Characteristics<sup id="fnref:1"><a href="#fn:1" class="footnote">1</a></sup>). The following bisphosphonates are available in the UK:</p>
315
320
 
@@ -381,14 +386,14 @@ examples:
381
386
  </div>
382
387
  inline_attachment:
383
388
  data:
384
- content: |
389
+ block: |
385
390
  <p>testing my attachment <span class="inline-attachment" id="attachment_1399340">
386
391
  <a href="/government/uploads/system/uploads/attachment_data/file/498071/PHE_Payments_over__25k_Jun_15.csv">testing</a>
387
392
  (<span class="type"><abbr title="Comma-separated Values">CSV</abbr></span>, <span class="file-size">65.4KB</span>)</span> works in the middle of copy.
388
393
  </p>
389
394
  block_attachments:
390
395
  data:
391
- content: |
396
+ block: |
392
397
  <section class="attachment embedded" id="attachment_1399345">
393
398
  <div class="attachment-thumb">
394
399
  <a aria-hidden="true" class="thumbnail" href="https://www.gov.uk/government/publications/minimum-wage-jobs-in-ashfield-local-authority-since-2009"><img alt="" src="https://assets.digital.cabinet-office.gov.uk/government/uploads/system/uploads/attachment_data/file/496127/thumbnail_LPC_FoI_09.12.15_NMW_jobs_Ashfield_LA.pdf.png"></a>
@@ -529,7 +534,7 @@ examples:
529
534
  block_attachment_rtl:
530
535
  data:
531
536
  direction: rtl
532
- content: |
537
+ block: |
533
538
  <section class="attachment embedded" id="attachment_514218">
534
539
  <div class="attachment-thumb">
535
540
  <a aria-hidden="true" class="thumbnail" href="https://www.gov.uk/government/publications/future-of-food-and-farming.ar"><img alt="" src="https://assets-origin.integration.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/288236/thumbnail_11-924-future-of-food-and-farming-summary-arabic.pdf.png"></a>
@@ -554,7 +559,7 @@ examples:
554
559
  </section>
555
560
  example:
556
561
  data:
557
- content: |
562
+ block: |
558
563
  <div class="example">
559
564
  <p>
560
565
  <strong>Example</strong>
@@ -567,13 +572,13 @@ examples:
567
572
  </div>
568
573
  call_to_action:
569
574
  data:
570
- content: |
575
+ block: |
571
576
  <div class="call-to-action">
572
577
  <p>Call to action</p>
573
578
  </div>
574
579
  information_callout:
575
580
  data:
576
- content: |
581
+ block: |
577
582
  <div class="application-notice info-notice">
578
583
  <p>
579
584
  If you drilled a tunnel straight through the Earth and jumped in, it would take
@@ -582,7 +587,7 @@ examples:
582
587
  </div>
583
588
  warning_callout:
584
589
  data:
585
- content: |
590
+ block: |
586
591
  <div class="application-notice help-notice">
587
592
  <p>
588
593
  The water in the mouth of a blue whale weighs more than its body.
@@ -590,19 +595,19 @@ examples:
590
595
  </div>
591
596
  advisory:
592
597
  data:
593
- content: |
598
+ block: |
594
599
  <h3 role="note" aria-label="Important" class="advisory">
595
600
  <span>This is a very important message or warning</span>
596
601
  </h3>
597
602
  form_download:
598
603
  data:
599
- content: |
604
+ block: |
600
605
  <div class="form-download">
601
606
  <p><a href="http://example.com/" title="Example form" rel="external">An example form download link.</a></p>
602
607
  </div>
603
608
  steps:
604
609
  data:
605
- content:
610
+ block:
606
611
  <ol class="steps">
607
612
  <li>
608
613
  <p>Add numbers.</p>
@@ -623,7 +628,7 @@ examples:
623
628
  * [https://gov.uk/individual-savings-accounts](https://gov.uk/individual-savings-accounts)
624
629
  * [https://gov.uk/corporation-tax-rates](https://gov.uk/corporation-tax-rates)
625
630
  data:
626
- content: |
631
+ block: |
627
632
  <div class="highlight-answer">
628
633
  <p>The VAT rate is <em>20%</em></p>
629
634
  </div>
@@ -635,19 +640,19 @@ examples:
635
640
  </div>
636
641
  place:
637
642
  data:
638
- content: |
643
+ block: |
639
644
  <div class="place">
640
645
  <p>This is a place</p>
641
646
  </div>
642
647
  summary:
643
648
  data:
644
- content: |
649
+ block: |
645
650
  <div class="summary">
646
651
  <p>This is a summary</p>
647
652
  </div>
648
653
  button:
649
654
  data:
650
- content: |
655
+ block: |
651
656
  <a href="#" class="button button-start" role="button">
652
657
  Start now
653
658
  </a>
@@ -11,26 +11,30 @@ shared_accessibility_criteria:
11
11
  - link
12
12
  examples:
13
13
  basic_content:
14
+ data:
15
+ block: |
16
+ <p>This is a Budget that puts security first. It ensures economic security for working people by putting the public finances in order and setting out a bold plan for a more productive, balanced economy.</p>
17
+ with_content:
14
18
  data:
15
19
  content: |
16
20
  <p>This is a Budget that puts security first. It ensures economic security for working people by putting the public finances in order and setting out a bold plan for a more productive, balanced economy.</p>
17
21
  heading_level_2:
18
22
  data:
19
- content: |
23
+ block: |
20
24
  <h2>
21
25
  <span class="number">1. </span>Executive summary
22
26
  </h2>
23
27
  <p>This is a Budget that puts security first. It ensures economic security for working people by putting the public finances in order and setting out a bold plan for a more productive, balanced economy.</p>
24
28
  heading_level_3:
25
29
  data:
26
- content: |
30
+ block: |
27
31
  <h3>
28
32
  <span class="number">1.1 </span>Fixing the public finances and running a surplus
29
33
  </h3>
30
34
  <p>The government’s long-term economic plan has laid the foundations for a stronger economy, and the UK’s recovery is now well established. The labour market remains strong, and in the 3 months to April 2015, employment was around record levels at 31.1 million.</p>
31
35
  numbered_content:
32
36
  data:
33
- content: |
37
+ block: |
34
38
  <h2 id="executive-summary">
35
39
  <span class="number">1. </span>Executive summary
36
40
  </h2>
@@ -53,7 +57,7 @@ examples:
53
57
  right_to_left:
54
58
  data:
55
59
  direction: 'rtl'
56
- content: |
60
+ block: |
57
61
  <h2>
58
62
  <span class="number">1. </span>Executive summary
59
63
  </h2>
@@ -75,7 +79,7 @@ examples:
75
79
  <p>The government’s long‑term economic plan has secured the recovery. The government’s fiscal responsibility has allowed monetary activism to support demand in the economy alongside repair of the financial sector. This has been supported by supply-side reform to deliver sustainable increases in standards of living.</p>
76
80
  financial_table:
77
81
  data:
78
- content: |
82
+ block: |
79
83
  <table class="financial-data">
80
84
  <caption>Table 1.6: Total Managed Expenditure (as produced by the <a href="https://alphagov.github.io/table-editor/financial-tables.html">financial table editor</a>)</caption>
81
85
  <thead>
@@ -3,6 +3,8 @@ description: A text heading
3
3
  body: |
4
4
  A versatile heading tag component, including options for different heading levels and font sizes.
5
5
 
6
+ This is a `h2` by default.
7
+
6
8
  Real world examples:
7
9
 
8
10
  - [Publication](/government/publications/recognising-the-terrorist-threat)
@@ -9,4 +9,7 @@ Rails.application.config.assets.precompile += %w(
9
9
  govuk_publishing_components/icon-pointer.png
10
10
  govuk_publishing_components/icon-pointer-2x.png
11
11
  govuk_publishing_components/govuk-logo.png
12
+ govuk_publishing_components/govuk-schema-placeholder-1x1.png
13
+ govuk_publishing_components/govuk-schema-placeholder-4x3.png
14
+ govuk_publishing_components/govuk-schema-placeholder-16x9.png
12
15
  )
@@ -4,7 +4,7 @@ module GovukPublishingComponents
4
4
  attr_reader :heading_tag, :id, :classes
5
5
 
6
6
  def initialize(options)
7
- @heading_tag = "h1"
7
+ @heading_tag = "h2"
8
8
  @heading_tag = "h#{options[:heading_level]}" if [1, 2, 3, 4, 5, 6].include? options[:heading_level]
9
9
  @id = options[:id]
10
10
 
@@ -47,12 +47,8 @@ module GovukPublishingComponents
47
47
  end
48
48
 
49
49
  def image_schema
50
- return {} unless page.has_image?
51
-
52
50
  {
53
- "image" => [
54
- page.image_url
55
- ]
51
+ "image" => page.has_image? ? [page.image_url] : page.image_placeholders
56
52
  }
57
53
  end
58
54
 
@@ -39,6 +39,10 @@ module GovukPublishingComponents
39
39
  content_item.dig("details", "image", "alt_text")
40
40
  end
41
41
 
42
+ def image_placeholders
43
+ local_assigns[:image_placeholders]
44
+ end
45
+
42
46
  def content_item
43
47
  local_assigns[:content_item]
44
48
  end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '9.1.0'.freeze
2
+ VERSION = '9.1.1'.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: 9.1.0
4
+ version: 9.1.1
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: 2018-06-05 00:00:00.000000000 Z
11
+ date: 2018-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -303,6 +303,9 @@ files:
303
303
  - app/assets/config/govuk_publishing_components_manifest.js
304
304
  - app/assets/images/govuk_publishing_components/feed-icon-black.png
305
305
  - app/assets/images/govuk_publishing_components/govuk-logo.png
306
+ - app/assets/images/govuk_publishing_components/govuk-schema-placeholder-16x9.png
307
+ - app/assets/images/govuk_publishing_components/govuk-schema-placeholder-1x1.png
308
+ - app/assets/images/govuk_publishing_components/govuk-schema-placeholder-4x3.png
306
309
  - app/assets/images/govuk_publishing_components/icon-pointer-2x.png
307
310
  - app/assets/images/govuk_publishing_components/icon-pointer.png
308
311
  - app/assets/images/govuk_publishing_components/mail-icon-x2.png