govuk_publishing_components 21.59.0 → 21.61.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -6
- data/app/assets/javascripts/component_guide/accessibility-test.js +21 -21
- data/app/assets/javascripts/component_guide/filter-components.js +19 -19
- data/app/assets/javascripts/component_guide/visual-regression.js +38 -37
- data/app/assets/javascripts/govuk_publishing_components/components/checkboxes.js +102 -73
- data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +4 -4
- data/app/assets/javascripts/govuk_publishing_components/ie.js +2 -0
- data/app/assets/javascripts/govuk_publishing_components/lib/auto-track-event.js +31 -0
- data/app/assets/javascripts/govuk_publishing_components/lib/cookie-functions.js +24 -24
- data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js +17 -17
- data/app/assets/javascripts/govuk_publishing_components/vendor/html5shiv-printshiv.js +4 -0
- data/app/assets/javascripts/govuk_publishing_components/vendor/json2.js +487 -0
- data/app/assets/stylesheets/component_guide/application.scss +19 -15
- data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +0 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/_breadcrumbs.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_checkboxes.scss +4 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +1 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss +0 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_govspeak-html-publication.scss +4 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_heading.scss +3 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_inverse-header.scss +5 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-footer.scss +8 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-for-public.scss +4 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-header.scss +87 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_radio.scss +4 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_related-navigation.scss +2 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +46 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-header.scss +0 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-related.scss +1 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +8 -12
- data/app/assets/stylesheets/govuk_publishing_components/components/_table.scss +21 -24
- data/app/assets/stylesheets/govuk_publishing_components/components/_tabs.scss +4 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_attachment.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_button.scss +1 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_charts.scss +6 -6
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_contact.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_footnotes.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_highlight-answer.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_place.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_typography.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_govspeak.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav-header.scss +0 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav.scss +2 -10
- data/app/controllers/govuk_publishing_components/audit_controller.rb +2 -2
- data/app/controllers/govuk_publishing_components/component_guide_controller.rb +2 -2
- data/app/models/govuk_publishing_components/audit_applications.rb +45 -27
- data/app/models/govuk_publishing_components/audit_comparer.rb +77 -51
- data/app/models/govuk_publishing_components/audit_components.rb +25 -6
- data/app/models/govuk_publishing_components/component_example.rb +4 -0
- data/app/views/govuk_publishing_components/audit/show.html.erb +227 -190
- data/app/views/govuk_publishing_components/component_guide/component_doc/_component.html.erb +1 -0
- data/app/views/govuk_publishing_components/component_guide/index.html.erb +3 -1
- data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_image_card.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +32 -21
- data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +76 -0
- data/app/views/govuk_publishing_components/components/_layout_header.html.erb +39 -51
- data/app/views/govuk_publishing_components/components/_machine_readable_metadata.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_radio.html.erb +13 -5
- data/app/views/govuk_publishing_components/components/_search.html.erb +10 -5
- data/app/views/govuk_publishing_components/components/_share_links.html.erb +9 -9
- data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +2 -2
- data/app/views/govuk_publishing_components/components/docs/checkboxes.yml +4 -0
- data/app/views/govuk_publishing_components/components/docs/govspeak.yml +45 -0
- data/app/views/govuk_publishing_components/components/docs/heading.yml +6 -3
- data/app/views/govuk_publishing_components/components/docs/image_card.yml +13 -1
- data/app/views/govuk_publishing_components/components/docs/layout_footer.yml +17 -0
- data/app/views/govuk_publishing_components/components/docs/layout_for_admin.yml +5 -1
- data/app/views/govuk_publishing_components/components/docs/layout_for_public.yml +29 -0
- data/app/views/govuk_publishing_components/components/docs/layout_header.yml +34 -0
- data/app/views/govuk_publishing_components/components/docs/radio.yml +4 -0
- data/app/views/govuk_publishing_components/components/docs/search.yml +6 -0
- data/app/views/govuk_publishing_components/components/layout_header/_header_logo.html.erb +23 -0
- data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb +17 -0
- data/app/views/govuk_publishing_components/components/layout_header/_search.html.erb +9 -0
- data/config/initializers/assets.rb +8 -0
- data/lib/govuk_publishing_components.rb +1 -0
- data/lib/govuk_publishing_components/presenters/checkboxes_helper.rb +15 -7
- data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_priority.rb +1 -0
- data/lib/govuk_publishing_components/presenters/heading_helper.rb +21 -1
- data/lib/govuk_publishing_components/presenters/image_card_helper.rb +3 -2
- data/lib/govuk_publishing_components/presenters/public_layout_helper.rb +380 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/axe-core/package.json +145 -220
- data/node_modules/govuk-frontend/govuk/all.js +160 -57
- data/node_modules/govuk-frontend/govuk/components/character-count/_index.scss +0 -4
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +16 -8
- data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +6 -0
- data/node_modules/govuk-frontend/govuk/components/character-count/template.njk +1 -0
- data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +6 -5
- data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +68 -21
- data/node_modules/govuk-frontend/govuk/components/date-input/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +0 -27
- data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +0 -3
- data/node_modules/govuk-frontend/govuk/components/footer/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/header/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/hint/_index.scss +2 -2
- data/node_modules/govuk-frontend/govuk/components/hint/template.njk +2 -2
- data/node_modules/govuk-frontend/govuk/components/input/_index.scss +0 -3
- data/node_modules/govuk-frontend/govuk/components/input/macro-options.json +6 -0
- data/node_modules/govuk-frontend/govuk/components/input/template.njk +1 -0
- data/node_modules/govuk-frontend/govuk/components/radios/radios.js +76 -28
- data/node_modules/govuk-frontend/govuk/components/select/_index.scss +0 -3
- data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +1 -0
- data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +0 -3
- data/node_modules/govuk-frontend/govuk/components/textarea/macro-options.json +6 -0
- data/node_modules/govuk-frontend/govuk/components/textarea/template.njk +1 -0
- data/node_modules/govuk-frontend/govuk/components/warning-text/_index.scss +4 -2
- data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +1 -1
- data/node_modules/govuk-frontend/govuk/settings/_colours-applied.scss +2 -2
- data/node_modules/govuk-frontend/govuk/settings/_colours-palette.scss +33 -33
- data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +4 -1
- data/node_modules/govuk-frontend/package.json +14 -81
- data/node_modules/jquery/package.json +44 -116
- metadata +34 -66
- data/Rakefile +0 -37
@@ -83,9 +83,9 @@ module GovukPublishingComponents
|
|
83
83
|
def components_in_use
|
84
84
|
matches = []
|
85
85
|
|
86
|
-
files = Dir["#{@application_path}/app/views/**/*.
|
86
|
+
files = Dir["#{@application_path}/app/views/**/*.erb"]
|
87
87
|
files.concat Dir["#{@application_path}/app/**/*.rb"]
|
88
|
-
files.concat Dir["#{@application_path}/lib/**/*.rb"]
|
88
|
+
files.concat Dir["#{@application_path}/lib/**/*.{rb,erb}"]
|
89
89
|
|
90
90
|
files.each do |file|
|
91
91
|
data = File.read(file)
|
@@ -3,40 +3,40 @@ module GovukPublishingComponents
|
|
3
3
|
attr_reader :data
|
4
4
|
|
5
5
|
def initialize(path, name)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
find_templates = /(?<=govuk_publishing_components\/components\/)[\/a-zA-Z_-]+(?=['"])/
|
6
|
+
@path = path
|
7
|
+
application_found = application_exists(path)
|
8
|
+
components_found = []
|
9
|
+
@gem_style_references = []
|
11
10
|
|
12
|
-
|
13
|
-
|
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"]
|
14
15
|
|
15
|
-
|
16
|
-
find_print_stylesheets = /(?<=@import ["']{1}govuk_publishing_components\/components\/print\/)[a-zA-Z_-]+(?=['"])/
|
16
|
+
find_components = /(?<=govuk_publishing_components\/components\/)[\/a-zA-Z_-]+(?=['"])/
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
@find_all_stylesheets = /@import ["']{1}govuk_publishing_components\/all_components/
|
19
|
+
find_stylesheets = /(?<=@import ["']{1}govuk_publishing_components\/components\/)(?!print\/)+[a-zA-Z_-]+(?=['"])/
|
20
20
|
|
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") || []
|
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_-]+(?=['"])/
|
25
23
|
|
26
|
-
|
27
|
-
|
24
|
+
@find_all_javascripts = /\/\/[ ]*= require govuk_publishing_components\/all_components/
|
25
|
+
find_javascripts = /(?<=require govuk_publishing_components\/components\/)[a-zA-Z_-]+/
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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") || []
|
33
31
|
|
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
|
-
|
37
|
-
name: name,
|
38
|
-
application_found: application_exists(path),
|
39
|
-
components_found: [
|
39
|
+
components_found = [
|
40
40
|
{
|
41
41
|
location: "templates",
|
42
42
|
components: components_in_templates,
|
@@ -57,7 +57,14 @@ module GovukPublishingComponents
|
|
57
57
|
location: "ruby",
|
58
58
|
components: components_in_ruby,
|
59
59
|
},
|
60
|
-
]
|
60
|
+
]
|
61
|
+
end
|
62
|
+
|
63
|
+
@data = {
|
64
|
+
name: name,
|
65
|
+
application_found: application_found,
|
66
|
+
components_found: components_found,
|
67
|
+
gem_style_references: @gem_style_references.flatten.uniq.sort,
|
61
68
|
}
|
62
69
|
end
|
63
70
|
|
@@ -69,6 +76,10 @@ module GovukPublishingComponents
|
|
69
76
|
files.each do |file|
|
70
77
|
src = File.read(file)
|
71
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
|
81
|
+
rescue StandardError
|
82
|
+
puts "File #{file} not found"
|
72
83
|
end
|
73
84
|
|
74
85
|
components_found.flatten.uniq.sort
|
@@ -88,6 +99,13 @@ module GovukPublishingComponents
|
|
88
99
|
all_matches
|
89
100
|
end
|
90
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
|
+
|
91
109
|
def clean_file_name(name)
|
92
110
|
name.tr("_-", " ").strip
|
93
111
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
module GovukPublishingComponents
|
2
2
|
class AuditComparer
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :applications_data, :gem_data
|
4
4
|
|
5
5
|
def initialize(gem_data, results)
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
if gem_data[:gem_found]
|
7
|
+
@gem_data = gem_data
|
8
|
+
@applications_data = sort_results(results)
|
9
|
+
@gem_data[:components_by_application] = get_components_by_application || []
|
10
|
+
end
|
9
11
|
end
|
10
12
|
|
11
13
|
private
|
@@ -18,51 +20,60 @@ module GovukPublishingComponents
|
|
18
20
|
data = []
|
19
21
|
|
20
22
|
results.each do |result|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
23
|
+
if result[:application_found]
|
24
|
+
templates = result[:components_found].find { |c| c[:location] == "templates" }
|
25
|
+
stylesheets = result[:components_found].find { |c| c[:location] == "stylesheets" }
|
26
|
+
print_stylesheets = result[:components_found].find { |c| c[:location] == "print_stylesheets" }
|
27
|
+
javascripts = result[:components_found].find { |c| c[:location] == "javascripts" }
|
28
|
+
ruby = result[:components_found].find { |c| c[:location] == "ruby" }
|
29
|
+
|
30
|
+
@all_stylesheets = true if stylesheets[:components].include?("all")
|
31
|
+
@all_print_stylesheets = true if print_stylesheets[:components].include?("all")
|
32
|
+
@all_javascripts = true if javascripts[:components].include?("all")
|
33
|
+
|
34
|
+
templates[:components] = include_any_components_within_components(templates[:components])
|
35
|
+
|
36
|
+
warnings = []
|
37
|
+
warnings << warn_about_missing_components(result[:components_found])
|
38
|
+
warnings << warn_about_missing_assets(result[:components_found])
|
39
|
+
warnings << warn_about_style_overrides(result[:gem_style_references])
|
40
|
+
warnings = warnings.flatten
|
41
|
+
|
42
|
+
data << {
|
43
|
+
name: result[:name],
|
44
|
+
application_found: result[:application_found],
|
45
|
+
summary: [
|
46
|
+
{
|
47
|
+
name: "Components in templates",
|
48
|
+
value: templates[:components].flatten.uniq.sort.join(", "),
|
49
|
+
},
|
50
|
+
{
|
51
|
+
name: "Components in stylesheets",
|
52
|
+
value: stylesheets[:components].join(", "),
|
53
|
+
},
|
54
|
+
{
|
55
|
+
name: "Components in print stylesheets",
|
56
|
+
value: print_stylesheets[:components].join(", "),
|
57
|
+
},
|
58
|
+
{
|
59
|
+
name: "Components in javascripts",
|
60
|
+
value: javascripts[:components].join(", "),
|
61
|
+
},
|
62
|
+
{
|
63
|
+
name: "Components in ruby",
|
64
|
+
value: ruby[:components].join(", "),
|
65
|
+
},
|
66
|
+
],
|
67
|
+
warnings: warnings,
|
68
|
+
warning_count: warnings.length,
|
69
|
+
gem_style_references: result[:gem_style_references],
|
70
|
+
}
|
71
|
+
else
|
72
|
+
data << {
|
73
|
+
name: result[:name],
|
74
|
+
application_found: result[:application_found],
|
75
|
+
}
|
76
|
+
end
|
66
77
|
end
|
67
78
|
|
68
79
|
data
|
@@ -141,18 +152,33 @@ module GovukPublishingComponents
|
|
141
152
|
!@gem_data[:component_code].include?(component) unless component == "all"
|
142
153
|
end
|
143
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
|
+
|
144
166
|
def find_missing(needle, haystack)
|
145
167
|
(haystack - needle).flatten.sort
|
146
168
|
end
|
147
169
|
|
148
170
|
def get_components_by_application
|
149
171
|
results = []
|
172
|
+
found_something = false
|
150
173
|
|
151
174
|
@gem_data[:component_listing].each do |component|
|
152
175
|
found_in_applications = []
|
153
176
|
|
154
|
-
@
|
177
|
+
@applications_data.each do |application|
|
178
|
+
next unless application[:application_found]
|
179
|
+
|
155
180
|
name = application[:name]
|
181
|
+
found_something = true
|
156
182
|
|
157
183
|
application[:summary].each do |item|
|
158
184
|
found_in_applications << name if item[:value].include?(component[:name])
|
@@ -166,7 +192,7 @@ module GovukPublishingComponents
|
|
166
192
|
}
|
167
193
|
end
|
168
194
|
|
169
|
-
results
|
195
|
+
results if found_something
|
170
196
|
end
|
171
197
|
end
|
172
198
|
end
|
@@ -3,6 +3,15 @@ module GovukPublishingComponents
|
|
3
3
|
attr_reader :data
|
4
4
|
|
5
5
|
def initialize(path)
|
6
|
+
@data = {
|
7
|
+
gem_found: false,
|
8
|
+
}
|
9
|
+
@data = compile_data(path) if Dir.exist?(path)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def compile_data(path)
|
6
15
|
templates_path = "app/views/govuk_publishing_components/components"
|
7
16
|
stylesheets_path = "app/assets/stylesheets/govuk_publishing_components/components"
|
8
17
|
print_stylesheets_path = "app/assets/stylesheets/govuk_publishing_components/components/print"
|
@@ -10,7 +19,7 @@ module GovukPublishingComponents
|
|
10
19
|
tests_path = "spec/components"
|
11
20
|
js_tests_path = "spec/javascripts/components"
|
12
21
|
|
13
|
-
templates = Dir["#{path}/#{templates_path}/*.
|
22
|
+
templates = Dir["#{path}/#{templates_path}/*.erb"]
|
14
23
|
stylesheets = Dir["#{path}/#{stylesheets_path}/*.scss"]
|
15
24
|
print_stylesheets = Dir["#{path}/#{print_stylesheets_path}/*.scss"]
|
16
25
|
javascripts = Dir["#{path}/#{javascripts_path}/*.js"]
|
@@ -26,7 +35,8 @@ module GovukPublishingComponents
|
|
26
35
|
@component_tests = find_files(tests, [path, tests_path].join("/"))
|
27
36
|
@component_js_tests = find_files(js_tests, [path, js_tests_path].join("/"))
|
28
37
|
|
29
|
-
|
38
|
+
{
|
39
|
+
gem_found: true,
|
30
40
|
component_code: @components,
|
31
41
|
component_stylesheets: @component_stylesheets,
|
32
42
|
component_print_stylesheets: @component_print_stylesheets,
|
@@ -38,18 +48,27 @@ module GovukPublishingComponents
|
|
38
48
|
}
|
39
49
|
end
|
40
50
|
|
41
|
-
private
|
42
|
-
|
43
51
|
def find_files(files, replace)
|
44
52
|
files.map { |file| clean_file_name(file.gsub(replace, "")) }.sort
|
45
53
|
end
|
46
54
|
|
47
55
|
def clean_file_name(name)
|
48
|
-
name.tr("/_-", " ")
|
56
|
+
name.tr("/_-", " ")
|
57
|
+
.gsub(".html.erb", "")
|
58
|
+
.gsub(".erb", "")
|
59
|
+
.gsub(".scss", "")
|
60
|
+
.gsub(".js", "")
|
61
|
+
.gsub("spec", "")
|
62
|
+
.gsub(".rb", "")
|
63
|
+
.strip
|
49
64
|
end
|
50
65
|
|
51
66
|
def get_component_name_from_full_path(path)
|
52
|
-
path.gsub(
|
67
|
+
path.gsub(/.*\K\/_/, "/")
|
68
|
+
.gsub(@templates_full_path, "")
|
69
|
+
.gsub(".html.erb", "")
|
70
|
+
.gsub(".erb", "")
|
71
|
+
.tr('\"\'', "")
|
53
72
|
end
|
54
73
|
|
55
74
|
def get_component_link(component)
|
@@ -2,220 +2,257 @@
|
|
2
2
|
|
3
3
|
<%= render 'govuk_publishing_components/components/title', title: "Components audit", margin_top: 0; %>
|
4
4
|
|
5
|
-
|
6
|
-
<
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
<
|
11
|
-
<
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
<
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<
|
5
|
+
<% if ENV["MAIN_COMPONENT_GUIDE"] %>
|
6
|
+
<div class="govuk-tabs" data-module="govuk-tabs">
|
7
|
+
<h2 class="govuk-tabs__title">
|
8
|
+
Contents
|
9
|
+
</h2>
|
10
|
+
<ul class="govuk-tabs__list">
|
11
|
+
<li class="govuk-tabs__list-item govuk-tabs__list-item--selected">
|
12
|
+
<a class="govuk-tabs__tab" href="#applications">
|
13
|
+
Applications
|
14
|
+
</a>
|
15
|
+
</li>
|
16
|
+
<li class="govuk-tabs__list-item">
|
17
|
+
<a class="govuk-tabs__tab" href="#components-gem">
|
18
|
+
Components
|
19
|
+
</a>
|
20
|
+
</li>
|
21
|
+
</ul>
|
22
|
+
<div class="govuk-tabs__panel" id="applications">
|
23
|
+
<%= render "govuk_publishing_components/components/heading", {
|
24
|
+
text: "Applications",
|
25
|
+
font_size: "l",
|
26
|
+
margin_bottom: 6
|
27
|
+
} %>
|
23
28
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
<% if @applications.any? %>
|
30
|
+
<details class="govuk-details" data-module="govuk-details">
|
31
|
+
<summary class="govuk-details__summary">
|
32
|
+
<span class="govuk-details__summary-text">
|
33
|
+
How to use this information
|
34
|
+
</span>
|
35
|
+
</summary>
|
36
|
+
<div class="govuk-details__text">
|
37
|
+
<p class="govuk-body">This page shows information about component use on GOV.UK. This information has been cross referenced with the components in the gem to produce warnings where e.g. a print stylesheet for a component exists but has not been included in an application.</p>
|
38
|
+
<p class="govuk-body">Warnings should be investigated, although there may be a reason why the application has been configured as it is. Note that 'code' can refer to templates or ruby code.</p>
|
39
|
+
</div>
|
40
|
+
</details>
|
41
|
+
|
42
|
+
<div class="govuk-accordion" data-module="govuk-accordion" id="accordion-with-summary-sections">
|
43
|
+
<% @applications.each_with_index do |application, index| %>
|
44
|
+
<div class="govuk-accordion__section ">
|
45
|
+
<div class="govuk-accordion__section-header">
|
46
|
+
<h2 class="govuk-accordion__section-heading">
|
47
|
+
<span class="govuk-accordion__section-button" id="accordion-with-summary-sections-heading-<%= index %>">
|
48
|
+
<%= application[:name] %>
|
49
|
+
</span>
|
50
|
+
</h2>
|
51
|
+
<div class="govuk-accordion__section-summary govuk-body" id="accordion-with-summary-sections-summary-<%= index %>">
|
52
|
+
<% if application[:application_found] %>
|
53
|
+
Warnings:
|
54
|
+
<% if application[:warning_count] > 0 %>
|
55
|
+
<strong class="govuk-tag govuk-tag--red"><%= application[:warning_count] %></strong>
|
56
|
+
<% else %>
|
57
|
+
<%= application[:warning_count] %>
|
58
|
+
<% end %>
|
59
|
+
<% else %>
|
60
|
+
<strong class="govuk-tag govuk-tag--red">Application not found</strong>
|
61
|
+
<% end %>
|
62
|
+
</div>
|
63
|
+
</div>
|
64
|
+
<div id="accordion-with-summary-sections-content-<%= index %>" class="govuk-accordion__section-content" aria-labelledby="accordion-with-summary-sections-heading-<%= index %>">
|
65
|
+
<% if application[:application_found] %>
|
66
|
+
<% application[:warnings].each do |warning| %>
|
67
|
+
<p class="govuk-body">
|
68
|
+
<strong class="govuk-tag">Warn</strong>
|
69
|
+
<strong><%= warning[:component] %></strong> - <%= warning[:message] %>
|
70
|
+
</p>
|
71
|
+
<% end %>
|
72
|
+
|
73
|
+
<%= render "govuk_publishing_components/components/heading", {
|
74
|
+
text: "Components used",
|
75
|
+
font_size: "m",
|
76
|
+
margin_bottom: 4,
|
77
|
+
heading_level: 3,
|
78
|
+
} %>
|
79
|
+
|
80
|
+
<dl class="govuk-summary-list">
|
81
|
+
<% application[:summary].each do |item| %>
|
82
|
+
<div class="govuk-summary-list__row">
|
83
|
+
<dt class="govuk-summary-list__key">
|
84
|
+
<%= item[:name] %>
|
85
|
+
</dt>
|
86
|
+
<dd class="govuk-summary-list__value">
|
87
|
+
<% if item[:value].length > 0 %>
|
88
|
+
<%= item[:value] %>
|
89
|
+
<% else %>
|
90
|
+
None
|
91
|
+
<% end %>
|
92
|
+
</dd>
|
93
|
+
</div>
|
94
|
+
<% end %>
|
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 %>
|
112
|
+
<% else %>
|
113
|
+
<p class="govuk-body">This application was not found. This could be because you do not have this repository checked out locally.</p>
|
114
|
+
<% end %>
|
115
|
+
</div>
|
116
|
+
</div>
|
117
|
+
<% end %>
|
34
118
|
</div>
|
35
|
-
|
119
|
+
<% else %>
|
120
|
+
<p class="govuk-body">No applications found.</p>
|
121
|
+
<% end %>
|
122
|
+
</div>
|
36
123
|
|
37
|
-
|
38
|
-
|
124
|
+
<div class="govuk-tabs__panel govuk-tabs__panel--hidden" id="components-gem">
|
125
|
+
<%= render "govuk_publishing_components/components/heading", {
|
126
|
+
text: "Components",
|
127
|
+
font_size: "l",
|
128
|
+
margin_bottom: 6,
|
129
|
+
} %>
|
130
|
+
|
131
|
+
<% if @components.any? %>
|
132
|
+
<div class="govuk-accordion" data-module="govuk-accordion" id="accordion-default">
|
39
133
|
<div class="govuk-accordion__section ">
|
40
134
|
<div class="govuk-accordion__section-header">
|
41
135
|
<h2 class="govuk-accordion__section-heading">
|
42
|
-
<span class="govuk-accordion__section-button" id="accordion-
|
43
|
-
|
136
|
+
<span class="govuk-accordion__section-button" id="accordion-default-heading-1">
|
137
|
+
Component files
|
44
138
|
</span>
|
45
139
|
</h2>
|
46
|
-
<div class="govuk-accordion__section-summary govuk-body" id="accordion-with-summary-sections-summary
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
140
|
+
<div class="govuk-accordion__section-summary govuk-body" id="accordion-with-summary-sections-summary-1">
|
141
|
+
Lists what files each component has
|
142
|
+
</div>
|
143
|
+
</div>
|
144
|
+
<div id="accordion-default-content-1" class="govuk-accordion__section-content" aria-labelledby="accordion-default-heading-1">
|
145
|
+
<table class="govuk-table">
|
146
|
+
<thead class="govuk-table__head">
|
147
|
+
<tr class="govuk-table__row">
|
148
|
+
<th scope="col" class="govuk-table__header sticky-table-header">Component</th>
|
149
|
+
<th scope="col" class="govuk-table__header sticky-table-header">Stylesheet</th>
|
150
|
+
<th scope="col" class="govuk-table__header sticky-table-header">Print stylesheet</th>
|
151
|
+
<th scope="col" class="govuk-table__header sticky-table-header">JS</th>
|
152
|
+
<th scope="col" class="govuk-table__header sticky-table-header">Test</th>
|
153
|
+
<th scope="col" class="govuk-table__header sticky-table-header">JS test</th>
|
154
|
+
</tr>
|
155
|
+
</thead>
|
156
|
+
<tbody class="govuk-table__body">
|
157
|
+
<% @components[:component_listing].each do |component| %>
|
158
|
+
<tr class="govuk-table__row">
|
159
|
+
<th scope="row" class="govuk-table__header">
|
160
|
+
<a href="<%= component[:link] %>" class="govuk-link"><%= component[:name] %></a>
|
161
|
+
</th>
|
162
|
+
<td class="govuk-table__cell">
|
163
|
+
<% if component[:stylesheet] %>
|
164
|
+
<strong class="govuk-tag govuk-tag--green">Yes</strong>
|
165
|
+
<% end %>
|
166
|
+
</td>
|
167
|
+
<td class="govuk-table__cell">
|
168
|
+
<% if component[:print_stylesheet] %>
|
169
|
+
<strong class="govuk-tag govuk-tag--green">Yes</strong>
|
170
|
+
<% end %>
|
171
|
+
</td>
|
172
|
+
<td class="govuk-table__cell">
|
173
|
+
<% if component[:javascript] %>
|
174
|
+
<strong class="govuk-tag govuk-tag--green">Yes</strong>
|
175
|
+
<% end %>
|
176
|
+
</td>
|
177
|
+
<td class="govuk-table__cell">
|
178
|
+
<% if component[:tests] %>
|
179
|
+
<strong class="govuk-tag govuk-tag--green">Yes</strong>
|
180
|
+
<% end %>
|
181
|
+
</td>
|
182
|
+
<td class="govuk-table__cell">
|
183
|
+
<% if component[:js_tests] %>
|
184
|
+
<strong class="govuk-tag govuk-tag--green">Yes</strong>
|
185
|
+
<% end %>
|
186
|
+
</td>
|
187
|
+
</tr>
|
53
188
|
<% end %>
|
54
|
-
|
55
|
-
|
56
|
-
|
189
|
+
</tbody>
|
190
|
+
</table>
|
191
|
+
</div>
|
192
|
+
</div>
|
193
|
+
|
194
|
+
<div class="govuk-accordion__section ">
|
195
|
+
<div class="govuk-accordion__section-header">
|
196
|
+
<h2 class="govuk-accordion__section-heading">
|
197
|
+
<span class="govuk-accordion__section-button" id="accordion-default-heading-2">
|
198
|
+
Components containing components
|
199
|
+
</span>
|
200
|
+
</h2>
|
201
|
+
<div class="govuk-accordion__section-summary govuk-body" id="accordion-with-summary-sections-summary-2">
|
202
|
+
Shows which components contain other components
|
57
203
|
</div>
|
58
204
|
</div>
|
59
|
-
<div id="accordion-
|
60
|
-
|
61
|
-
<%
|
62
|
-
<
|
63
|
-
<
|
64
|
-
|
65
|
-
|
205
|
+
<div id="accordion-default-content-2" class="govuk-accordion__section-content" aria-labelledby="accordion-default-heading-2">
|
206
|
+
<dl class="govuk-summary-list">
|
207
|
+
<% @components[:components_containing_components].each do |component| %>
|
208
|
+
<div class="govuk-summary-list__row">
|
209
|
+
<dt class="govuk-summary-list__key">
|
210
|
+
<a href="<%= component[:link] %>" class="govuk-link"><%= component[:component] %></a>
|
211
|
+
</dt>
|
212
|
+
<dd class="govuk-summary-list__value">
|
213
|
+
<%= component[:sub_components].join(', ') %>
|
214
|
+
</dd>
|
215
|
+
</div>
|
66
216
|
<% end %>
|
67
|
-
|
68
|
-
|
69
|
-
|
217
|
+
</dl>
|
218
|
+
</div>
|
219
|
+
</div>
|
220
|
+
<div class="govuk-accordion__section ">
|
221
|
+
<div class="govuk-accordion__section-header">
|
222
|
+
<h2 class="govuk-accordion__section-heading">
|
223
|
+
<span class="govuk-accordion__section-button" id="accordion-default-heading-2">
|
224
|
+
Components by application
|
225
|
+
</span>
|
226
|
+
</h2>
|
227
|
+
<div class="govuk-accordion__section-summary govuk-body" id="accordion-with-summary-sections-summary-2">
|
228
|
+
Shows which applications use each component
|
229
|
+
</div>
|
230
|
+
</div>
|
231
|
+
<div id="accordion-default-content-2" class="govuk-accordion__section-content" aria-labelledby="accordion-default-heading-2">
|
232
|
+
<% if @components[:components_by_application].any? %>
|
70
233
|
<dl class="govuk-summary-list">
|
71
|
-
<%
|
234
|
+
<% @components[:components_by_application].each do |component| %>
|
72
235
|
<div class="govuk-summary-list__row">
|
73
236
|
<dt class="govuk-summary-list__key">
|
74
|
-
<%=
|
237
|
+
<%= component[:component] %> (<%= component[:count] %>)
|
75
238
|
</dt>
|
76
239
|
<dd class="govuk-summary-list__value">
|
77
|
-
|
78
|
-
<%= item[:value] %>
|
79
|
-
<% else %>
|
80
|
-
None
|
81
|
-
<% end %>
|
240
|
+
<%= component[:list] %>
|
82
241
|
</dd>
|
83
242
|
</div>
|
84
243
|
<% end %>
|
85
244
|
</dl>
|
86
245
|
<% else %>
|
87
|
-
<p class="govuk-body">
|
246
|
+
<p class="govuk-body">Sorry, no applications found.</p>
|
88
247
|
<% end %>
|
89
248
|
</div>
|
90
249
|
</div>
|
91
|
-
<% end %>
|
92
|
-
</div>
|
93
|
-
<% else %>
|
94
|
-
<p class="govuk-body">No applications found.</p>
|
95
|
-
<% end %>
|
96
|
-
</div>
|
97
|
-
|
98
|
-
<div class="govuk-tabs__panel govuk-tabs__panel--hidden" id="components-gem">
|
99
|
-
<h2 class="govuk-heading-l">Components</h2>
|
100
|
-
|
101
|
-
<% if @components.any? %>
|
102
|
-
<div class="govuk-accordion" data-module="govuk-accordion" id="accordion-default">
|
103
|
-
<div class="govuk-accordion__section ">
|
104
|
-
<div class="govuk-accordion__section-header">
|
105
|
-
<h2 class="govuk-accordion__section-heading">
|
106
|
-
<span class="govuk-accordion__section-button" id="accordion-default-heading-1">
|
107
|
-
Component files
|
108
|
-
</span>
|
109
|
-
</h2>
|
110
|
-
<div class="govuk-accordion__section-summary govuk-body" id="accordion-with-summary-sections-summary-1">
|
111
|
-
Lists what files each component has
|
112
|
-
</div>
|
113
|
-
</div>
|
114
|
-
<div id="accordion-default-content-1" class="govuk-accordion__section-content" aria-labelledby="accordion-default-heading-1">
|
115
|
-
<table class="govuk-table">
|
116
|
-
<thead class="govuk-table__head">
|
117
|
-
<tr class="govuk-table__row">
|
118
|
-
<th scope="col" class="govuk-table__header">Component</th>
|
119
|
-
<th scope="col" class="govuk-table__header">Stylesheet</th>
|
120
|
-
<th scope="col" class="govuk-table__header">Print stylesheet</th>
|
121
|
-
<th scope="col" class="govuk-table__header">JS</th>
|
122
|
-
<th scope="col" class="govuk-table__header">Test</th>
|
123
|
-
<th scope="col" class="govuk-table__header">JS test</th>
|
124
|
-
</tr>
|
125
|
-
</thead>
|
126
|
-
<tbody class="govuk-table__body">
|
127
|
-
<% @components[:component_listing].each do |component| %>
|
128
|
-
<tr class="govuk-table__row">
|
129
|
-
<th scope="row" class="govuk-table__header">
|
130
|
-
<a href="<%= component[:link] %>" class="govuk-link"><%= component[:name] %></a>
|
131
|
-
</th>
|
132
|
-
<td class="govuk-table__cell">
|
133
|
-
<% if component[:stylesheet] %>
|
134
|
-
<strong class="govuk-tag govuk-tag--green">Yes</strong>
|
135
|
-
<% end %>
|
136
|
-
</td>
|
137
|
-
<td class="govuk-table__cell">
|
138
|
-
<% if component[:print_stylesheet] %>
|
139
|
-
<strong class="govuk-tag govuk-tag--green">Yes</strong>
|
140
|
-
<% end %>
|
141
|
-
</td>
|
142
|
-
<td class="govuk-table__cell">
|
143
|
-
<% if component[:javascript] %>
|
144
|
-
<strong class="govuk-tag govuk-tag--green">Yes</strong>
|
145
|
-
<% end %>
|
146
|
-
</td>
|
147
|
-
<td class="govuk-table__cell">
|
148
|
-
<% if component[:tests] %>
|
149
|
-
<strong class="govuk-tag govuk-tag--green">Yes</strong>
|
150
|
-
<% end %>
|
151
|
-
</td>
|
152
|
-
<td class="govuk-table__cell">
|
153
|
-
<% if component[:js_tests] %>
|
154
|
-
<strong class="govuk-tag govuk-tag--green">Yes</strong>
|
155
|
-
<% end %>
|
156
|
-
</td>
|
157
|
-
</tr>
|
158
|
-
<% end %>
|
159
|
-
</tbody>
|
160
|
-
</table>
|
161
|
-
</div>
|
162
|
-
</div>
|
163
|
-
|
164
|
-
<div class="govuk-accordion__section ">
|
165
|
-
<div class="govuk-accordion__section-header">
|
166
|
-
<h2 class="govuk-accordion__section-heading">
|
167
|
-
<span class="govuk-accordion__section-button" id="accordion-default-heading-2">
|
168
|
-
Components containing components
|
169
|
-
</span>
|
170
|
-
</h2>
|
171
|
-
<div class="govuk-accordion__section-summary govuk-body" id="accordion-with-summary-sections-summary-2">
|
172
|
-
Shows which components contain other components
|
173
|
-
</div>
|
174
|
-
</div>
|
175
|
-
<div id="accordion-default-content-2" class="govuk-accordion__section-content" aria-labelledby="accordion-default-heading-2">
|
176
|
-
<dl class="govuk-summary-list">
|
177
|
-
<% @components[:components_containing_components].each do |component| %>
|
178
|
-
<div class="govuk-summary-list__row">
|
179
|
-
<dt class="govuk-summary-list__key">
|
180
|
-
<a href="<%= component[:link] %>" class="govuk-link"><%= component[:component] %></a>
|
181
|
-
</dt>
|
182
|
-
<dd class="govuk-summary-list__value">
|
183
|
-
<%= component[:sub_components].join(', ') %>
|
184
|
-
</dd>
|
185
|
-
</div>
|
186
|
-
<% end %>
|
187
|
-
</dl>
|
188
|
-
</div>
|
189
|
-
</div>
|
190
|
-
<div class="govuk-accordion__section ">
|
191
|
-
<div class="govuk-accordion__section-header">
|
192
|
-
<h2 class="govuk-accordion__section-heading">
|
193
|
-
<span class="govuk-accordion__section-button" id="accordion-default-heading-2">
|
194
|
-
Components by application
|
195
|
-
</span>
|
196
|
-
</h2>
|
197
|
-
<div class="govuk-accordion__section-summary govuk-body" id="accordion-with-summary-sections-summary-2">
|
198
|
-
Shows which applications use each component
|
199
|
-
</div>
|
200
|
-
</div>
|
201
|
-
<div id="accordion-default-content-2" class="govuk-accordion__section-content" aria-labelledby="accordion-default-heading-2">
|
202
|
-
<dl class="govuk-summary-list">
|
203
|
-
<% @components[:components_by_application].each do |component| %>
|
204
|
-
<div class="govuk-summary-list__row">
|
205
|
-
<dt class="govuk-summary-list__key">
|
206
|
-
<%= component[:component] %> (<%= component[:count] %>)
|
207
|
-
</dt>
|
208
|
-
<dd class="govuk-summary-list__value">
|
209
|
-
<%= component[:list] %>
|
210
|
-
</dd>
|
211
|
-
</div>
|
212
|
-
<% end %>
|
213
|
-
</dl>
|
214
|
-
</div>
|
215
250
|
</div>
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
251
|
+
<% else %>
|
252
|
+
<p class="govuk-body">No components found.</p>
|
253
|
+
<% end %>
|
254
|
+
</div>
|
220
255
|
</div>
|
221
|
-
|
256
|
+
<% else %>
|
257
|
+
<p class="govuk-body">Component auditing is only available when the component guide is running locally as a standalone app.</p>
|
258
|
+
<% end %>
|