govspeak 6.0.0 → 6.1.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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +1 -45
  4. data/lib/govspeak.rb +18 -8
  5. data/lib/govspeak/blockquote_extra_quote_remover.rb +4 -3
  6. data/lib/govspeak/html_sanitizer.rb +1 -1
  7. data/lib/govspeak/post_processor.rb +25 -3
  8. data/lib/govspeak/presenters/attachment_presenter.rb +7 -194
  9. data/lib/govspeak/version.rb +1 -1
  10. data/locales/ar.yml +0 -17
  11. data/locales/be.yml +0 -17
  12. data/locales/bg.yml +0 -19
  13. data/locales/cs.yml +0 -19
  14. data/locales/cy.yml +0 -18
  15. data/locales/de.yml +0 -18
  16. data/locales/el.yml +0 -19
  17. data/locales/en.yml +0 -20
  18. data/locales/es-419.yml +0 -18
  19. data/locales/es.yml +0 -18
  20. data/locales/et.yml +0 -19
  21. data/locales/fa.yml +0 -17
  22. data/locales/fr.yml +0 -18
  23. data/locales/he.yml +0 -18
  24. data/locales/hi.yml +0 -18
  25. data/locales/hu.yml +0 -18
  26. data/locales/hy.yml +0 -18
  27. data/locales/id.yml +0 -17
  28. data/locales/it.yml +0 -18
  29. data/locales/ja.yml +0 -16
  30. data/locales/ko.yml +0 -16
  31. data/locales/lt.yml +0 -17
  32. data/locales/lv.yml +0 -17
  33. data/locales/pl.yml +0 -19
  34. data/locales/ps.yml +0 -17
  35. data/locales/pt.yml +0 -17
  36. data/locales/ro.yml +0 -19
  37. data/locales/ru.yml +0 -16
  38. data/locales/si.yml +0 -17
  39. data/locales/sr.yml +0 -18
  40. data/locales/ta.yml +0 -19
  41. data/locales/th.yml +0 -16
  42. data/locales/tr.yml +0 -17
  43. data/locales/uk.yml +0 -17
  44. data/locales/ur.yml +0 -18
  45. data/locales/uz.yml +0 -17
  46. data/locales/vi.yml +0 -17
  47. data/locales/zh-hk.yml +0 -15
  48. data/locales/zh-tw.yml +0 -15
  49. data/locales/zh.yml +0 -15
  50. data/test/blockquote_extra_quote_remover_test.rb +7 -0
  51. data/test/govspeak_attachment_link_test.rb +25 -0
  52. data/test/govspeak_attachment_test.rb +40 -0
  53. metadata +33 -35
  54. data/lib/templates/attachment.html.erb +0 -57
  55. data/locales/dr.yml +0 -20
  56. data/locales/so.yml +0 -22
  57. data/locales/sq.yml +0 -21
  58. data/test/govspeak_attachments_test.rb +0 -358
@@ -1,23 +1,6 @@
1
1
  ---
2
2
  vi:
3
3
  govspeak:
4
- attachment:
5
- accessibility:
6
- full_help_html: |-
7
- Để yêu cầu tài liệu này dưới định dạng khác như tài liệu chữ nổi, tiếng hay một định dạng file khác, xin mời email đến %{email}
8
- cung cấp địa chỉ của bạn, số điện thoại cùng với tiêu đề của tài liệu ("%{title}")%{references}.
9
- heading: 'File này không phù hợp với công nghệ hỗ trợ của người dùng '
10
- request_a_different_format: Yêu cầu một định dạng khác
11
- headings:
12
- order_a_copy: Đặt một bản sao
13
- order_a_copy_full: Đặt một bản sao của ấn phẩm truyền thông
14
- published: Đã đăng
15
- reference: đối với
16
- unnumbered_command_paper:
17
- unnumbered_hoc_paper:
18
- opendocument:
19
- help_html:
20
- see_more:
21
4
  contact:
22
5
  contact_form: Mẫu liên hệ
23
6
  email: Email
@@ -1,21 +1,6 @@
1
1
  ---
2
2
  zh-hk:
3
3
  govspeak:
4
- attachment:
5
- accessibility:
6
- full_help_html: 尋求另一種檔案格式:點字或音檔
7
- heading: 此檔案不適合使用科技輔助的使用者
8
- request_a_different_format: 尋求別種格式
9
- headings:
10
- order_a_copy: 訂閱副本
11
- order_a_copy_full: 訂閱報告副本
12
- published: 已發布
13
- reference: 參考
14
- unnumbered_command_paper:
15
- unnumbered_hoc_paper:
16
- opendocument:
17
- help_html:
18
- see_more:
19
4
  contact:
20
5
  contact_form: "聯絡資料表"
21
6
  email: "電子郵件"
@@ -1,21 +1,6 @@
1
1
  ---
2
2
  zh-tw:
3
3
  govspeak:
4
- attachment:
5
- accessibility:
6
- full_help_html: 尋求另一種檔案格式:點字或音檔
7
- heading: 此檔案不適合使用科技輔助的使用者
8
- request_a_different_format: 尋求別種格式
9
- headings:
10
- order_a_copy: 訂購備份
11
- order_a_copy_full: 訂購發行刊物
12
- published: 發行
13
- reference: 參考
14
- unnumbered_command_paper:
15
- unnumbered_hoc_paper:
16
- opendocument:
17
- help_html:
18
- see_more:
19
4
  contact:
20
5
  contact_form: "聯絡資料表"
21
6
  email: "電子郵件"
@@ -1,21 +1,6 @@
1
1
  ---
2
2
  zh:
3
3
  govspeak:
4
- attachment:
5
- accessibility:
6
- full_help_html: 申请本文件的其它格式,如盲文、音频或者不同的文件类型,请发送邮件%{email}并写明您的地址、电话号码以及此报告的标题("%{title}")%{references}。
7
- heading: 此文件可能对使用辅助技术的用户不适合。
8
- request_a_different_format: 申请另一种格式。
9
- headings:
10
- order_a_copy: 订阅副本
11
- order_a_copy_full: 订阅报告副本
12
- published: 已发布
13
- reference: Ref
14
- unnumbered_command_paper:
15
- unnumbered_hoc_paper:
16
- opendocument:
17
- help_html:
18
- see_more:
19
4
  contact:
20
5
  contact_form: "联系表格"
21
6
  email: "邮件"
@@ -60,6 +60,13 @@ class BlockquoteExtraQuoteRemoverTest < Minitest::Test
60
60
  )
61
61
  end
62
62
 
63
+ test "handles space after a quote" do
64
+ assert_remover_transforms(
65
+ %{>" Test"} =>
66
+ %{> Test}
67
+ )
68
+ end
69
+
63
70
  test "remove double double quotes" do
64
71
  assert_remover_transforms(
65
72
  %{We heard it said:\n\n> ""Today the coalition is remedying those deficiencies by putting in place a new fast track process where the people's elected representatives have responsibility for the final decisions about Britain's future instead of unelected commissioners.""} =>
@@ -0,0 +1,25 @@
1
+ # encoding: UTF-8
2
+
3
+ require "test_helper"
4
+
5
+ class GovspeakAttachmentLinkTest < Minitest::Test
6
+ def render_govspeak(govspeak, attachments = [])
7
+ Govspeak::Document.new(govspeak, attachments: attachments).to_html
8
+ end
9
+
10
+ test "renders an empty string for attachment link that is not found" do
11
+ assert_equal("\n", render_govspeak("[AttachmentLink:file.pdf]", []))
12
+ end
13
+
14
+ test "renders an attachment link component for a found attachment link" do
15
+ attachment = {
16
+ id: "attachment.pdf",
17
+ url: "http://example.com/attachment.pdf",
18
+ title: "Attachment Title",
19
+ }
20
+
21
+ rendered = render_govspeak("[AttachmentLink:attachment.pdf]", [attachment])
22
+ assert_match(/<span class="gem-c-attachment-link">/, rendered)
23
+ assert_match(%r{href="http://example.com/attachment.pdf"}, rendered)
24
+ end
25
+ end
@@ -0,0 +1,40 @@
1
+ # encoding: UTF-8
2
+
3
+ require "test_helper"
4
+
5
+ class GovspeakAttachmentTest < Minitest::Test
6
+ def render_govspeak(govspeak, attachments = [])
7
+ Govspeak::Document.new(govspeak, attachments: attachments).to_html
8
+ end
9
+
10
+ test "renders an empty string for attachment link that is not found" do
11
+ assert_equal("\n", render_govspeak("[Attachment:file.pdf]", []))
12
+ end
13
+
14
+ test "renders an attachment component for a found attachment" do
15
+ attachment = {
16
+ id: "attachment.pdf",
17
+ url: "http://example.com/attachment.pdf",
18
+ title: "Attachment Title",
19
+ }
20
+
21
+ rendered = render_govspeak("[Attachment:attachment.pdf]", [attachment])
22
+ assert_match(/<section class="gem-c-attachment">/, rendered)
23
+ assert_match(/Attachment Title/, rendered)
24
+ end
25
+
26
+ test "only renders attachment when markdown extension starts on a line" do
27
+ attachment = {
28
+ id: "attachment.pdf",
29
+ url: "http://example.com/attachment.pdf",
30
+ title: "Attachment Title",
31
+ }
32
+
33
+ rendered = render_govspeak("some text [Attachment:attachment.pdf]", [attachment])
34
+ assert_equal("<p>some text [Attachment:attachment.pdf]</p>\n", rendered)
35
+
36
+ rendered = render_govspeak("[Attachment:attachment.pdf] some text", [attachment])
37
+ assert_match(/<section class="gem-c-attachment">/, rendered)
38
+ assert_match(/<p>some text<\/p>/, rendered)
39
+ end
40
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govspeak
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.1.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-03-14 00:00:00.000000000 Z
11
+ date: 2019-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -45,61 +45,61 @@ dependencies:
45
45
  - !ruby/object:Gem::Version
46
46
  version: '3'
47
47
  - !ruby/object:Gem::Dependency
48
- name: htmlentities
48
+ name: govuk_publishing_components
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '4'
53
+ version: '16.16'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: '4'
60
+ version: '16.16'
61
61
  - !ruby/object:Gem::Dependency
62
- name: i18n
62
+ name: htmlentities
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0.7'
67
+ version: '4'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '0.7'
74
+ version: '4'
75
75
  - !ruby/object:Gem::Dependency
76
- name: kramdown
76
+ name: i18n
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: 1.15.0
81
+ version: '0.7'
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: 1.15.0
88
+ version: '0.7'
89
89
  - !ruby/object:Gem::Dependency
90
- name: money
90
+ name: kramdown
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '6.7'
95
+ version: 1.15.0
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '6.7'
102
+ version: 1.15.0
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: nokogiri
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -261,7 +261,6 @@ files:
261
261
  - lib/govspeak/template_renderer.rb
262
262
  - lib/govspeak/version.rb
263
263
  - lib/kramdown/parser/kramdown_with_automatic_external_links.rb
264
- - lib/templates/attachment.html.erb
265
264
  - lib/templates/contact.html.erb
266
265
  - locales/ar.yml
267
266
  - locales/be.yml
@@ -269,7 +268,6 @@ files:
269
268
  - locales/cs.yml
270
269
  - locales/cy.yml
271
270
  - locales/de.yml
272
- - locales/dr.yml
273
271
  - locales/el.yml
274
272
  - locales/en.yml
275
273
  - locales/es-419.yml
@@ -293,8 +291,6 @@ files:
293
291
  - locales/ro.yml
294
292
  - locales/ru.yml
295
293
  - locales/si.yml
296
- - locales/so.yml
297
- - locales/sq.yml
298
294
  - locales/sr.yml
299
295
  - locales/ta.yml
300
296
  - locales/th.yml
@@ -307,9 +303,10 @@ files:
307
303
  - locales/zh-tw.yml
308
304
  - locales/zh.yml
309
305
  - test/blockquote_extra_quote_remover_test.rb
306
+ - test/govspeak_attachment_link_test.rb
307
+ - test/govspeak_attachment_test.rb
310
308
  - test/govspeak_attachments_image_test.rb
311
309
  - test/govspeak_attachments_inline_test.rb
312
- - test/govspeak_attachments_test.rb
313
310
  - test/govspeak_button_test.rb
314
311
  - test/govspeak_contacts_test.rb
315
312
  - test/govspeak_extract_contact_content_ids_test.rb
@@ -342,26 +339,27 @@ required_rubygems_version: !ruby/object:Gem::Requirement
342
339
  - !ruby/object:Gem::Version
343
340
  version: '0'
344
341
  requirements: []
345
- rubygems_version: 3.0.1
342
+ rubygems_version: 3.0.3
346
343
  signing_key:
347
344
  specification_version: 4
348
345
  summary: Markup language for single domain
349
346
  test_files:
350
- - test/blockquote_extra_quote_remover_test.rb
351
- - test/govspeak_test_helper.rb
352
- - test/govspeak_structured_headers_test.rb
353
- - test/govspeak_attachments_image_test.rb
354
- - test/govspeak_attachments_test.rb
347
+ - test/govspeak_attachment_link_test.rb
355
348
  - test/test_helper.rb
356
- - test/govspeak_attachments_inline_test.rb
357
- - test/html_sanitizer_test.rb
358
349
  - test/govspeak_button_test.rb
359
- - test/govspeak_images_bang_test.rb
360
- - test/govspeak_images_test.rb
361
- - test/html_validator_test.rb
362
- - test/govspeak_extract_contact_content_ids_test.rb
363
350
  - test/govspeak_test.rb
364
- - test/govspeak_link_extractor_test.rb
365
- - test/govspeak_link_test.rb
351
+ - test/html_validator_test.rb
352
+ - test/govspeak_attachment_test.rb
366
353
  - test/govspeak_contacts_test.rb
354
+ - test/govspeak_test_helper.rb
355
+ - test/blockquote_extra_quote_remover_test.rb
356
+ - test/govspeak_attachments_image_test.rb
357
+ - test/html_sanitizer_test.rb
358
+ - test/govspeak_link_test.rb
359
+ - test/govspeak_extract_contact_content_ids_test.rb
360
+ - test/govspeak_structured_headers_test.rb
361
+ - test/govspeak_images_test.rb
367
362
  - test/presenters/h_card_presenter_test.rb
363
+ - test/govspeak_images_bang_test.rb
364
+ - test/govspeak_link_extractor_test.rb
365
+ - test/govspeak_attachments_inline_test.rb
@@ -1,57 +0,0 @@
1
- <section class="attachment <%= attachment.section_class %>">
2
- <div class="attachment-thumb">
3
- <%= attachment.thumbnail_link %>
4
- </div>
5
- <div class="attachment-details">
6
- <h2 class="title"><%= attachment.attachment_details %></h2>
7
- <p class="metadata">
8
- <% if attachment.references? %>
9
- <span class="references"><%= t('govspeak.attachment.headings.reference') %>: <%= attachment.reference %></span>
10
- <% end %>
11
- <% if attachment.unnumbered_paper? %>
12
- <span class="unnumbered-paper">
13
- <% if attachment.unnumbered_command_paper? %>
14
- <%= t('govspeak.attachment.headings.unnumbered_command_paper') %>
15
- <% else %>
16
- <%= t('govspeak.attachment.headings.unnumbered_hoc_paper') %>
17
- <% end %>
18
- </span>
19
- <% end %>
20
- <% if attachment.previewable? %>
21
- <span class="preview">
22
- <strong><%= attachment.link("View online", attachment.preview_url) %></strong>
23
- </span>
24
- <span class="download"><%= attachment.download_link %></span>
25
- <% else %>
26
- <%= attachment.attachment_attributes %>
27
- <% end %>
28
- </p>
29
- <% if attachment.order_url.present? %>
30
- <p>
31
- <%= attachment.link t('govspeak.attachment.headings.order_a_copy'), attachment.order_url,
32
- class: "order_url", title: t('govspeak.attachment.headings.order_a_copy_full')
33
- %><% if attachment.price %>(<span class="price"><%= attachment.price %></span>)<% end %>
34
- </p>
35
- <% end %>
36
-
37
- <% if attachment.opendocument? %>
38
- <p class="opendocument-help">
39
- <%= t('govspeak.attachment.opendocument.help_html') %>
40
- </p>
41
- <% end %>
42
-
43
- <% unless attachment.accessible? %>
44
- <div data-module="toggle" class="accessibility-warning" id="<%= attachment.help_block_id %>">
45
- <h2><%= t('govspeak.attachment.accessibility.heading') %>
46
- <a class="toggler" href="#<%= attachment.help_block_toggle_id %>" data-controls="<%= attachment.help_block_toggle_id %>" data-expanded="false"><%= t('govspeak.attachment.accessibility.request_a_different_format') %></a>
47
- </h2>
48
- <p id="<%= attachment.help_block_toggle_id %>" class="js-hidden">
49
- <%= t('govspeak.attachment.accessibility.full_help_html',
50
- email: attachment.alternative_format_order_link,
51
- title: attachment.title,
52
- references: attachment.references_for_title) %>
53
- </p>
54
- </div>
55
- <% end %>
56
- </div>
57
- </section>
@@ -1,20 +0,0 @@
1
- ---
2
- dr:
3
- govspeak:
4
- attachment:
5
- accessibility:
6
- full_help_html: جهت درخواست سند در فارمت بدیل مانند بریل، صوتی و یا هم در فارمت
7
- متفاوت لطفاً آدرس، شماره تماس با نام نشریه ("%{title}")%{references} را ایمیل
8
- %{email} کنید
9
- heading: این فایل برای استعمال کننده گان تکنالوجی کمکی مناسب نخواهد بود
10
- request_a_different_format: فارمت متفاوت را درخواست نمائید
11
- headings:
12
- order_a_copy: نقل را درخواست نمائید
13
- order_a_copy_full: نقل نشریه را درخواست نمائید
14
- published: نشر شده
15
- reference: ماخذ
16
- unnumbered_command_paper:
17
- unnumbered_hoc_paper:
18
- opendocument:
19
- help_html:
20
- see_more:
@@ -1,22 +0,0 @@
1
- ---
2
- so:
3
- govspeak:
4
- attachment:
5
- accessibility:
6
- full_help_html: Sida aad u codsato qoraalka oo qaab kale u qoran sida isaga
7
- oo lagu qorey farta loogu talogaley dadka aan indhaha lahayn, cod ah ama fayl
8
- nooc kale ah fadlan e-mail soo dir %{email} adiga oo ku soo sheegaya cinwaankaada,
9
- lambarka telefoonkaada adiga oo soo raacinaya cinwaanka qoraalka ("%{title}")%{references}.
10
- heading: Waxaa laga yaabaa in aanu faylkan u habbooneyn kuwa isticmaala tiknolojiyada
11
- la kaashado
12
- request_a_different_format: Codsi isaga oo qaab kale ah
13
- headings:
14
- order_a_copy: Dalbo nuqul
15
- order_a_copy_full: Dalbo nuqulka daabacaadda
16
- published: La-daabacay
17
- reference: Xigasho
18
- unnumbered_command_paper:
19
- unnumbered_hoc_paper:
20
- opendocument:
21
- help_html:
22
- see_more:
@@ -1,21 +0,0 @@
1
- ---
2
- sq:
3
- govspeak:
4
- attachment:
5
- accessibility:
6
- full_help_html: Per te kerkuar kete dokument ne format alternativ si braille,
7
- audio ose format tjeter te lutem email %{email} duke cituar adresen tende,
8
- telefonin dhe titullin e publikimit ("%{title}")%{references}.
9
- heading: Ky dokument mund te mos jete i pershtatshem per perdoruesit e teknologjise
10
- ndihmuese.
11
- request_a_different_format: Kerko nje format ndryshe
12
- headings:
13
- order_a_copy: Porosit nje kopje
14
- order_a_copy_full: Porosit nje kopje te publikimit
15
- published: Publikuar
16
- reference: Ref
17
- unnumbered_command_paper:
18
- unnumbered_hoc_paper:
19
- opendocument:
20
- help_html:
21
- see_more: