govuk_publishing_components 9.24.0 → 9.25.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: d96cc42674fd300f72617dc7b61c347801407bb831067d0e4ed1e1a8ae33357a
4
- data.tar.gz: 151100b8a74eee825b24a88eb09c10ae113492d698221ca9bdc3b34c42d96fb4
3
+ metadata.gz: fd0431873bfd24e6d770033d912c371dde3c33b33ced0c36205db2c970d122e8
4
+ data.tar.gz: 5692cd938bc333869b439de5b1a07bb560ea324ccf88922c5f3156f343a2f600
5
5
  SHA512:
6
- metadata.gz: bbf1201dc581d1f5f816b835bd2eebc545a3c63ba2450854f8bc2236115e5acdbd64f6e5a63b3b0101a4000a796fe7053d4dfbd3fad0a82d32b1a77ecfef29bb
7
- data.tar.gz: 40857d35934e4f8a454896abd065f1cd15c82aa6b31cf56c7948696fcff11b92ea180392f15490e006a0680ab2cdd40e503ee18ced84ba7053baf224cc33ded0
6
+ metadata.gz: 6a23c1b4980f24754815743f808093b47485939fce5d97a2b6d41ed298596af1650e805b86f3fd6b413d2fecf91b3580125b08433375d9fba9975e54b799049a
7
+ data.tar.gz: 35ec2d9303ab22bb9394ca34e102dfdede8eaecae66f0c24f4ecacd3eefc04df28a19fe31786c2242f0e9376563ac10a720fdd966b919a0a7f783e12205b7bc5
@@ -29,7 +29,7 @@ module GovukPublishingComponents
29
29
  "url" => page.logo_url,
30
30
  }
31
31
  }
32
- }.merge(image_schema).merge(author_schema).merge(body).merge(is_part_of).merge(about)
32
+ }.merge(image_schema).merge(author_schema).merge(body).merge(is_part_of).merge(about).merge(has_part)
33
33
  end
34
34
 
35
35
  private
@@ -99,6 +99,21 @@ module GovukPublishingComponents
99
99
  )
100
100
  end
101
101
 
102
+ def has_part
103
+ return {} unless collection_pages.any?
104
+ {
105
+ "hasPart" => collection_pages.map { |document| HasPartSchema.new(document).structured_data }
106
+ }
107
+ end
108
+
109
+ def collection_pages
110
+ @pages ||= fetch_collection_pages
111
+ end
112
+
113
+ def fetch_collection_pages
114
+ page.content_item.dig("links", "documents").to_a.map { |document| document["web_url"] }
115
+ end
116
+
102
117
  def about
103
118
  return {} unless live_taxons.any?
104
119
  {
@@ -0,0 +1,20 @@
1
+ module GovukPublishingComponents
2
+ module Presenters
3
+ class HasPartSchema
4
+ attr_reader :has_part_url
5
+
6
+ def initialize(has_part_url)
7
+ @has_part_url = has_part_url
8
+ end
9
+
10
+ def structured_data
11
+ # http://schema.org/hasPart - minimal
12
+ {
13
+ "@context" => "http://schema.org",
14
+ "@type" => "CreativeWork",
15
+ "sameAs" => has_part_url
16
+ }
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,6 +1,7 @@
1
1
  require 'govuk_publishing_components/presenters/machine_readable/page'
2
2
  require 'govuk_publishing_components/presenters/machine_readable/article_schema'
3
3
  require 'govuk_publishing_components/presenters/machine_readable/how_to_schema'
4
+ require 'govuk_publishing_components/presenters/machine_readable/has_part_schema'
4
5
  require 'govuk_publishing_components/presenters/machine_readable/news_article_schema'
5
6
  require 'govuk_publishing_components/presenters/machine_readable/organisation_schema'
6
7
  require 'govuk_publishing_components/presenters/machine_readable/person_schema'
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '9.24.0'.freeze
2
+ VERSION = '9.25.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: 9.24.0
4
+ version: 9.25.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: 2018-09-19 00:00:00.000000000 Z
11
+ date: 2018-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -584,6 +584,7 @@ files:
584
584
  - lib/govuk_publishing_components/presenters/highlight_boxes_helper.rb
585
585
  - lib/govuk_publishing_components/presenters/image_card_helper.rb
586
586
  - lib/govuk_publishing_components/presenters/machine_readable/article_schema.rb
587
+ - lib/govuk_publishing_components/presenters/machine_readable/has_part_schema.rb
587
588
  - lib/govuk_publishing_components/presenters/machine_readable/how_to_schema.rb
588
589
  - lib/govuk_publishing_components/presenters/machine_readable/news_article_schema.rb
589
590
  - lib/govuk_publishing_components/presenters/machine_readable/organisation_schema.rb