govuk_publishing_components 21.57.1 → 21.60.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +2 -2
- data/app/assets/javascripts/govuk_publishing_components/components/details.js +6 -4
- data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +4 -4
- 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/stylesheets/component_guide/application.scss +15 -15
- 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/_list.scss +1 -0
- 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 +7 -3
- 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 +52 -0
- data/app/controllers/govuk_publishing_components/component_guide_controller.rb +2 -1
- data/app/models/govuk_publishing_components/audit_applications.rb +117 -0
- data/app/models/govuk_publishing_components/audit_comparer.rb +198 -0
- data/app/models/govuk_publishing_components/audit_components.rb +158 -0
- data/app/views/govuk_publishing_components/audit/show.html.erb +258 -0
- data/app/views/govuk_publishing_components/component_guide/index.html.erb +9 -4
- 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/_list.html.erb +26 -0
- 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/_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/list.yml +64 -0
- data/app/views/govuk_publishing_components/components/docs/radio.yml +4 -0
- data/config/routes.rb +1 -0
- data/lib/govuk_publishing_components/presenters/checkboxes_helper.rb +15 -7
- data/lib/govuk_publishing_components/presenters/heading_helper.rb +21 -1
- data/lib/govuk_publishing_components/presenters/image_card_helper.rb +2 -1
- 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/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 +1 -1
- 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 +46 -66
- data/Rakefile +0 -32
@@ -0,0 +1,198 @@
|
|
1
|
+
module GovukPublishingComponents
|
2
|
+
class AuditComparer
|
3
|
+
attr_reader :applications_data, :gem_data
|
4
|
+
|
5
|
+
def initialize(gem_data, results)
|
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
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def prettify_key(key)
|
16
|
+
key.to_s.gsub("_", " ").capitalize
|
17
|
+
end
|
18
|
+
|
19
|
+
def sort_results(results)
|
20
|
+
data = []
|
21
|
+
|
22
|
+
results.each do |result|
|
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
|
77
|
+
end
|
78
|
+
|
79
|
+
data
|
80
|
+
end
|
81
|
+
|
82
|
+
def include_any_components_within_components(components)
|
83
|
+
@gem_data[:components_containing_components].each do |component|
|
84
|
+
components << component[:sub_components] if components.include?(component[:component])
|
85
|
+
end
|
86
|
+
|
87
|
+
components.flatten.uniq.sort
|
88
|
+
end
|
89
|
+
|
90
|
+
def create_warning(component, message)
|
91
|
+
{
|
92
|
+
component: component,
|
93
|
+
message: message,
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
97
|
+
def find_missing_items(first_group, second_group)
|
98
|
+
warnings = []
|
99
|
+
|
100
|
+
first_group.each do |first|
|
101
|
+
first_location = first[:location]
|
102
|
+
|
103
|
+
second_group.each do |second|
|
104
|
+
second_location = second[:location]
|
105
|
+
second_location = "code" if %w[templates ruby].include?(second_location)
|
106
|
+
in_current = find_missing(second[:components].clone, first[:components].clone)
|
107
|
+
|
108
|
+
next if second[:components].include?("all")
|
109
|
+
|
110
|
+
in_current.each do |component|
|
111
|
+
if @gem_data.include?("component_#{second_location}".to_sym)
|
112
|
+
warnings << create_warning(component, "Included in #{first_location} but not #{second_location}") if @gem_data["component_#{second_location}".to_sym].include?(component)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
warnings
|
119
|
+
end
|
120
|
+
|
121
|
+
def warn_about_missing_assets(components)
|
122
|
+
warnings = []
|
123
|
+
|
124
|
+
code = components.select { |c| c[:location] == "templates" || c[:location] == "ruby" }
|
125
|
+
code = [
|
126
|
+
{
|
127
|
+
location: "code",
|
128
|
+
components: code.map { |c| c[:components] }.flatten.uniq.sort,
|
129
|
+
},
|
130
|
+
]
|
131
|
+
assets = components.select { |c| c[:location] == "stylesheets" || c[:location] == "print_stylesheets" || c[:location] == "javascripts" }
|
132
|
+
|
133
|
+
warnings << find_missing_items(code, assets)
|
134
|
+
warnings << find_missing_items(assets, code)
|
135
|
+
warnings.flatten
|
136
|
+
end
|
137
|
+
|
138
|
+
def warn_about_missing_components(results)
|
139
|
+
warnings = []
|
140
|
+
|
141
|
+
results.each do |result|
|
142
|
+
location = result[:location]
|
143
|
+
result[:components].each do |component|
|
144
|
+
warnings << create_warning(component, "Included in #{location} but component does not exist") if component_does_not_exist(component)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
warnings
|
149
|
+
end
|
150
|
+
|
151
|
+
def component_does_not_exist(component)
|
152
|
+
!@gem_data[:component_code].include?(component) unless component == "all"
|
153
|
+
end
|
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
|
+
|
166
|
+
def find_missing(needle, haystack)
|
167
|
+
(haystack - needle).flatten.sort
|
168
|
+
end
|
169
|
+
|
170
|
+
def get_components_by_application
|
171
|
+
results = []
|
172
|
+
found_something = false
|
173
|
+
|
174
|
+
@gem_data[:component_listing].each do |component|
|
175
|
+
found_in_applications = []
|
176
|
+
|
177
|
+
@applications_data.each do |application|
|
178
|
+
next unless application[:application_found]
|
179
|
+
|
180
|
+
name = application[:name]
|
181
|
+
found_something = true
|
182
|
+
|
183
|
+
application[:summary].each do |item|
|
184
|
+
found_in_applications << name if item[:value].include?(component[:name])
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
results << {
|
189
|
+
component: component[:name],
|
190
|
+
count: found_in_applications.uniq.length,
|
191
|
+
list: found_in_applications.uniq.join(", "),
|
192
|
+
}
|
193
|
+
end
|
194
|
+
|
195
|
+
results if found_something
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
module GovukPublishingComponents
|
2
|
+
class AuditComponents
|
3
|
+
attr_reader :data
|
4
|
+
|
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)
|
15
|
+
templates_path = "app/views/govuk_publishing_components/components"
|
16
|
+
stylesheets_path = "app/assets/stylesheets/govuk_publishing_components/components"
|
17
|
+
print_stylesheets_path = "app/assets/stylesheets/govuk_publishing_components/components/print"
|
18
|
+
javascripts_path = "app/assets/javascripts/govuk_publishing_components/components"
|
19
|
+
tests_path = "spec/components"
|
20
|
+
js_tests_path = "spec/javascripts/components"
|
21
|
+
|
22
|
+
templates = Dir["#{path}/#{templates_path}/*.erb"]
|
23
|
+
stylesheets = Dir["#{path}/#{stylesheets_path}/*.scss"]
|
24
|
+
print_stylesheets = Dir["#{path}/#{print_stylesheets_path}/*.scss"]
|
25
|
+
javascripts = Dir["#{path}/#{javascripts_path}/*.js"]
|
26
|
+
tests = Dir["#{path}/#{tests_path}/*.rb"]
|
27
|
+
js_tests = Dir["#{path}/#{js_tests_path}/*.js"]
|
28
|
+
|
29
|
+
@templates_full_path = "#{path}/#{templates_path}/"
|
30
|
+
|
31
|
+
@components = find_files(templates, [path, templates_path].join("/"))
|
32
|
+
@component_stylesheets = find_files(stylesheets, [path, stylesheets_path].join("/"))
|
33
|
+
@component_print_stylesheets = find_files(print_stylesheets, [path, print_stylesheets_path].join("/"))
|
34
|
+
@component_javascripts = find_files(javascripts, [path, javascripts_path].join("/"))
|
35
|
+
@component_tests = find_files(tests, [path, tests_path].join("/"))
|
36
|
+
@component_js_tests = find_files(js_tests, [path, js_tests_path].join("/"))
|
37
|
+
|
38
|
+
{
|
39
|
+
gem_found: true,
|
40
|
+
component_code: @components,
|
41
|
+
component_stylesheets: @component_stylesheets,
|
42
|
+
component_print_stylesheets: @component_print_stylesheets,
|
43
|
+
component_javascripts: @component_javascripts,
|
44
|
+
component_tests: @component_tests,
|
45
|
+
component_js_tests: @component_js_tests,
|
46
|
+
components_containing_components: find_all_partials_in(templates),
|
47
|
+
component_listing: list_all_component_details,
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def find_files(files, replace)
|
52
|
+
files.map { |file| clean_file_name(file.gsub(replace, "")) }.sort
|
53
|
+
end
|
54
|
+
|
55
|
+
def clean_file_name(name)
|
56
|
+
name.tr("/_-", " ")
|
57
|
+
.gsub(".html.erb", "")
|
58
|
+
.gsub(".erb", "")
|
59
|
+
.gsub(".scss", "")
|
60
|
+
.gsub(".js", "")
|
61
|
+
.gsub("spec", "")
|
62
|
+
.gsub(".rb", "")
|
63
|
+
.strip
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_component_name_from_full_path(path)
|
67
|
+
path.gsub(/.*\K\/_/, "/")
|
68
|
+
.gsub(@templates_full_path, "")
|
69
|
+
.gsub(".html.erb", "")
|
70
|
+
.gsub(".erb", "")
|
71
|
+
.tr('\"\'', "")
|
72
|
+
end
|
73
|
+
|
74
|
+
def get_component_link(component)
|
75
|
+
"/component-guide/#{component.gsub(' ', '_')}"
|
76
|
+
end
|
77
|
+
|
78
|
+
def find_all_partials_in(templates)
|
79
|
+
components = []
|
80
|
+
|
81
|
+
templates.each do |template|
|
82
|
+
partials_found = true
|
83
|
+
components_to_search = [template]
|
84
|
+
components_found = []
|
85
|
+
|
86
|
+
while partials_found
|
87
|
+
extra_components = find_partials_in(components_to_search)
|
88
|
+
|
89
|
+
if extra_components.any?
|
90
|
+
components_found << extra_components
|
91
|
+
components_to_search = extra_components
|
92
|
+
else
|
93
|
+
partials_found = false
|
94
|
+
components_found = components_found.flatten.reject { |c| c.include?("/") }
|
95
|
+
|
96
|
+
if components_found.any?
|
97
|
+
component_name = clean_file_name(get_component_name_from_full_path(template))
|
98
|
+
components << {
|
99
|
+
component: component_name,
|
100
|
+
link: get_component_link(component_name),
|
101
|
+
sub_components: components_found.uniq.sort.map { |name| clean_file_name(name) },
|
102
|
+
}
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
components.sort_by { |c| c[:component] }
|
109
|
+
end
|
110
|
+
|
111
|
+
def find_partials_in(components)
|
112
|
+
extra_components = []
|
113
|
+
components.each do |component|
|
114
|
+
extra_components << components_within_component(component)
|
115
|
+
end
|
116
|
+
|
117
|
+
extra_components.flatten.uniq.sort
|
118
|
+
end
|
119
|
+
|
120
|
+
def components_within_component(file)
|
121
|
+
file = get_component_name_from_full_path(file)
|
122
|
+
file = "#{@templates_full_path}#{file}.html.erb".sub(/.*\K\//, "/_")
|
123
|
+
data = File.read(file)
|
124
|
+
match = data.scan(/["']{1}(govuk_publishing_components\/components\/[\/a-z_-]+["']{1})/)
|
125
|
+
match.flatten.uniq.map(&:to_s).sort.map do |m|
|
126
|
+
m.gsub("govuk_publishing_components/components/", "").tr('\"\'', "")
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def list_all_component_details
|
131
|
+
all_component_information = []
|
132
|
+
|
133
|
+
@components.each do |component|
|
134
|
+
all_component_information << {
|
135
|
+
name: component,
|
136
|
+
link: get_component_link(component),
|
137
|
+
stylesheet: check_component_has("stylesheet", component),
|
138
|
+
print_stylesheet: check_component_has("print_stylesheet", component),
|
139
|
+
javascript: check_component_has("javascript", component),
|
140
|
+
tests: check_component_has("test", component),
|
141
|
+
js_tests: check_component_has("js_test", component),
|
142
|
+
}
|
143
|
+
end
|
144
|
+
|
145
|
+
all_component_information
|
146
|
+
end
|
147
|
+
|
148
|
+
def check_component_has(a_thing, component)
|
149
|
+
look_in = @component_stylesheets if a_thing == "stylesheet"
|
150
|
+
look_in = @component_print_stylesheets if a_thing == "print_stylesheet"
|
151
|
+
look_in = @component_javascripts if a_thing == "javascript"
|
152
|
+
look_in = @component_tests if a_thing == "test"
|
153
|
+
look_in = @component_js_tests if a_thing == "js_test"
|
154
|
+
|
155
|
+
true if look_in.include?(component)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
@@ -0,0 +1,258 @@
|
|
1
|
+
<% content_for :title, "Component audit" %>
|
2
|
+
|
3
|
+
<%= render 'govuk_publishing_components/components/title', title: "Components audit", margin_top: 0; %>
|
4
|
+
|
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
|
+
} %>
|
28
|
+
|
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 %>
|
118
|
+
</div>
|
119
|
+
<% else %>
|
120
|
+
<p class="govuk-body">No applications found.</p>
|
121
|
+
<% end %>
|
122
|
+
</div>
|
123
|
+
|
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">
|
133
|
+
<div class="govuk-accordion__section ">
|
134
|
+
<div class="govuk-accordion__section-header">
|
135
|
+
<h2 class="govuk-accordion__section-heading">
|
136
|
+
<span class="govuk-accordion__section-button" id="accordion-default-heading-1">
|
137
|
+
Component files
|
138
|
+
</span>
|
139
|
+
</h2>
|
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>
|
188
|
+
<% end %>
|
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
|
203
|
+
</div>
|
204
|
+
</div>
|
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>
|
216
|
+
<% end %>
|
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? %>
|
233
|
+
<dl class="govuk-summary-list">
|
234
|
+
<% @components[:components_by_application].each do |component| %>
|
235
|
+
<div class="govuk-summary-list__row">
|
236
|
+
<dt class="govuk-summary-list__key">
|
237
|
+
<%= component[:component] %> (<%= component[:count] %>)
|
238
|
+
</dt>
|
239
|
+
<dd class="govuk-summary-list__value">
|
240
|
+
<%= component[:list] %>
|
241
|
+
</dd>
|
242
|
+
</div>
|
243
|
+
<% end %>
|
244
|
+
</dl>
|
245
|
+
<% else %>
|
246
|
+
<p class="govuk-body">Sorry, no applications found.</p>
|
247
|
+
<% end %>
|
248
|
+
</div>
|
249
|
+
</div>
|
250
|
+
</div>
|
251
|
+
<% else %>
|
252
|
+
<p class="govuk-body">No components found.</p>
|
253
|
+
<% end %>
|
254
|
+
</div>
|
255
|
+
</div>
|
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 %>
|