govuk_publishing_components 21.58.0 → 21.59.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/details.js +5 -3
- data/app/controllers/govuk_publishing_components/audit_controller.rb +52 -0
- data/app/models/govuk_publishing_components/audit_applications.rb +99 -0
- data/app/models/govuk_publishing_components/audit_comparer.rb +172 -0
- data/app/models/govuk_publishing_components/audit_components.rb +139 -0
- data/app/views/govuk_publishing_components/audit/show.html.erb +221 -0
- data/app/views/govuk_publishing_components/component_guide/index.html.erb +5 -1
- data/config/routes.rb +1 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d31d1f48a5d3491e568c0412fdbbcfaf2e1a98a71aaf84ff703556e83a19b6b
|
4
|
+
data.tar.gz: 45ecc8d0b068dd621f3a5a4fb2b4add39f542cfe14ba22f5a2e9828ae9638438
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89fd3c928d07a3cda0079255ea980e7731bda3eb1b9033eeba53131f85f05c12a9073334b17a04b86c050ddd5329fcef28be3ced3373137b6c4385cefb1070aa
|
7
|
+
data.tar.gz: 82d9e99c1d65f4441404f8a76c18ccc11a3357250ac579bdd6844e8f0b57c63d41dfca449cb848b3f86e37576c7e5dcd6eb3e373860c5d1814882ac52a6d3052
|
@@ -20,9 +20,11 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
20
20
|
var detailsClick = detailsComponent.querySelector('[data-details-track-click]')
|
21
21
|
var that = this
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
if (detailsClick) {
|
24
|
+
detailsClick.addEventListener('click', function (event) {
|
25
|
+
that.trackDefault(detailsComponent)
|
26
|
+
})
|
27
|
+
}
|
26
28
|
}
|
27
29
|
}
|
28
30
|
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module GovukPublishingComponents
|
2
|
+
class AuditController < GovukPublishingComponents::ApplicationController
|
3
|
+
def show
|
4
|
+
path = Dir.pwd
|
5
|
+
|
6
|
+
components = AuditComponents.new(path)
|
7
|
+
applications = analyse_applications(File.expand_path("..", path))
|
8
|
+
compared_data = AuditComparer.new(components.data, applications)
|
9
|
+
|
10
|
+
@applications = compared_data.data
|
11
|
+
@components = compared_data.gem_data
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def analyse_applications(path)
|
17
|
+
results = []
|
18
|
+
applications = %w[
|
19
|
+
calculators
|
20
|
+
collections
|
21
|
+
collections-publisher
|
22
|
+
content-data-admin
|
23
|
+
content-publisher
|
24
|
+
email-alert-frontend
|
25
|
+
feedback
|
26
|
+
finder-frontend
|
27
|
+
frontend
|
28
|
+
government-frontend
|
29
|
+
govspeak-preview
|
30
|
+
info-frontend
|
31
|
+
licence-finder
|
32
|
+
manuals-frontend
|
33
|
+
release
|
34
|
+
search-admin
|
35
|
+
service-manual-frontend
|
36
|
+
signon
|
37
|
+
smart-answers
|
38
|
+
static
|
39
|
+
travel-advice-publisher
|
40
|
+
whitehall
|
41
|
+
].sort
|
42
|
+
|
43
|
+
applications.each do |application|
|
44
|
+
application_path = [path, application].join("/")
|
45
|
+
app = AuditApplications.new(application_path, application)
|
46
|
+
results << app.data
|
47
|
+
end
|
48
|
+
|
49
|
+
results
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module GovukPublishingComponents
|
2
|
+
class AuditApplications
|
3
|
+
attr_reader :data
|
4
|
+
|
5
|
+
def initialize(path, name)
|
6
|
+
templates = Dir["#{path}/app/views/**/*.html.erb"]
|
7
|
+
stylesheets = Dir["#{path}/app/assets/stylesheets/**/*.scss"]
|
8
|
+
javascripts = Dir["#{path}/app/assets/javascripts/**/*.js"]
|
9
|
+
|
10
|
+
find_templates = /(?<=govuk_publishing_components\/components\/)[\/a-zA-Z_-]+(?=['"])/
|
11
|
+
|
12
|
+
@find_all_stylesheets = /@import ["']{1}govuk_publishing_components\/all_components/
|
13
|
+
find_stylesheets = /(?<=@import ["']{1}govuk_publishing_components\/components\/)(?!print)+[a-zA-Z_-]+(?=['"])/
|
14
|
+
|
15
|
+
@find_all_print_stylesheets = /@import ["']{1}govuk_publishing_components\/all_components_print/
|
16
|
+
find_print_stylesheets = /(?<=@import ["']{1}govuk_publishing_components\/components\/print\/)[a-zA-Z_-]+(?=['"])/
|
17
|
+
|
18
|
+
@find_all_javascripts = /\/\/[ ]*= require govuk_publishing_components\/all_components/
|
19
|
+
find_javascripts = /(?<=require govuk_publishing_components\/components\/)[a-zA-Z_-]+/
|
20
|
+
|
21
|
+
components_in_templates = find_components(templates, find_templates, "templates") || []
|
22
|
+
components_in_stylesheets = find_components(stylesheets, find_stylesheets, "stylesheets") || []
|
23
|
+
components_in_print_stylesheets = find_components(stylesheets, find_print_stylesheets, "print_stylesheets") || []
|
24
|
+
components_in_javascripts = find_components(javascripts, find_javascripts, "javascripts") || []
|
25
|
+
|
26
|
+
find_ruby = /(?<=render\(["']{1}govuk_publishing_components\/components\/)[a-zA-Z_-]+/
|
27
|
+
ruby_paths = %w[/app/helpers/ /app/presenters/ /lib/]
|
28
|
+
|
29
|
+
components_in_ruby = []
|
30
|
+
ruby_paths.each do |ruby_path|
|
31
|
+
components_in_ruby << find_components(Dir["#{path}#{ruby_path}**/*.rb"], find_ruby, "ruby") || []
|
32
|
+
end
|
33
|
+
|
34
|
+
components_in_ruby = components_in_ruby.flatten.uniq
|
35
|
+
|
36
|
+
@data = {
|
37
|
+
name: name,
|
38
|
+
application_found: application_exists(path),
|
39
|
+
components_found: [
|
40
|
+
{
|
41
|
+
location: "templates",
|
42
|
+
components: components_in_templates,
|
43
|
+
},
|
44
|
+
{
|
45
|
+
location: "stylesheets",
|
46
|
+
components: components_in_stylesheets,
|
47
|
+
},
|
48
|
+
{
|
49
|
+
location: "print_stylesheets",
|
50
|
+
components: components_in_print_stylesheets,
|
51
|
+
},
|
52
|
+
{
|
53
|
+
location: "javascripts",
|
54
|
+
components: components_in_javascripts,
|
55
|
+
},
|
56
|
+
{
|
57
|
+
location: "ruby",
|
58
|
+
components: components_in_ruby,
|
59
|
+
},
|
60
|
+
],
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def find_components(files, find, type)
|
67
|
+
components_found = []
|
68
|
+
|
69
|
+
files.each do |file|
|
70
|
+
src = File.read(file)
|
71
|
+
components_found << find_match(find, src, type)
|
72
|
+
end
|
73
|
+
|
74
|
+
components_found.flatten.uniq.sort
|
75
|
+
end
|
76
|
+
|
77
|
+
def find_match(find, src, type)
|
78
|
+
return %w[all] if src.match(@find_all_stylesheets) && type == "stylesheets"
|
79
|
+
return %w[all] if src.match(@find_all_print_stylesheets) && type == "print_stylesheets"
|
80
|
+
return %w[all] if src.match(@find_all_javascripts) && type == "javascripts"
|
81
|
+
|
82
|
+
matches = src.scan(find)
|
83
|
+
all_matches = []
|
84
|
+
matches.each do |match|
|
85
|
+
all_matches << clean_file_name(match.tr('[])\'"', ""))
|
86
|
+
end
|
87
|
+
|
88
|
+
all_matches
|
89
|
+
end
|
90
|
+
|
91
|
+
def clean_file_name(name)
|
92
|
+
name.tr("_-", " ").strip
|
93
|
+
end
|
94
|
+
|
95
|
+
def application_exists(directory)
|
96
|
+
File.directory?(directory)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
module GovukPublishingComponents
|
2
|
+
class AuditComparer
|
3
|
+
attr_reader :data, :gem_data
|
4
|
+
|
5
|
+
def initialize(gem_data, results)
|
6
|
+
@gem_data = gem_data
|
7
|
+
@data = sort_results(results)
|
8
|
+
@gem_data[:components_by_application] = get_components_by_application
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def prettify_key(key)
|
14
|
+
key.to_s.gsub("_", " ").capitalize
|
15
|
+
end
|
16
|
+
|
17
|
+
def sort_results(results)
|
18
|
+
data = []
|
19
|
+
|
20
|
+
results.each do |result|
|
21
|
+
templates = result[:components_found].find { |c| c[:location] == "templates" }
|
22
|
+
stylesheets = result[:components_found].find { |c| c[:location] == "stylesheets" }
|
23
|
+
print_stylesheets = result[:components_found].find { |c| c[:location] == "print_stylesheets" }
|
24
|
+
javascripts = result[:components_found].find { |c| c[:location] == "javascripts" }
|
25
|
+
ruby = result[:components_found].find { |c| c[:location] == "ruby" }
|
26
|
+
|
27
|
+
@all_stylesheets = true if stylesheets[:components].include?("all")
|
28
|
+
@all_print_stylesheets = true if print_stylesheets[:components].include?("all")
|
29
|
+
@all_javascripts = true if javascripts[:components].include?("all")
|
30
|
+
|
31
|
+
templates[:components] = include_any_components_within_components(templates[:components])
|
32
|
+
|
33
|
+
warnings = []
|
34
|
+
warnings << warn_about_missing_components(result[:components_found])
|
35
|
+
warnings << warn_about_missing_assets(result[:components_found])
|
36
|
+
warnings = warnings.flatten
|
37
|
+
|
38
|
+
data << {
|
39
|
+
name: result[:name],
|
40
|
+
application_found: result[:application_found],
|
41
|
+
summary: [
|
42
|
+
{
|
43
|
+
name: "Components in templates",
|
44
|
+
value: templates[:components].flatten.uniq.sort.join(", "),
|
45
|
+
},
|
46
|
+
{
|
47
|
+
name: "Components in stylesheets",
|
48
|
+
value: stylesheets[:components].join(", "),
|
49
|
+
},
|
50
|
+
{
|
51
|
+
name: "Components in print stylesheets",
|
52
|
+
value: print_stylesheets[:components].join(", "),
|
53
|
+
},
|
54
|
+
{
|
55
|
+
name: "Components in javascripts",
|
56
|
+
value: javascripts[:components].join(", "),
|
57
|
+
},
|
58
|
+
{
|
59
|
+
name: "Components in ruby",
|
60
|
+
value: ruby[:components].join(", "),
|
61
|
+
},
|
62
|
+
],
|
63
|
+
warnings: warnings,
|
64
|
+
warning_count: warnings.length,
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
data
|
69
|
+
end
|
70
|
+
|
71
|
+
def include_any_components_within_components(components)
|
72
|
+
@gem_data[:components_containing_components].each do |component|
|
73
|
+
components << component[:sub_components] if components.include?(component[:component])
|
74
|
+
end
|
75
|
+
|
76
|
+
components.flatten.uniq.sort
|
77
|
+
end
|
78
|
+
|
79
|
+
def create_warning(component, message)
|
80
|
+
{
|
81
|
+
component: component,
|
82
|
+
message: message,
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
def find_missing_items(first_group, second_group)
|
87
|
+
warnings = []
|
88
|
+
|
89
|
+
first_group.each do |first|
|
90
|
+
first_location = first[:location]
|
91
|
+
|
92
|
+
second_group.each do |second|
|
93
|
+
second_location = second[:location]
|
94
|
+
second_location = "code" if %w[templates ruby].include?(second_location)
|
95
|
+
in_current = find_missing(second[:components].clone, first[:components].clone)
|
96
|
+
|
97
|
+
next if second[:components].include?("all")
|
98
|
+
|
99
|
+
in_current.each do |component|
|
100
|
+
if @gem_data.include?("component_#{second_location}".to_sym)
|
101
|
+
warnings << create_warning(component, "Included in #{first_location} but not #{second_location}") if @gem_data["component_#{second_location}".to_sym].include?(component)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
warnings
|
108
|
+
end
|
109
|
+
|
110
|
+
def warn_about_missing_assets(components)
|
111
|
+
warnings = []
|
112
|
+
|
113
|
+
code = components.select { |c| c[:location] == "templates" || c[:location] == "ruby" }
|
114
|
+
code = [
|
115
|
+
{
|
116
|
+
location: "code",
|
117
|
+
components: code.map { |c| c[:components] }.flatten.uniq.sort,
|
118
|
+
},
|
119
|
+
]
|
120
|
+
assets = components.select { |c| c[:location] == "stylesheets" || c[:location] == "print_stylesheets" || c[:location] == "javascripts" }
|
121
|
+
|
122
|
+
warnings << find_missing_items(code, assets)
|
123
|
+
warnings << find_missing_items(assets, code)
|
124
|
+
warnings.flatten
|
125
|
+
end
|
126
|
+
|
127
|
+
def warn_about_missing_components(results)
|
128
|
+
warnings = []
|
129
|
+
|
130
|
+
results.each do |result|
|
131
|
+
location = result[:location]
|
132
|
+
result[:components].each do |component|
|
133
|
+
warnings << create_warning(component, "Included in #{location} but component does not exist") if component_does_not_exist(component)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
warnings
|
138
|
+
end
|
139
|
+
|
140
|
+
def component_does_not_exist(component)
|
141
|
+
!@gem_data[:component_code].include?(component) unless component == "all"
|
142
|
+
end
|
143
|
+
|
144
|
+
def find_missing(needle, haystack)
|
145
|
+
(haystack - needle).flatten.sort
|
146
|
+
end
|
147
|
+
|
148
|
+
def get_components_by_application
|
149
|
+
results = []
|
150
|
+
|
151
|
+
@gem_data[:component_listing].each do |component|
|
152
|
+
found_in_applications = []
|
153
|
+
|
154
|
+
@data.each do |application|
|
155
|
+
name = application[:name]
|
156
|
+
|
157
|
+
application[:summary].each do |item|
|
158
|
+
found_in_applications << name if item[:value].include?(component[:name])
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
results << {
|
163
|
+
component: component[:name],
|
164
|
+
count: found_in_applications.uniq.length,
|
165
|
+
list: found_in_applications.uniq.join(", "),
|
166
|
+
}
|
167
|
+
end
|
168
|
+
|
169
|
+
results
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
module GovukPublishingComponents
|
2
|
+
class AuditComponents
|
3
|
+
attr_reader :data
|
4
|
+
|
5
|
+
def initialize(path)
|
6
|
+
templates_path = "app/views/govuk_publishing_components/components"
|
7
|
+
stylesheets_path = "app/assets/stylesheets/govuk_publishing_components/components"
|
8
|
+
print_stylesheets_path = "app/assets/stylesheets/govuk_publishing_components/components/print"
|
9
|
+
javascripts_path = "app/assets/javascripts/govuk_publishing_components/components"
|
10
|
+
tests_path = "spec/components"
|
11
|
+
js_tests_path = "spec/javascripts/components"
|
12
|
+
|
13
|
+
templates = Dir["#{path}/#{templates_path}/*.html.erb"]
|
14
|
+
stylesheets = Dir["#{path}/#{stylesheets_path}/*.scss"]
|
15
|
+
print_stylesheets = Dir["#{path}/#{print_stylesheets_path}/*.scss"]
|
16
|
+
javascripts = Dir["#{path}/#{javascripts_path}/*.js"]
|
17
|
+
tests = Dir["#{path}/#{tests_path}/*.rb"]
|
18
|
+
js_tests = Dir["#{path}/#{js_tests_path}/*.js"]
|
19
|
+
|
20
|
+
@templates_full_path = "#{path}/#{templates_path}/"
|
21
|
+
|
22
|
+
@components = find_files(templates, [path, templates_path].join("/"))
|
23
|
+
@component_stylesheets = find_files(stylesheets, [path, stylesheets_path].join("/"))
|
24
|
+
@component_print_stylesheets = find_files(print_stylesheets, [path, print_stylesheets_path].join("/"))
|
25
|
+
@component_javascripts = find_files(javascripts, [path, javascripts_path].join("/"))
|
26
|
+
@component_tests = find_files(tests, [path, tests_path].join("/"))
|
27
|
+
@component_js_tests = find_files(js_tests, [path, js_tests_path].join("/"))
|
28
|
+
|
29
|
+
@data = {
|
30
|
+
component_code: @components,
|
31
|
+
component_stylesheets: @component_stylesheets,
|
32
|
+
component_print_stylesheets: @component_print_stylesheets,
|
33
|
+
component_javascripts: @component_javascripts,
|
34
|
+
component_tests: @component_tests,
|
35
|
+
component_js_tests: @component_js_tests,
|
36
|
+
components_containing_components: find_all_partials_in(templates),
|
37
|
+
component_listing: list_all_component_details,
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def find_files(files, replace)
|
44
|
+
files.map { |file| clean_file_name(file.gsub(replace, "")) }.sort
|
45
|
+
end
|
46
|
+
|
47
|
+
def clean_file_name(name)
|
48
|
+
name.tr("/_-", " ").gsub(".html.erb", "").gsub(".scss", "").gsub(".js", "").gsub("spec", "").gsub(".rb", "").strip
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_component_name_from_full_path(path)
|
52
|
+
path.gsub("/_", "/").gsub(@templates_full_path, "").gsub(".html.erb", "").tr('\"\'', "")
|
53
|
+
end
|
54
|
+
|
55
|
+
def get_component_link(component)
|
56
|
+
"/component-guide/#{component.gsub(' ', '_')}"
|
57
|
+
end
|
58
|
+
|
59
|
+
def find_all_partials_in(templates)
|
60
|
+
components = []
|
61
|
+
|
62
|
+
templates.each do |template|
|
63
|
+
partials_found = true
|
64
|
+
components_to_search = [template]
|
65
|
+
components_found = []
|
66
|
+
|
67
|
+
while partials_found
|
68
|
+
extra_components = find_partials_in(components_to_search)
|
69
|
+
|
70
|
+
if extra_components.any?
|
71
|
+
components_found << extra_components
|
72
|
+
components_to_search = extra_components
|
73
|
+
else
|
74
|
+
partials_found = false
|
75
|
+
components_found = components_found.flatten.reject { |c| c.include?("/") }
|
76
|
+
|
77
|
+
if components_found.any?
|
78
|
+
component_name = clean_file_name(get_component_name_from_full_path(template))
|
79
|
+
components << {
|
80
|
+
component: component_name,
|
81
|
+
link: get_component_link(component_name),
|
82
|
+
sub_components: components_found.uniq.sort.map { |name| clean_file_name(name) },
|
83
|
+
}
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
components.sort_by { |c| c[:component] }
|
90
|
+
end
|
91
|
+
|
92
|
+
def find_partials_in(components)
|
93
|
+
extra_components = []
|
94
|
+
components.each do |component|
|
95
|
+
extra_components << components_within_component(component)
|
96
|
+
end
|
97
|
+
|
98
|
+
extra_components.flatten.uniq.sort
|
99
|
+
end
|
100
|
+
|
101
|
+
def components_within_component(file)
|
102
|
+
file = get_component_name_from_full_path(file)
|
103
|
+
file = "#{@templates_full_path}#{file}.html.erb".sub(/.*\K\//, "/_")
|
104
|
+
data = File.read(file)
|
105
|
+
match = data.scan(/["']{1}(govuk_publishing_components\/components\/[\/a-z_-]+["']{1})/)
|
106
|
+
match.flatten.uniq.map(&:to_s).sort.map do |m|
|
107
|
+
m.gsub("govuk_publishing_components/components/", "").tr('\"\'', "")
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def list_all_component_details
|
112
|
+
all_component_information = []
|
113
|
+
|
114
|
+
@components.each do |component|
|
115
|
+
all_component_information << {
|
116
|
+
name: component,
|
117
|
+
link: get_component_link(component),
|
118
|
+
stylesheet: check_component_has("stylesheet", component),
|
119
|
+
print_stylesheet: check_component_has("print_stylesheet", component),
|
120
|
+
javascript: check_component_has("javascript", component),
|
121
|
+
tests: check_component_has("test", component),
|
122
|
+
js_tests: check_component_has("js_test", component),
|
123
|
+
}
|
124
|
+
end
|
125
|
+
|
126
|
+
all_component_information
|
127
|
+
end
|
128
|
+
|
129
|
+
def check_component_has(a_thing, component)
|
130
|
+
look_in = @component_stylesheets if a_thing == "stylesheet"
|
131
|
+
look_in = @component_print_stylesheets if a_thing == "print_stylesheet"
|
132
|
+
look_in = @component_javascripts if a_thing == "javascript"
|
133
|
+
look_in = @component_tests if a_thing == "test"
|
134
|
+
look_in = @component_js_tests if a_thing == "js_test"
|
135
|
+
|
136
|
+
true if look_in.include?(component)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,221 @@
|
|
1
|
+
<% content_for :title, "Component audit" %>
|
2
|
+
|
3
|
+
<%= render 'govuk_publishing_components/components/title', title: "Components audit", margin_top: 0; %>
|
4
|
+
|
5
|
+
<div class="govuk-tabs" data-module="govuk-tabs">
|
6
|
+
<h2 class="govuk-tabs__title">
|
7
|
+
Contents
|
8
|
+
</h2>
|
9
|
+
<ul class="govuk-tabs__list">
|
10
|
+
<li class="govuk-tabs__list-item govuk-tabs__list-item--selected">
|
11
|
+
<a class="govuk-tabs__tab" href="#applications">
|
12
|
+
Applications
|
13
|
+
</a>
|
14
|
+
</li>
|
15
|
+
<li class="govuk-tabs__list-item">
|
16
|
+
<a class="govuk-tabs__tab" href="#components-gem">
|
17
|
+
Components
|
18
|
+
</a>
|
19
|
+
</li>
|
20
|
+
</ul>
|
21
|
+
<div class="govuk-tabs__panel" id="applications">
|
22
|
+
<h2 class="govuk-heading-l">Applications</h2>
|
23
|
+
|
24
|
+
<% if @applications.any? %>
|
25
|
+
<details class="govuk-details" data-module="govuk-details">
|
26
|
+
<summary class="govuk-details__summary">
|
27
|
+
<span class="govuk-details__summary-text">
|
28
|
+
How to use this information
|
29
|
+
</span>
|
30
|
+
</summary>
|
31
|
+
<div class="govuk-details__text">
|
32
|
+
<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>
|
33
|
+
<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>
|
34
|
+
</div>
|
35
|
+
</details>
|
36
|
+
|
37
|
+
<div class="govuk-accordion" data-module="govuk-accordion" id="accordion-with-summary-sections">
|
38
|
+
<% @applications.each_with_index do |application, index| %>
|
39
|
+
<div class="govuk-accordion__section ">
|
40
|
+
<div class="govuk-accordion__section-header">
|
41
|
+
<h2 class="govuk-accordion__section-heading">
|
42
|
+
<span class="govuk-accordion__section-button" id="accordion-with-summary-sections-heading-<%= index %>">
|
43
|
+
<%= application[:name] %>
|
44
|
+
</span>
|
45
|
+
</h2>
|
46
|
+
<div class="govuk-accordion__section-summary govuk-body" id="accordion-with-summary-sections-summary-<%= index %>">
|
47
|
+
<% if application[:application_found] %>
|
48
|
+
Warnings:
|
49
|
+
<% if application[:warning_count] > 0 %>
|
50
|
+
<strong class="govuk-tag govuk-tag--red"><%= application[:warning_count] %></strong>
|
51
|
+
<% else %>
|
52
|
+
<%= application[:warning_count] %>
|
53
|
+
<% end %>
|
54
|
+
<% else %>
|
55
|
+
<strong class="govuk-tag govuk-tag--red">Application not found</strong>
|
56
|
+
<% end %>
|
57
|
+
</div>
|
58
|
+
</div>
|
59
|
+
<div id="accordion-with-summary-sections-content-<%= index %>" class="govuk-accordion__section-content" aria-labelledby="accordion-with-summary-sections-heading-<%= index %>">
|
60
|
+
<% if application[:application_found] %>
|
61
|
+
<% application[:warnings].each do |warning| %>
|
62
|
+
<p class="govuk-body">
|
63
|
+
<strong class="govuk-tag">Warn</strong>
|
64
|
+
<strong><%= warning[:component] %></strong> - <%= warning[:message] %>
|
65
|
+
</p>
|
66
|
+
<% end %>
|
67
|
+
|
68
|
+
<h3 class="govuk-heading-m">Components used</h3>
|
69
|
+
|
70
|
+
<dl class="govuk-summary-list">
|
71
|
+
<% application[:summary].each do |item| %>
|
72
|
+
<div class="govuk-summary-list__row">
|
73
|
+
<dt class="govuk-summary-list__key">
|
74
|
+
<%= item[:name] %>
|
75
|
+
</dt>
|
76
|
+
<dd class="govuk-summary-list__value">
|
77
|
+
<% if item[:value].length > 0 %>
|
78
|
+
<%= item[:value] %>
|
79
|
+
<% else %>
|
80
|
+
None
|
81
|
+
<% end %>
|
82
|
+
</dd>
|
83
|
+
</div>
|
84
|
+
<% end %>
|
85
|
+
</dl>
|
86
|
+
<% else %>
|
87
|
+
<p class="govuk-body">This application was not found. This could be because you do not have this repository checked out locally.</p>
|
88
|
+
<% end %>
|
89
|
+
</div>
|
90
|
+
</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
|
+
</div>
|
216
|
+
</div>
|
217
|
+
<% else %>
|
218
|
+
<p class="govuk-body">No components found.</p>
|
219
|
+
<% end %>
|
220
|
+
</div>
|
221
|
+
</div>
|
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
<div class="component-markdown">
|
4
4
|
<p>Components are packages of template, style, behaviour and documentation that live in your application.</p>
|
5
|
-
<p>See the <a href="https://github.com/alphagov/govuk_publishing_components">govuk_publishing_components gem</a> for further details, or <a href="https://docs.publishing.service.gov.uk/manual/components.html#component-guides">a list of all component guides</a
|
5
|
+
<p>See the <a href="https://github.com/alphagov/govuk_publishing_components">govuk_publishing_components gem</a> for further details, or <a href="https://docs.publishing.service.gov.uk/manual/components.html#component-guides">a list of all component guides</a>.</p>
|
6
|
+
<ul>
|
7
|
+
<li>Read about how to <a href="https://github.com/alphagov/govuk_publishing_components/blob/master/docs/publishing-to-rubygems.md">release a new version of the gem</a></li>
|
8
|
+
<li><a href="/component-guide/audit">View component audits</a></li>
|
9
|
+
</ul>
|
6
10
|
</div>
|
7
11
|
|
8
12
|
<form role="search" data-module="filter-components" class="component-search">
|
data/config/routes.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
GovukPublishingComponents::Engine.routes.draw do
|
2
|
+
get "/audit" => "audit#show", as: :audit
|
2
3
|
root to: "component_guide#index", as: :component_guide
|
3
4
|
get ":component/preview" => "component_guide#preview", as: :component_preview_all
|
4
5
|
get ":component/:example/preview" => "component_guide#preview", as: :component_preview
|
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.
|
4
|
+
version: 21.59.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: 2020-07-
|
11
|
+
date: 2020-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gds-api-adapters
|
@@ -597,12 +597,17 @@ files:
|
|
597
597
|
- app/assets/stylesheets/govuk_publishing_components/components/print/_translation-nav.scss
|
598
598
|
- app/assets/stylesheets/govuk_publishing_components/govuk_frontend_support.scss
|
599
599
|
- app/controllers/govuk_publishing_components/application_controller.rb
|
600
|
+
- app/controllers/govuk_publishing_components/audit_controller.rb
|
600
601
|
- app/controllers/govuk_publishing_components/component_guide_controller.rb
|
601
602
|
- app/helpers/govuk_publishing_components/application_helper.rb
|
603
|
+
- app/models/govuk_publishing_components/audit_applications.rb
|
604
|
+
- app/models/govuk_publishing_components/audit_comparer.rb
|
605
|
+
- app/models/govuk_publishing_components/audit_components.rb
|
602
606
|
- app/models/govuk_publishing_components/component_doc.rb
|
603
607
|
- app/models/govuk_publishing_components/component_docs.rb
|
604
608
|
- app/models/govuk_publishing_components/component_example.rb
|
605
609
|
- app/models/govuk_publishing_components/shared_accessibility_criteria.rb
|
610
|
+
- app/views/govuk_publishing_components/audit/show.html.erb
|
606
611
|
- app/views/govuk_publishing_components/component_guide/_application_stylesheet.html.erb
|
607
612
|
- app/views/govuk_publishing_components/component_guide/component_doc/_call.html.erb
|
608
613
|
- app/views/govuk_publishing_components/component_guide/component_doc/_component.html.erb
|