content_block_tools 0.8.0 → 0.10.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/CHANGELOG.md +9 -0
- data/content_block_tools.gemspec +1 -0
- data/lib/content_block_tools/helpers/govspeak.rb +10 -0
- data/lib/content_block_tools/presenters/base_presenter.rb +1 -1
- data/lib/content_block_tools/presenters/block_presenters/base_presenter.rb +2 -0
- data/lib/content_block_tools/presenters/block_presenters/contact/address_presenter.rb +11 -5
- data/lib/content_block_tools/presenters/block_presenters/contact/block_level_contact_item.rb +11 -7
- data/lib/content_block_tools/presenters/block_presenters/contact/contact_form_presenter.rb +8 -6
- data/lib/content_block_tools/presenters/block_presenters/contact/email_address_presenter.rb +8 -6
- data/lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb +27 -3
- data/lib/content_block_tools/presenters/contact_presenter.rb +1 -1
- data/lib/content_block_tools/version.rb +1 -1
- data/lib/content_block_tools.rb +3 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 076d610c0146672c70d0b2d7971b6917c87fc395599ff546e0f50a0fe6817bf5
|
4
|
+
data.tar.gz: 3027bd4756b5246363b8ad1f220d9ec6da2e3c30dd79d3b1716ac568146be0fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31ebe02a43ba3a92b7f5c18717dc7e9b889aba02fd453d68f7bd71a494d82af835c182eebd8ff54abeed544dc0983016ef1abf659b356faca233d1ca8da3e8dc
|
7
|
+
data.tar.gz: 1dd7eeeaa7aaba5f6ff1c7ca485eb4ed131dd604845dce282c700318f1314b281989d9993074e55f0dd12ba17e0324372a36acd9f508cfb506c53a6862c3a74a
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,15 @@
|
|
7
7
|
useful summary for people upgrading their application, not a replication
|
8
8
|
of the commit log.
|
9
9
|
|
10
|
+
## 0.10.0
|
11
|
+
|
12
|
+
- Add content block titles to individual contact blocks ([60](https://github.com/alphagov/govuk_content_block_tools/pull/60))
|
13
|
+
- Render title and description within telephone blocks ([60](https://github.com/alphagov/govuk_content_block_tools/pull/60))
|
14
|
+
|
15
|
+
## 0.9.0
|
16
|
+
|
17
|
+
- Render addresses within a `contact` div ([58](https://github.com/alphagov/govuk_content_block_tools/pull/58))
|
18
|
+
|
10
19
|
## 0.8.0
|
11
20
|
|
12
21
|
- Add wrapper classes to contact sub-blocks ([57](https://github.com/alphagov/govuk_content_block_tools/pull/57))
|
data/content_block_tools.gemspec
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
module ContentBlockTools
|
2
|
+
module Govspeak
|
3
|
+
def render_govspeak(body, root_class: nil)
|
4
|
+
html = ::Govspeak::Document.new(body).to_html
|
5
|
+
Nokogiri::HTML.fragment(html).tap { |fragment|
|
6
|
+
fragment.children[0].add_class(root_class) if root_class
|
7
|
+
}.to_s.html_safe
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -75,7 +75,7 @@ module ContentBlockTools
|
|
75
75
|
return content_block.embed_code
|
76
76
|
end
|
77
77
|
|
78
|
-
field_or_block_presenter.new(field_or_block_content, rendering_context: :field_names).render
|
78
|
+
field_or_block_presenter.new(field_or_block_content, rendering_context: :field_names, content_block:).render
|
79
79
|
end
|
80
80
|
|
81
81
|
def field_names
|
@@ -1,15 +1,21 @@
|
|
1
|
+
require_relative "./block_level_contact_item"
|
2
|
+
|
1
3
|
module ContentBlockTools
|
2
4
|
module Presenters
|
3
5
|
module BlockPresenters
|
4
6
|
module Contact
|
5
7
|
class AddressPresenter < ContentBlockTools::Presenters::BlockPresenters::BasePresenter
|
8
|
+
include ContentBlockTools::Presenters::BlockPresenters::Contact::BlockLevelContactItem
|
9
|
+
|
6
10
|
def render
|
7
|
-
|
8
|
-
|
9
|
-
|
11
|
+
wrapper do
|
12
|
+
content_tag(:p, class: "adr") do
|
13
|
+
%i[street_address locality region postal_code country].map { |field|
|
14
|
+
next if item[field].blank?
|
10
15
|
|
11
|
-
|
12
|
-
|
16
|
+
content_tag(:span, item[field], { class: class_for_field_name(field) })
|
17
|
+
}.compact_blank.join(",<br/>").html_safe
|
18
|
+
end
|
13
19
|
end
|
14
20
|
end
|
15
21
|
|
data/lib/content_block_tools/presenters/block_presenters/contact/block_level_contact_item.rb
CHANGED
@@ -5,24 +5,28 @@ module ContentBlockTools
|
|
5
5
|
module BlockLevelContactItem
|
6
6
|
BASE_TAG_TYPE = :div
|
7
7
|
|
8
|
-
def initialize(item, rendering_context: :block, **_args)
|
8
|
+
def initialize(item, content_block:, rendering_context: :block, **_args)
|
9
9
|
@item = item
|
10
|
+
@content_block = content_block
|
10
11
|
@rendering_context = rendering_context
|
11
12
|
end
|
12
13
|
|
13
14
|
def wrapper(&block)
|
14
15
|
if @rendering_context == :field_names
|
15
16
|
content_tag(:div, class: "contact") do
|
16
|
-
|
17
|
-
|
18
|
-
end
|
17
|
+
concat title
|
18
|
+
concat yield block
|
19
19
|
end
|
20
20
|
else
|
21
|
-
|
22
|
-
yield block
|
23
|
-
end
|
21
|
+
yield block
|
24
22
|
end
|
25
23
|
end
|
24
|
+
|
25
|
+
def title
|
26
|
+
content_tag(:p,
|
27
|
+
@content_block.title,
|
28
|
+
class: "govuk-!-margin-bottom-3")
|
29
|
+
end
|
26
30
|
end
|
27
31
|
end
|
28
32
|
end
|
@@ -9,12 +9,14 @@ module ContentBlockTools
|
|
9
9
|
|
10
10
|
def render
|
11
11
|
wrapper do
|
12
|
-
content_tag(:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
content_tag(:div, class: "email-url-number") do
|
13
|
+
content_tag(:p) do
|
14
|
+
concat content_tag(:span, item[:title])
|
15
|
+
concat content_tag(:a,
|
16
|
+
item[:url],
|
17
|
+
class: "url",
|
18
|
+
href: item[:url])
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
@@ -9,12 +9,14 @@ module ContentBlockTools
|
|
9
9
|
|
10
10
|
def render
|
11
11
|
wrapper do
|
12
|
-
content_tag(:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
content_tag(:div, class: "email-url-number") do
|
13
|
+
content_tag(:p) do
|
14
|
+
concat content_tag(:span, item[:title])
|
15
|
+
concat content_tag(:a,
|
16
|
+
item[:email_address],
|
17
|
+
class: "email",
|
18
|
+
href: "mailto:#{item[:email_address]}")
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
@@ -9,12 +9,36 @@ module ContentBlockTools
|
|
9
9
|
|
10
10
|
def render
|
11
11
|
wrapper do
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
content_tag(:div, class: "email-url-number") do
|
13
|
+
concat title_and_description
|
14
|
+
concat number_list
|
15
|
+
concat opening_hours_list if item[:opening_hours].present?
|
16
|
+
concat call_charges_link
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def title_and_description
|
22
|
+
items = [
|
23
|
+
(item_title if item[:title].present?),
|
24
|
+
(description if item[:description].present?),
|
25
|
+
].compact
|
26
|
+
|
27
|
+
if items.any?
|
28
|
+
content_tag(:div, class: "govuk-!-margin-bottom-3") do
|
29
|
+
concat items.join("").html_safe
|
30
|
+
end
|
15
31
|
end
|
16
32
|
end
|
17
33
|
|
34
|
+
def item_title
|
35
|
+
content_tag(:p, item[:title], { class: "govuk-!-margin-bottom-0" })
|
36
|
+
end
|
37
|
+
|
38
|
+
def description
|
39
|
+
render_govspeak(item[:description], root_class: "govuk-!-margin-top-1 govuk-!-margin-bottom-0")
|
40
|
+
end
|
41
|
+
|
18
42
|
def number_list
|
19
43
|
content_tag(:ul) do
|
20
44
|
item[:telephone_numbers].each do |number|
|
@@ -27,7 +27,7 @@ module ContentBlockTools
|
|
27
27
|
concat content_tag(:p, content_block.title, class: "fn org")
|
28
28
|
embedded_objects.each do |object|
|
29
29
|
items = send(object)
|
30
|
-
concat(items.map { |item| presenter_for_object_type(object).new(item).render }.join.html_safe)
|
30
|
+
concat(items.map { |item| presenter_for_object_type(object).new(item, content_block:).render }.join.html_safe)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
data/lib/content_block_tools.rb
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
require "action_view"
|
4
4
|
require "uri"
|
5
|
+
require "govspeak"
|
6
|
+
|
7
|
+
require "content_block_tools/helpers/govspeak"
|
5
8
|
|
6
9
|
require "content_block_tools/presenters/field_presenters/base_presenter"
|
7
10
|
require "content_block_tools/presenters/field_presenters/contact/email_address_presenter"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: content_block_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
@@ -79,6 +79,20 @@ dependencies:
|
|
79
79
|
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '6'
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: govspeak
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 10.4.1
|
89
|
+
type: :runtime
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 10.4.1
|
82
96
|
email:
|
83
97
|
- govuk-dev@digital.cabinet-office.gov.uk
|
84
98
|
executables: []
|
@@ -105,6 +119,7 @@ files:
|
|
105
119
|
- lib/content_block_tools.rb
|
106
120
|
- lib/content_block_tools/content_block.rb
|
107
121
|
- lib/content_block_tools/content_block_reference.rb
|
122
|
+
- lib/content_block_tools/helpers/govspeak.rb
|
108
123
|
- lib/content_block_tools/presenters/base_presenter.rb
|
109
124
|
- lib/content_block_tools/presenters/block_presenters/base_presenter.rb
|
110
125
|
- lib/content_block_tools/presenters/block_presenters/contact/address_presenter.rb
|
@@ -135,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
150
|
- !ruby/object:Gem::Version
|
136
151
|
version: '0'
|
137
152
|
requirements: []
|
138
|
-
rubygems_version: 3.
|
153
|
+
rubygems_version: 3.7.0
|
139
154
|
specification_version: 4
|
140
155
|
summary: A suite of tools for working with GOV.UK Content Blocks
|
141
156
|
test_files: []
|