govuk_publishing_components 9.26.0 → 9.26.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/govuk_publishing_components/components/docs/contextual_sidebar.yml +2 -2
- data/app/views/govuk_publishing_components/components/docs/machine_readable_metadata.yml +14 -0
- data/app/views/govuk_publishing_components/components/docs/taxonomy_navigation.yml +1 -1
- data/lib/govuk_publishing_components.rb +0 -1
- data/lib/govuk_publishing_components/presenters/machine_readable/organisation_schema.rb +33 -0
- data/lib/govuk_publishing_components/presenters/taxonomy_navigation.rb +1 -15
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +1 -2
- data/lib/govuk_publishing_components/presenters/rummager_taxonomy_sidebar_links.rb +0 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eb88659bbccc009aa73c9269e763c77991316574a3dcd97f19fce6bf628cfc7
|
4
|
+
data.tar.gz: da410f0890205197ce0b74334f4f42c120e844ec1742bd26595ca492ce40ca94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 466e5fb908c79e4f2ed4ee376e1f4ed07ac645c9f34e4036bb96d88c94e8affff78d69649ac89b46888dccca87f8ae23882bea91184f231342f174fe16e5185a
|
7
|
+
data.tar.gz: ab9e76586ba05a5916e09e18a13d71a86d88ac07343c500c93e27cbe903904b6c231b84323461b1e16994f4e2c6709c5c773fc971c0d3e39a3d5a4c0a1956e3f
|
@@ -11,12 +11,12 @@ body: |
|
|
11
11
|
- Mainstream, which uses related links in the [related navigation component][related_navigation]
|
12
12
|
- Related navigation, which uses legacy taxonomies in the [related navigation component][related_navigation]
|
13
13
|
|
14
|
-
It must always used [
|
14
|
+
It must always be used [with the contextual breadcrumbs component][contextual_breadcrumbs].
|
15
15
|
|
16
16
|
[preview]: https://govuk-publishing-components.herokuapp.com/contextual-navigation
|
17
17
|
[step-by-step]: /component-guide/step_by_step_nav
|
18
18
|
[related_navigation]: /component-guide/related_navigation
|
19
|
-
[taxonomy-sidebar]: https://govuk-publishing-components.herokuapp.com/component-guide/
|
19
|
+
[taxonomy-sidebar]: https://govuk-publishing-components.herokuapp.com/component-guide/taxonomy_navigation
|
20
20
|
[contextual_breadcrumbs]: /component-guide/contextual_breadcrumbs
|
21
21
|
accessibility_criteria: |
|
22
22
|
Components called by this component must be accessible
|
@@ -54,3 +54,17 @@ examples:
|
|
54
54
|
base_path: "/foo"
|
55
55
|
details: {}
|
56
56
|
schema: :organisation
|
57
|
+
organisation_schema_with_related_orgs:
|
58
|
+
data:
|
59
|
+
content_item:
|
60
|
+
title: "Magical Artefacts Agency"
|
61
|
+
base_path: "/foo"
|
62
|
+
details: {}
|
63
|
+
links:
|
64
|
+
ordered_parent_organisations:
|
65
|
+
- title: "Ministry of Magic"
|
66
|
+
base_path: "/ministry-of-magic"
|
67
|
+
ordered_child_organisations:
|
68
|
+
- title: "Dodgy Wands Commission"
|
69
|
+
base_path: "/dodgy-wands-commission"
|
70
|
+
schema: :organisation
|
@@ -92,7 +92,7 @@ examples:
|
|
92
92
|
path: "/world/argentina/news"
|
93
93
|
no_children:
|
94
94
|
description: |
|
95
|
-
|
95
|
+
Shows a sidebar with a taxon link but without any child content links.
|
96
96
|
data:
|
97
97
|
items:
|
98
98
|
- title: "School curriculum"
|
@@ -11,7 +11,6 @@ require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_tax
|
|
11
11
|
require "govuk_publishing_components/presenters/services"
|
12
12
|
require "govuk_publishing_components/presenters/meta_tags"
|
13
13
|
require "govuk_publishing_components/presenters/taxonomy_navigation"
|
14
|
-
require "govuk_publishing_components/presenters/rummager_taxonomy_sidebar_links"
|
15
14
|
require "govuk_publishing_components/presenters/curated_taxonomy_sidebar_links"
|
16
15
|
require "govuk_publishing_components/presenters/content_item"
|
17
16
|
require "govuk_publishing_components/presenters/translation_nav_helper"
|
@@ -18,6 +18,39 @@ module GovukPublishingComponents
|
|
18
18
|
},
|
19
19
|
"name" => page.title,
|
20
20
|
"description" => page.body
|
21
|
+
}.merge(parent_organisations).merge(sub_organisations)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def parent_organisations
|
27
|
+
related_organisations("ordered_parent_organisations", "parentOrganization")
|
28
|
+
end
|
29
|
+
|
30
|
+
def sub_organisations
|
31
|
+
related_organisations("ordered_child_organisations", "subOrganization")
|
32
|
+
end
|
33
|
+
|
34
|
+
def related_organisations(link_type, schema_name)
|
35
|
+
organisations = page.content_item.dig("links", link_type)
|
36
|
+
|
37
|
+
return {} unless organisations.present?
|
38
|
+
|
39
|
+
related_orgs = organisations.map do |org|
|
40
|
+
page = Page.new(content_item: org)
|
41
|
+
linked_org(page.canonical_url)
|
42
|
+
end
|
43
|
+
|
44
|
+
{
|
45
|
+
schema_name => related_orgs
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def linked_org(url)
|
50
|
+
{
|
51
|
+
"@context" => "http://schema.org",
|
52
|
+
"@type" => "GovernmentOrganization",
|
53
|
+
"sameAs" => url
|
21
54
|
}
|
22
55
|
end
|
23
56
|
end
|
@@ -29,22 +29,8 @@ module GovukPublishingComponents
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def there_are_related_item_overrides?
|
33
|
-
# TODO: We should check for any external links when we have "new"
|
34
|
-
# external links being curated in Content Tagger
|
35
|
-
@content_item.curated_taxonomy_sidebar_links.any?
|
36
|
-
end
|
37
|
-
|
38
32
|
def related_items
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
def related_items_factory
|
43
|
-
if there_are_related_item_overrides?
|
44
|
-
CuratedTaxonomySidebarLinks
|
45
|
-
else
|
46
|
-
RummagerTaxonomySidebarLinks
|
47
|
-
end
|
33
|
+
CuratedTaxonomySidebarLinks.new(@content_item).related_items
|
48
34
|
end
|
49
35
|
|
50
36
|
def collections
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_publishing_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.26.
|
4
|
+
version: 9.26.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
@@ -598,7 +598,6 @@ files:
|
|
598
598
|
- lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
|
599
599
|
- lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb
|
600
600
|
- lib/govuk_publishing_components/presenters/related_navigation_helper.rb
|
601
|
-
- lib/govuk_publishing_components/presenters/rummager_taxonomy_sidebar_links.rb
|
602
601
|
- lib/govuk_publishing_components/presenters/schema_org.rb
|
603
602
|
- lib/govuk_publishing_components/presenters/services.rb
|
604
603
|
- lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'govuk_app_config'
|
2
|
-
|
3
|
-
module GovukPublishingComponents
|
4
|
-
module Presenters
|
5
|
-
# @private
|
6
|
-
class RummagerTaxonomySidebarLinks
|
7
|
-
def initialize(content_item)
|
8
|
-
@content_item = content_item
|
9
|
-
end
|
10
|
-
|
11
|
-
def related_items
|
12
|
-
parent_taxons = @content_item.parent_taxons
|
13
|
-
used_related_links = Set.new
|
14
|
-
|
15
|
-
parent_taxons.each_with_index.map do |parent_taxon, index|
|
16
|
-
related_content = index < 2 ? content_related_to(parent_taxon, used_related_links) : []
|
17
|
-
|
18
|
-
used_related_links.merge(
|
19
|
-
related_content.map { |content| content[:link] }
|
20
|
-
)
|
21
|
-
|
22
|
-
{
|
23
|
-
title: parent_taxon.title,
|
24
|
-
url: parent_taxon.base_path,
|
25
|
-
description: parent_taxon.description,
|
26
|
-
related_content: related_content,
|
27
|
-
}
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
# This method will fetch content related to content_item, and tagged to taxon. This is a
|
34
|
-
# temporary method that uses search to achieve this. This behaviour is to be moved into
|
35
|
-
# the content store
|
36
|
-
def content_related_to(taxon, used_related_links)
|
37
|
-
GovukStatsd.time(:taxonomy_sidebar_search_time) do
|
38
|
-
begin
|
39
|
-
results = Services.rummager.search(
|
40
|
-
similar_to: @content_item.base_path,
|
41
|
-
start: 0,
|
42
|
-
count: 3,
|
43
|
-
filter_taxons: [taxon.content_id],
|
44
|
-
filter_navigation_document_supertype: 'guidance',
|
45
|
-
reject_link: used_related_links.to_a,
|
46
|
-
fields: %w[title link],
|
47
|
-
)['results']
|
48
|
-
|
49
|
-
GovukStatsd.increment(:taxonomy_sidebar_searches)
|
50
|
-
|
51
|
-
results
|
52
|
-
.map { |result| { title: result['title'], link: result['link'], } }
|
53
|
-
.sort_by { |result| result[:title] }
|
54
|
-
rescue StandardError => e
|
55
|
-
GovukError.notify(e)
|
56
|
-
[]
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|