content_block_tools 0.7.0 → 0.9.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 +8 -0
- data/lib/content_block_tools/presenters/base_presenter.rb +1 -1
- data/lib/content_block_tools/presenters/block_presenters/base_presenter.rb +1 -1
- data/lib/content_block_tools/presenters/block_presenters/contact/address_presenter.rb +21 -5
- data/lib/content_block_tools/presenters/block_presenters/contact/block_level_contact_item.rb +26 -0
- data/lib/content_block_tools/presenters/block_presenters/contact/contact_form_presenter.rb +13 -7
- data/lib/content_block_tools/presenters/block_presenters/contact/email_address_presenter.rb +13 -7
- data/lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb +9 -5
- data/lib/content_block_tools/presenters/contact_presenter.rb +2 -0
- data/lib/content_block_tools/presenters/field_presenters/base_presenter.rb +1 -1
- data/lib/content_block_tools/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 565c412328ad54e9e45ca5ce473e6876147543cf88900dafde91083042c6b0ab
|
4
|
+
data.tar.gz: 8de3aab0cbfb65213cf1dceadd420ebdd1c006d6f9e715963bb6e49383617b1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffda22c0d89798cea8b029ee90c2bc65564ab25fe7de67047251aafd53b01b1a7f127bc5c4af9deebba2e21e968767380dbde01993d9d9143394f7e0308ad5a4
|
7
|
+
data.tar.gz: '07429aa7168f233ca8935cf7c20c4e30221bdf0a1970f4376ffa30214e5bd09307509f331e97fd86e30d8babe94c7e4242c5a2cfe757dc0bfacf00a4362e351b'
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,14 @@
|
|
7
7
|
useful summary for people upgrading their application, not a replication
|
8
8
|
of the commit log.
|
9
9
|
|
10
|
+
## 0.9.0
|
11
|
+
|
12
|
+
- Render addresses within a `contact` div ([58](https://github.com/alphagov/govuk_content_block_tools/pull/58))
|
13
|
+
|
14
|
+
## 0.8.0
|
15
|
+
|
16
|
+
- Add wrapper classes to contact sub-blocks ([57](https://github.com/alphagov/govuk_content_block_tools/pull/57))
|
17
|
+
|
10
18
|
## 0.7.0
|
11
19
|
|
12
20
|
- Alter markup of contact ([55](https://github.com/alphagov/govuk_content_block_tools/pull/55))
|
@@ -1,15 +1,31 @@
|
|
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?
|
15
|
+
|
16
|
+
content_tag(:span, item[field], { class: class_for_field_name(field) })
|
17
|
+
}.compact_blank.join(",<br/>").html_safe
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
10
21
|
|
11
|
-
|
12
|
-
|
22
|
+
def wrapper(&block)
|
23
|
+
if @rendering_context == :field_names
|
24
|
+
content_tag(:div, class: "contact") do
|
25
|
+
yield block
|
26
|
+
end
|
27
|
+
else
|
28
|
+
yield block
|
13
29
|
end
|
14
30
|
end
|
15
31
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ContentBlockTools
|
2
|
+
module Presenters
|
3
|
+
module BlockPresenters
|
4
|
+
module Contact
|
5
|
+
module BlockLevelContactItem
|
6
|
+
BASE_TAG_TYPE = :div
|
7
|
+
|
8
|
+
def initialize(item, rendering_context: :block, **_args)
|
9
|
+
@item = item
|
10
|
+
@rendering_context = rendering_context
|
11
|
+
end
|
12
|
+
|
13
|
+
def wrapper(&block)
|
14
|
+
if @rendering_context == :field_names
|
15
|
+
content_tag(:div, class: "contact") do
|
16
|
+
yield block
|
17
|
+
end
|
18
|
+
else
|
19
|
+
yield block
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,16 +1,22 @@
|
|
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 ContactFormPresenter < ContentBlockTools::Presenters::BlockPresenters::BasePresenter
|
8
|
+
include ContentBlockTools::Presenters::BlockPresenters::Contact::BlockLevelContactItem
|
9
|
+
|
6
10
|
def render
|
7
|
-
|
8
|
-
content_tag(:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
wrapper do
|
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
|
14
20
|
end
|
15
21
|
end
|
16
22
|
end
|
@@ -1,16 +1,22 @@
|
|
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 EmailAddressPresenter < ContentBlockTools::Presenters::BlockPresenters::BasePresenter
|
8
|
+
include ContentBlockTools::Presenters::BlockPresenters::Contact::BlockLevelContactItem
|
9
|
+
|
6
10
|
def render
|
7
|
-
|
8
|
-
content_tag(:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
wrapper do
|
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
|
14
20
|
end
|
15
21
|
end
|
16
22
|
end
|
@@ -1,15 +1,19 @@
|
|
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 TelephonePresenter < ContentBlockTools::Presenters::BlockPresenters::BasePresenter
|
6
|
-
|
8
|
+
include ContentBlockTools::Presenters::BlockPresenters::Contact::BlockLevelContactItem
|
7
9
|
|
8
10
|
def render
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
wrapper do
|
12
|
+
content_tag(:div, class: "email-url-number") do
|
13
|
+
concat number_list
|
14
|
+
concat opening_hours_list if item[:opening_hours].present?
|
15
|
+
concat call_charges_link
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
15
19
|
|
@@ -12,6 +12,8 @@ module ContentBlockTools
|
|
12
12
|
BLOCK_PRESENTERS = {
|
13
13
|
addresses: ContentBlockTools::Presenters::BlockPresenters::Contact::AddressPresenter,
|
14
14
|
telephones: ContentBlockTools::Presenters::BlockPresenters::Contact::TelephonePresenter,
|
15
|
+
email_addresses: ContentBlockTools::Presenters::BlockPresenters::Contact::EmailAddressPresenter,
|
16
|
+
contact_forms: ContentBlockTools::Presenters::BlockPresenters::Contact::ContactFormPresenter,
|
15
17
|
}.freeze
|
16
18
|
|
17
19
|
has_embedded_objects :addresses, :email_addresses, :telephones, :contact_forms
|
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.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- lib/content_block_tools/presenters/base_presenter.rb
|
109
109
|
- lib/content_block_tools/presenters/block_presenters/base_presenter.rb
|
110
110
|
- lib/content_block_tools/presenters/block_presenters/contact/address_presenter.rb
|
111
|
+
- lib/content_block_tools/presenters/block_presenters/contact/block_level_contact_item.rb
|
111
112
|
- lib/content_block_tools/presenters/block_presenters/contact/contact_form_presenter.rb
|
112
113
|
- lib/content_block_tools/presenters/block_presenters/contact/email_address_presenter.rb
|
113
114
|
- lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb
|