govuk_publishing_components 21.60.1 → 21.60.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/_radio.scss +1 -1
- data/app/models/govuk_publishing_components/audit_applications.rb +35 -23
- data/app/models/govuk_publishing_components/audit_comparer.rb +13 -0
- data/app/views/govuk_publishing_components/audit/show.html.erb +32 -3
- data/app/views/govuk_publishing_components/components/_image_card.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/docs/image_card.yml +13 -1
- data/lib/govuk_publishing_components/presenters/image_card_helper.rb +2 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98fa4203e2dd5c9bbcc5ecfc9b64d18612a1434167c1ece8b4203ade58c0c45a
|
4
|
+
data.tar.gz: f24e38e566e25ad2dc6c5d6fb954cf91cc7f43a9b6f46fabd0a08b184d69bb21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c9342c8d542a1a703f5700ffa6fa87d0fa253641a45d549176b8f6d0b4b6a8cefb73602cc4351afdd3ce35f307380a599e95fd1df2c14301acc55c9542f5987
|
7
|
+
data.tar.gz: 1179277ccaaa0b9758c4f0dfe723472a852525a2dbd9607f2a6d52033307232f53383e17812237975a0df232cd0e3c04ea31363ae1f85c5e6b81938579932006
|
@@ -3,37 +3,39 @@ module GovukPublishingComponents
|
|
3
3
|
attr_reader :data
|
4
4
|
|
5
5
|
def initialize(path, name)
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
@path = path
|
7
|
+
application_found = application_exists(path)
|
8
|
+
components_found = []
|
9
|
+
@gem_style_references = []
|
9
10
|
|
10
|
-
|
11
|
+
if application_found
|
12
|
+
templates = Dir["#{path}/app/views/**/*.erb"]
|
13
|
+
stylesheets = Dir["#{path}/app/assets/stylesheets/**/*.scss"]
|
14
|
+
javascripts = Dir["#{path}/app/assets/javascripts/**/*.js"]
|
11
15
|
|
12
|
-
|
13
|
-
find_stylesheets = /(?<=@import ["']{1}govuk_publishing_components\/components\/)(?!print\/)+[a-zA-Z_-]+(?=['"])/
|
16
|
+
find_components = /(?<=govuk_publishing_components\/components\/)[\/a-zA-Z_-]+(?=['"])/
|
14
17
|
|
15
|
-
|
16
|
-
|
18
|
+
@find_all_stylesheets = /@import ["']{1}govuk_publishing_components\/all_components/
|
19
|
+
find_stylesheets = /(?<=@import ["']{1}govuk_publishing_components\/components\/)(?!print\/)+[a-zA-Z_-]+(?=['"])/
|
17
20
|
|
18
|
-
|
19
|
-
|
21
|
+
@find_all_print_stylesheets = /@import ["']{1}govuk_publishing_components\/all_components_print/
|
22
|
+
find_print_stylesheets = /(?<=@import ["']{1}govuk_publishing_components\/components\/print\/)[a-zA-Z_-]+(?=['"])/
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
components_in_print_stylesheets = find_components(stylesheets, find_print_stylesheets, "print_stylesheets") || []
|
24
|
-
components_in_javascripts = find_components(javascripts, find_javascripts, "javascripts") || []
|
24
|
+
@find_all_javascripts = /\/\/[ ]*= require govuk_publishing_components\/all_components/
|
25
|
+
find_javascripts = /(?<=require govuk_publishing_components\/components\/)[a-zA-Z_-]+/
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
-
components_in_ruby = components_in_ruby.flatten.uniq
|
27
|
+
components_in_templates = find_components(templates, find_components, "templates") || []
|
28
|
+
components_in_stylesheets = find_components(stylesheets, find_stylesheets, "stylesheets") || []
|
29
|
+
components_in_print_stylesheets = find_components(stylesheets, find_print_stylesheets, "print_stylesheets") || []
|
30
|
+
components_in_javascripts = find_components(javascripts, find_javascripts, "javascripts") || []
|
32
31
|
|
33
|
-
|
34
|
-
|
32
|
+
ruby_paths = %w[/app/helpers/ /app/presenters/ /lib/]
|
33
|
+
components_in_ruby = []
|
34
|
+
ruby_paths.each do |ruby_path|
|
35
|
+
components_in_ruby << find_components(Dir["#{path}#{ruby_path}**/*.{rb,erb}"], find_components, "ruby") || []
|
36
|
+
end
|
37
|
+
components_in_ruby = components_in_ruby.flatten.uniq
|
35
38
|
|
36
|
-
if application_found
|
37
39
|
components_found = [
|
38
40
|
{
|
39
41
|
location: "templates",
|
@@ -62,6 +64,7 @@ module GovukPublishingComponents
|
|
62
64
|
name: name,
|
63
65
|
application_found: application_found,
|
64
66
|
components_found: components_found,
|
67
|
+
gem_style_references: @gem_style_references.flatten.uniq.sort,
|
65
68
|
}
|
66
69
|
end
|
67
70
|
|
@@ -73,6 +76,8 @@ module GovukPublishingComponents
|
|
73
76
|
files.each do |file|
|
74
77
|
src = File.read(file)
|
75
78
|
components_found << find_match(find, src, type)
|
79
|
+
gem_references = find_gem_references(file, src)
|
80
|
+
@gem_style_references << gem_references if gem_references
|
76
81
|
rescue StandardError
|
77
82
|
puts "File #{file} not found"
|
78
83
|
end
|
@@ -94,6 +99,13 @@ module GovukPublishingComponents
|
|
94
99
|
all_matches
|
95
100
|
end
|
96
101
|
|
102
|
+
def find_gem_references(file, src)
|
103
|
+
find_gem_classes = /gem-c-[-_a-zA-Z]+/
|
104
|
+
clean_file_path = /(?<=#{Regexp.escape(@path)}\/)[\/a-zA-Z_-]+.[a-zA-Z.]+/
|
105
|
+
|
106
|
+
return file[clean_file_path] if find_gem_classes.match?(src)
|
107
|
+
end
|
108
|
+
|
97
109
|
def clean_file_name(name)
|
98
110
|
name.tr("_-", " ").strip
|
99
111
|
end
|
@@ -36,6 +36,7 @@ module GovukPublishingComponents
|
|
36
36
|
warnings = []
|
37
37
|
warnings << warn_about_missing_components(result[:components_found])
|
38
38
|
warnings << warn_about_missing_assets(result[:components_found])
|
39
|
+
warnings << warn_about_style_overrides(result[:gem_style_references])
|
39
40
|
warnings = warnings.flatten
|
40
41
|
|
41
42
|
data << {
|
@@ -65,6 +66,7 @@ module GovukPublishingComponents
|
|
65
66
|
],
|
66
67
|
warnings: warnings,
|
67
68
|
warning_count: warnings.length,
|
69
|
+
gem_style_references: result[:gem_style_references],
|
68
70
|
}
|
69
71
|
else
|
70
72
|
data << {
|
@@ -150,6 +152,17 @@ module GovukPublishingComponents
|
|
150
152
|
!@gem_data[:component_code].include?(component) unless component == "all"
|
151
153
|
end
|
152
154
|
|
155
|
+
def warn_about_style_overrides(results)
|
156
|
+
warnings = []
|
157
|
+
|
158
|
+
results.each do |result|
|
159
|
+
warnings << create_warning("Possible component style override", result) if result.include? ".scss"
|
160
|
+
warnings << create_warning("Possible hard coded component markup", result) if [".html", ".rb"].any? { |needle| result.include? needle }
|
161
|
+
end
|
162
|
+
|
163
|
+
warnings
|
164
|
+
end
|
165
|
+
|
153
166
|
def find_missing(needle, haystack)
|
154
167
|
(haystack - needle).flatten.sort
|
155
168
|
end
|
@@ -20,7 +20,11 @@
|
|
20
20
|
</li>
|
21
21
|
</ul>
|
22
22
|
<div class="govuk-tabs__panel" id="applications">
|
23
|
-
|
23
|
+
<%= render "govuk_publishing_components/components/heading", {
|
24
|
+
text: "Applications",
|
25
|
+
font_size: "l",
|
26
|
+
margin_bottom: 6
|
27
|
+
} %>
|
24
28
|
|
25
29
|
<% if @applications.any? %>
|
26
30
|
<details class="govuk-details" data-module="govuk-details">
|
@@ -66,7 +70,12 @@
|
|
66
70
|
</p>
|
67
71
|
<% end %>
|
68
72
|
|
69
|
-
|
73
|
+
<%= render "govuk_publishing_components/components/heading", {
|
74
|
+
text: "Components used",
|
75
|
+
font_size: "m",
|
76
|
+
margin_bottom: 4,
|
77
|
+
heading_level: 3,
|
78
|
+
} %>
|
70
79
|
|
71
80
|
<dl class="govuk-summary-list">
|
72
81
|
<% application[:summary].each do |item| %>
|
@@ -84,6 +93,22 @@
|
|
84
93
|
</div>
|
85
94
|
<% end %>
|
86
95
|
</dl>
|
96
|
+
|
97
|
+
<% if application[:gem_style_references].any? %>
|
98
|
+
<%= render "govuk_publishing_components/components/heading", {
|
99
|
+
text: "Component references",
|
100
|
+
font_size: "m",
|
101
|
+
margin_bottom: 4,
|
102
|
+
heading_level: 3,
|
103
|
+
} %>
|
104
|
+
|
105
|
+
<p class="govuk-body">This shows instances of `gem-c-` classes found in the application. If a reference is found in a stylesheet or in code a warning is created, as this could be a style override or hard coded component markup.</p>
|
106
|
+
<ul class="govuk-list govuk-list--bullet">
|
107
|
+
<% application[:gem_style_references].each do |ref| %>
|
108
|
+
<li><%= ref %></li>
|
109
|
+
<% end %>
|
110
|
+
</ul>
|
111
|
+
<% end %>
|
87
112
|
<% else %>
|
88
113
|
<p class="govuk-body">This application was not found. This could be because you do not have this repository checked out locally.</p>
|
89
114
|
<% end %>
|
@@ -97,7 +122,11 @@
|
|
97
122
|
</div>
|
98
123
|
|
99
124
|
<div class="govuk-tabs__panel govuk-tabs__panel--hidden" id="components-gem">
|
100
|
-
|
125
|
+
<%= render "govuk_publishing_components/components/heading", {
|
126
|
+
text: "Components",
|
127
|
+
font_size: "l",
|
128
|
+
margin_bottom: 6,
|
129
|
+
} %>
|
101
130
|
|
102
131
|
<% if @components.any? %>
|
103
132
|
<div class="govuk-accordion" data-module="govuk-accordion" id="accordion-default">
|
@@ -7,7 +7,7 @@
|
|
7
7
|
<% if card_helper.href || card_helper.extra_links.any? %>
|
8
8
|
<div class="gem-c-image-card <%= "gem-c-image-card--large" if card_helper.large %> <%= brand_helper.brand_class %>"
|
9
9
|
<%= "data-module=track-click" if card_helper.is_tracking? %>
|
10
|
-
|
10
|
+
<%= "lang=#{card_helper.lang}" if card_helper.lang %>>
|
11
11
|
<%= card_helper.image %>
|
12
12
|
|
13
13
|
<div class="gem-c-image-card__text-wrapper">
|
@@ -9,6 +9,7 @@ accessibility_criteria: |
|
|
9
9
|
|
10
10
|
- include alt text for images when present
|
11
11
|
- not have duplicate links for the image and the text
|
12
|
+
- if the contents of the component are in a different language than the rest of the document, include an appropriate `lang` attribute to correctly identify the language used in the component
|
12
13
|
shared_accessibility_criteria:
|
13
14
|
- link
|
14
15
|
examples:
|
@@ -191,7 +192,7 @@ examples:
|
|
191
192
|
description: Can be used for links to people pages to indicate payment type
|
192
193
|
data:
|
193
194
|
href: "/government/people/"
|
194
|
-
image_src: "
|
195
|
+
image_src: "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/62756/s300_courts-of-justice.JPG"
|
195
196
|
image_alt: "some meaningful alt text please"
|
196
197
|
context:
|
197
198
|
text: "The Rt Hon"
|
@@ -204,3 +205,14 @@ examples:
|
|
204
205
|
}
|
205
206
|
]
|
206
207
|
extra_links_no_indent: true
|
208
|
+
with_lang:
|
209
|
+
description: |
|
210
|
+
Pass through an appropriate `lang` to set a HTML lang attribute for the component.
|
211
|
+
|
212
|
+
The `lang` attribute **must** be set to a [valid BCP47 string](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang#Language_tag_syntax). A valid code can be the two or three letter language code - for example, English is `en` or `eng`, Korean is `ko` or `kor` - but if in doubt please check.
|
213
|
+
data:
|
214
|
+
href: "/not-a-page"
|
215
|
+
image_src: "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/62756/s300_courts-of-justice.JPG"
|
216
|
+
image_alt: "some meaningful alt text please"
|
217
|
+
heading_text: Yr hyn rydym ni'n ei wneud
|
218
|
+
lang: cy
|
@@ -4,7 +4,7 @@ module GovukPublishingComponents
|
|
4
4
|
include ActionView::Helpers
|
5
5
|
include ActionView::Context
|
6
6
|
|
7
|
-
attr_reader :href, :href_data_attributes, :extra_links, :large, :extra_links_no_indent, :heading_text, :metadata
|
7
|
+
attr_reader :href, :href_data_attributes, :extra_links, :large, :extra_links_no_indent, :heading_text, :metadata, :lang
|
8
8
|
|
9
9
|
def initialize(local_assigns)
|
10
10
|
@href = local_assigns[:href]
|
@@ -18,6 +18,7 @@ module GovukPublishingComponents
|
|
18
18
|
@heading_text = local_assigns[:heading_text]
|
19
19
|
@extra_links_no_indent = local_assigns[:extra_links_no_indent]
|
20
20
|
@metadata = local_assigns[:metadata]
|
21
|
+
@lang = local_assigns[:lang]
|
21
22
|
end
|
22
23
|
|
23
24
|
def is_tracking?
|
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: 21.60.
|
4
|
+
version: 21.60.2
|
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: 2020-
|
11
|
+
date: 2020-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_app_config
|