govuk_publishing_components 7.2.0 → 7.3.0
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/_document_list.html.erb +3 -3
- data/app/views/govuk_publishing_components/components/docs/input.yml +2 -2
- data/app/views/govuk_publishing_components/components/docs/meta_tags.yml +10 -0
- data/lib/govuk_publishing_components.rb +1 -1
- data/lib/govuk_publishing_components/app_helpers/brand_helper.rb +25 -0
- data/lib/govuk_publishing_components/presenters/meta_tags.rb +15 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +3 -3
- data/lib/govuk_publishing_components/presenters/brand_helper.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 718e4d3d0e9959be0f7d0270202b9af68951b66b1a75263232a3cff12dab9ec4
|
4
|
+
data.tar.gz: c6c6c04682ea600c4ad69bc6dc1c494046efea44c2e3b3bf87c01d65dbf5d396
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49462b2130f34c4172dc6680b4f1216f44fe5a973e639d573d61a39b712d899571f9a50b69000a37666fb6d7b696cf131833d97c1f731d9e71b63e11cb7ccae6
|
7
|
+
data.tar.gz: a1d8b39fbb2216b2c04d7cdea21d84bf9f5d23f93e63f4f22bdc16ccd0050955f900a2557d17eda0049115af4f8fa440bbf633133eb3e0e2aa235e558234c723
|
@@ -4,10 +4,10 @@
|
|
4
4
|
margin_bottom_class = " gem-c-document-list--bottom-margin" if local_assigns[:margin_bottom]
|
5
5
|
|
6
6
|
brand ||= false
|
7
|
-
brand_helper = GovukPublishingComponents::
|
7
|
+
brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
|
8
8
|
%>
|
9
9
|
<% if items.any? %>
|
10
|
-
<ol class="gem-c-document-list<%= margin_bottom_class %><%= margin_top_class %> <%= brand_helper.
|
10
|
+
<ol class="gem-c-document-list<%= margin_bottom_class %><%= margin_top_class %> <%= brand_helper.brand_class %>">
|
11
11
|
<% items.each do |item| %>
|
12
12
|
<li class="gem-c-document-list__item">
|
13
13
|
<h3 class="gem-c-document-list__item-title">
|
@@ -16,7 +16,7 @@
|
|
16
16
|
item[:link][:text],
|
17
17
|
item[:link][:path],
|
18
18
|
data: item[:link][:data_attributes],
|
19
|
-
class: brand_helper.
|
19
|
+
class: brand_helper.color_class
|
20
20
|
)
|
21
21
|
%>
|
22
22
|
</h3>
|
@@ -32,12 +32,12 @@ examples:
|
|
32
32
|
description: |
|
33
33
|
Allows the addition of an aria-describedby attribute. Note that this will be overridden in the event of an error, where the error will be used for the describedby attribute value.
|
34
34
|
|
35
|
-
The example below uses the ID of the
|
35
|
+
The example below uses the ID of the main container for demonstration purposes as there aren't any useful elements with IDs in the component guide. In real use this would be passed the ID of an element that correctly described the input.
|
36
36
|
data:
|
37
37
|
label:
|
38
38
|
text: "This might not work"
|
39
39
|
name: "labelledby"
|
40
|
-
describedby: "
|
40
|
+
describedby: "wrapper"
|
41
41
|
with_error:
|
42
42
|
data:
|
43
43
|
label:
|
@@ -23,3 +23,13 @@ examples:
|
|
23
23
|
links:
|
24
24
|
world_locations:
|
25
25
|
- analytics_identifier: WL3
|
26
|
+
with_default_canonical_path:
|
27
|
+
data:
|
28
|
+
content_item:
|
29
|
+
base_path: /test
|
30
|
+
canonical_path: true
|
31
|
+
with_overridden_canonical_path:
|
32
|
+
data:
|
33
|
+
content_item:
|
34
|
+
base_path: /test
|
35
|
+
canonical_path: /this-is-a-test-path
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require "govuk_publishing_components/config"
|
2
2
|
require "govuk_publishing_components/engine"
|
3
|
-
require "govuk_publishing_components/presenters/brand_helper"
|
4
3
|
require "govuk_publishing_components/presenters/contextual_navigation"
|
5
4
|
require "govuk_publishing_components/presenters/related_navigation_helper"
|
6
5
|
require "govuk_publishing_components/presenters/step_by_step_nav_helper"
|
@@ -15,6 +14,7 @@ require "govuk_publishing_components/presenters/curated_taxonomy_sidebar_links"
|
|
15
14
|
require "govuk_publishing_components/presenters/content_item"
|
16
15
|
|
17
16
|
require "govuk_publishing_components/app_helpers/taxon_breadcrumbs"
|
17
|
+
require "govuk_publishing_components/app_helpers/brand_helper"
|
18
18
|
|
19
19
|
module GovukPublishingComponents
|
20
20
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module GovukPublishingComponents
|
2
|
+
module AppHelpers
|
3
|
+
class BrandHelper
|
4
|
+
def initialize(brand)
|
5
|
+
@brand = brand if brand
|
6
|
+
end
|
7
|
+
|
8
|
+
# Apply government organisation branding to individual components, specifically
|
9
|
+
# link colour and border colour
|
10
|
+
# see https://github.com/alphagov/govuk_publishing_components/blob/master/docs/component_branding.md
|
11
|
+
|
12
|
+
def brand_class
|
13
|
+
"brand--#{@brand}" if @brand
|
14
|
+
end
|
15
|
+
|
16
|
+
def border_color_class
|
17
|
+
"brand__border-color" if @brand
|
18
|
+
end
|
19
|
+
|
20
|
+
def color_class
|
21
|
+
"brand__color" if @brand
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -20,6 +20,7 @@ module GovukPublishingComponents
|
|
20
20
|
meta_tags = add_political_tags(meta_tags)
|
21
21
|
meta_tags = add_taxonomy_tags(meta_tags)
|
22
22
|
meta_tags = add_step_by_step_tags(meta_tags)
|
23
|
+
meta_tags = add_canonical_tag(meta_tags)
|
23
24
|
meta_tags
|
24
25
|
end
|
25
26
|
|
@@ -106,6 +107,20 @@ module GovukPublishingComponents
|
|
106
107
|
meta_tags
|
107
108
|
end
|
108
109
|
|
110
|
+
def add_canonical_tag(meta_tags)
|
111
|
+
if local_assigns.key?(:canonical_path)
|
112
|
+
canonical_path = if local_assigns[:canonical_path] == true
|
113
|
+
content_item[:base_path]
|
114
|
+
else
|
115
|
+
local_assigns[:canonical_path]
|
116
|
+
end
|
117
|
+
|
118
|
+
meta_tags["canonical"] = Plek.new.website_root + canonical_path
|
119
|
+
end
|
120
|
+
|
121
|
+
meta_tags
|
122
|
+
end
|
123
|
+
|
109
124
|
def has_content_history?
|
110
125
|
(content_item[:public_updated_at] && details[:first_public_at] && content_item[:public_updated_at] != details[:first_public_at]) ||
|
111
126
|
(details[:change_history] && details[:change_history].size > 1)
|
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: 7.
|
4
|
+
version: 7.3.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-05-
|
11
|
+
date: 2018-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_app_config
|
@@ -425,11 +425,11 @@ files:
|
|
425
425
|
- lib/generators/govuk_publishing_components/templates/_component.scss
|
426
426
|
- lib/generators/govuk_publishing_components/templates/component.yml.erb
|
427
427
|
- lib/govuk_publishing_components.rb
|
428
|
+
- lib/govuk_publishing_components/app_helpers/brand_helper.rb
|
428
429
|
- lib/govuk_publishing_components/app_helpers/taxon_breadcrumbs.rb
|
429
430
|
- lib/govuk_publishing_components/config.rb
|
430
431
|
- lib/govuk_publishing_components/engine.rb
|
431
432
|
- lib/govuk_publishing_components/minitest/component_guide_test.rb
|
432
|
-
- lib/govuk_publishing_components/presenters/brand_helper.rb
|
433
433
|
- lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_parent.rb
|
434
434
|
- lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons.rb
|
435
435
|
- lib/govuk_publishing_components/presenters/content_item.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module GovukPublishingComponents
|
2
|
-
module Presenters
|
3
|
-
class BrandHelper
|
4
|
-
def initialize(brand)
|
5
|
-
@brand = brand if brand
|
6
|
-
end
|
7
|
-
|
8
|
-
def get_brand
|
9
|
-
"brand--#{@brand}" if @brand
|
10
|
-
end
|
11
|
-
|
12
|
-
def get_brand_element(attribute)
|
13
|
-
"brand__#{attribute}" if @brand
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|