govuk_publishing_components 21.57.1 → 21.60.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/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
data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-related.scss
CHANGED
@@ -12,6 +12,7 @@
|
|
12
12
|
|
13
13
|
.gem-c-step-nav-related__links {
|
14
14
|
@include govuk-font(16);
|
15
|
+
list-style: none;
|
15
16
|
margin: 0;
|
16
17
|
padding: 0;
|
17
18
|
}
|
@@ -42,10 +43,6 @@
|
|
42
43
|
}
|
43
44
|
}
|
44
45
|
|
45
|
-
.gem-c-step-nav-related__links {
|
46
|
-
list-style: none;
|
47
|
-
}
|
48
|
-
|
49
46
|
.gem-c-step-nav-related__link-item {
|
50
47
|
margin-top: govuk-spacing(3);
|
51
48
|
}
|
@@ -29,7 +29,7 @@ $top-border: solid 2px govuk-colour("mid-grey", $legacy: "grey-3");
|
|
29
29
|
// we want to ensure that both large and small step navs have the same size font on mobile
|
30
30
|
// this will stop text resizing if compatibility mode is turned off
|
31
31
|
@mixin step-nav-font($size, $tablet-size: $size, $weight: normal, $line-height: 1.3, $tablet-line-height: $line-height) {
|
32
|
-
@include govuk-typography-common
|
32
|
+
@include govuk-typography-common;
|
33
33
|
font-size: $size + px;
|
34
34
|
font-weight: $weight;
|
35
35
|
line-height: $line-height;
|
@@ -122,7 +122,7 @@ $top-border: solid 2px govuk-colour("mid-grey", $legacy: "grey-3");
|
|
122
122
|
@include govuk-media-query($from: tablet) {
|
123
123
|
padding-left: govuk-spacing(9);
|
124
124
|
|
125
|
-
&:after {
|
125
|
+
&:after { // stylelint-disable-line max-nesting-depth
|
126
126
|
@include step-nav-line-position-large;
|
127
127
|
top: govuk-spacing(6);
|
128
128
|
}
|
@@ -145,12 +145,8 @@ $top-border: solid 2px govuk-colour("mid-grey", $legacy: "grey-3");
|
|
145
145
|
}
|
146
146
|
|
147
147
|
&:after {
|
148
|
-
// scss-lint:disable DuplicateProperty
|
149
|
-
// sass-lint:disable no-duplicate-properties
|
150
148
|
height: -webkit-calc(100% - #{govuk-spacing(3)}); // fallback for iphone 4
|
151
149
|
height: calc(100% - #{govuk-spacing(3)});
|
152
|
-
// sass-lint:enable no-duplicate-properties
|
153
|
-
// scss-lint:enable DuplicateProperty
|
154
150
|
}
|
155
151
|
|
156
152
|
.gem-c-step-nav__help:after {
|
@@ -322,12 +318,6 @@ $top-border: solid 2px govuk-colour("mid-grey", $legacy: "grey-3");
|
|
322
318
|
|
323
319
|
+ .gem-c-step-nav__list {
|
324
320
|
margin-top: -5px;
|
325
|
-
|
326
|
-
.gem-c-step-nav--large & {
|
327
|
-
@include govuk-media-query($from: tablet) {
|
328
|
-
margin-top: -govuk-spacing(3);
|
329
|
-
}
|
330
|
-
}
|
331
321
|
}
|
332
322
|
|
333
323
|
.gem-c-step-nav--large & {
|
@@ -335,6 +325,12 @@ $top-border: solid 2px govuk-colour("mid-grey", $legacy: "grey-3");
|
|
335
325
|
padding-bottom: govuk-spacing(6);
|
336
326
|
}
|
337
327
|
}
|
328
|
+
|
329
|
+
.gem-c-step-nav--large & + .gem-c-step-nav__list {
|
330
|
+
@include govuk-media-query($from: tablet) {
|
331
|
+
margin-top: -govuk-spacing(3);
|
332
|
+
}
|
333
|
+
}
|
338
334
|
}
|
339
335
|
|
340
336
|
.gem-c-step-nav__list {
|
@@ -37,28 +37,26 @@ $table-row-even-background-colour: govuk-colour("light-grey", $legacy: "grey-4")
|
|
37
37
|
padding-right: $sort-link-arrow-size;
|
38
38
|
color: $govuk-link-colour;
|
39
39
|
text-decoration: none;
|
40
|
+
}
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
&::after {
|
46
|
-
content: "";
|
47
|
-
position: absolute;
|
48
|
-
top: 5px;
|
49
|
-
right: 0;
|
50
|
-
|
51
|
-
@include govuk-shape-arrow($direction: up, $base: $sort-link-arrow-size-small, $display: block);
|
52
|
-
}
|
42
|
+
.app-table__sort-link:focus {
|
43
|
+
@include govuk-focused-text;
|
44
|
+
}
|
53
45
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
46
|
+
.app-table__sort-link:after {
|
47
|
+
content: "";
|
48
|
+
position: absolute;
|
49
|
+
top: 5px;
|
50
|
+
right: 0;
|
51
|
+
@include govuk-shape-arrow($direction: up, $base: $sort-link-arrow-size-small, $display: block);
|
52
|
+
}
|
59
53
|
|
60
|
-
|
61
|
-
|
54
|
+
.app-table__sort-link:before {
|
55
|
+
content: "";
|
56
|
+
position: absolute;
|
57
|
+
top: 13px;
|
58
|
+
right: 0;
|
59
|
+
@include govuk-shape-arrow($direction: down, $base: $sort-link-arrow-size-small, $display: block);
|
62
60
|
}
|
63
61
|
}
|
64
62
|
|
@@ -81,12 +79,12 @@ $table-row-even-background-colour: govuk-colour("light-grey", $legacy: "grey-4")
|
|
81
79
|
}
|
82
80
|
}
|
83
81
|
|
84
|
-
.app-table__sort-link--ascending
|
85
|
-
.app-table__sort-link--descending
|
82
|
+
.app-table__sort-link--ascending:before,
|
83
|
+
.app-table__sort-link--descending:before {
|
86
84
|
content: none;
|
87
85
|
}
|
88
86
|
|
89
|
-
.app-table__sort-link--ascending
|
87
|
+
.app-table__sort-link--ascending:after {
|
90
88
|
content: "";
|
91
89
|
position: absolute;
|
92
90
|
top: $sort-link-arrow-spacing;
|
@@ -96,7 +94,7 @@ $table-row-even-background-colour: govuk-colour("light-grey", $legacy: "grey-4")
|
|
96
94
|
@include govuk-shape-arrow($direction: up, $base: $sort-link-arrow-size, $display: inline-block);
|
97
95
|
}
|
98
96
|
|
99
|
-
.app-table__sort-link--descending
|
97
|
+
.app-table__sort-link--descending:after {
|
100
98
|
content: "";
|
101
99
|
position: absolute;
|
102
100
|
top: $sort-link-arrow-spacing;
|
@@ -105,7 +103,6 @@ $table-row-even-background-colour: govuk-colour("light-grey", $legacy: "grey-4")
|
|
105
103
|
|
106
104
|
@include govuk-shape-arrow($direction: down, $base: $sort-link-arrow-size, $display: inline-block);
|
107
105
|
}
|
108
|
-
|
109
106
|
}
|
110
107
|
|
111
108
|
.govuk-table__row {
|
@@ -11,25 +11,21 @@
|
|
11
11
|
// We have some styles within GOVUK (.content-block) which can leak into the list styles for this component.
|
12
12
|
// These styles are defined in Static: https://github.com/alphagov/static/blob/a815620cada7ea1c65428c1c3b3ac4dbe28977bf/app/assets/stylesheets/helpers/_text.scss
|
13
13
|
// This sets more specific selectors so those unwanted styles are overidden
|
14
|
-
//
|
15
|
-
// sass-lint:disable no-qualifying-elements
|
16
|
-
ul.govuk-tabs__list {
|
14
|
+
ul.govuk-tabs__list { // stylelint-disable-line selector-no-qualifying-type
|
17
15
|
margin: 0;
|
18
16
|
padding: 0;
|
19
17
|
list-style: none;
|
20
18
|
@include govuk-responsive-margin(6, "bottom");
|
21
19
|
}
|
22
20
|
|
23
|
-
li.govuk-tabs__list-item {
|
21
|
+
li.govuk-tabs__list-item { // stylelint-disable-line selector-no-qualifying-type
|
24
22
|
margin-left: govuk-spacing(5);
|
25
23
|
}
|
26
24
|
|
27
|
-
.js-enabled {
|
25
|
+
.js-enabled { // stylelint-disable-line no-duplicate-selectors
|
28
26
|
@include govuk-media-query($from: tablet) {
|
29
|
-
ul.govuk-tabs__list {
|
27
|
+
ul.govuk-tabs__list { // stylelint-disable-line selector-no-qualifying-type
|
30
28
|
margin-bottom: 0;
|
31
29
|
}
|
32
30
|
}
|
33
31
|
}
|
34
|
-
// scss-lint:enable QualifyingElement
|
35
|
-
// sass-lint:enable no-qualifying-elements
|
@@ -1,7 +1,6 @@
|
|
1
1
|
@import "govuk/components/button/button";
|
2
2
|
|
3
|
-
//
|
4
|
-
// sass-lint:disable placeholder-in-extend
|
3
|
+
// stylelint-disable scss/at-extend-no-missing-placeholder
|
5
4
|
.gem-c-govspeak {
|
6
5
|
.gem-c-button {
|
7
6
|
@extend .govuk-button;
|
@@ -11,5 +10,3 @@
|
|
11
10
|
@extend .govuk-button--start;
|
12
11
|
}
|
13
12
|
}
|
14
|
-
// sass-lint:enable placeholder-in-extend
|
15
|
-
// scss-lint:enable PlaceholderInExtend
|
@@ -9,6 +9,8 @@
|
|
9
9
|
// adapted from magna-charta example stylesheet
|
10
10
|
// https://github.com/alphagov/magna-charta/blob/master/demo/stylesheets/magna-charta.css
|
11
11
|
|
12
|
+
// stylelint-disable max-nesting-depth
|
13
|
+
|
12
14
|
.gem-c-govspeak {
|
13
15
|
// DEFAULT CHART STYLES
|
14
16
|
|
@@ -27,8 +29,9 @@
|
|
27
29
|
$chart-border: govuk-colour("white"); // Chart border colour
|
28
30
|
$key-border: govuk-colour("white"); // Key border colour
|
29
31
|
$bar-colours: govuk-colour("blue"), govuk-colour("turquoise"), govuk-colour("green"), govuk-colour("light-green"), govuk-colour("yellow"), govuk-colour("orange"), govuk-colour("red"), govuk-colour("bright-purple", $legacy: "bright-red");
|
30
|
-
$bar-
|
31
|
-
$bar-
|
32
|
+
$bar-text-colours: govuk-colour("white"), govuk-colour("black"), govuk-colour("white"), govuk-colour("black"), govuk-colour("black"), govuk-colour("black"), govuk-colour("white"), govuk-colour("white");
|
33
|
+
$bar-cell-colour: govuk-colour("black");
|
34
|
+
$bar-outdented-colour: govuk-colour("black");
|
32
35
|
|
33
36
|
// CHART STYLES
|
34
37
|
.mc-chart {
|
@@ -138,6 +141,7 @@
|
|
138
141
|
@for $i from 0 to length($bar-colours) {
|
139
142
|
.mc-bar-#{$i + 1} {
|
140
143
|
background-color: nth($bar-colours, $i + 1);
|
144
|
+
color: nth($bar-text-colours, $i + 1);
|
141
145
|
}
|
142
146
|
}
|
143
147
|
|
@@ -266,10 +270,6 @@
|
|
266
270
|
text-align: left;
|
267
271
|
}
|
268
272
|
|
269
|
-
.mc-chart.mc-negative .mc-td.mc-key-cell {
|
270
|
-
padding-right: 25px;
|
271
|
-
}
|
272
|
-
|
273
273
|
.mc-toggle-link {
|
274
274
|
display: block;
|
275
275
|
margin-top: 30px;
|
data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav.scss
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
// scss-lint:disable SelectorFormat
|
2
|
-
|
3
1
|
$grey-2: #bfc1c3;
|
4
2
|
$white: #ffffff;
|
5
3
|
$number-circle-size: 35px;
|
@@ -40,6 +38,7 @@ $stroke-width: 3px;
|
|
40
38
|
}
|
41
39
|
|
42
40
|
.gem-c-step-nav__step {
|
41
|
+
padding-left: 60px;
|
43
42
|
position: relative;
|
44
43
|
}
|
45
44
|
|
@@ -74,14 +73,9 @@ $stroke-width: 3px;
|
|
74
73
|
padding-bottom: 1em;
|
75
74
|
}
|
76
75
|
|
77
|
-
.gem-c-step-nav__step {
|
78
|
-
position: relative;
|
79
|
-
padding-left: 60px;
|
80
|
-
}
|
81
|
-
|
82
76
|
.gem-c-step-nav__title {
|
83
77
|
@include govuk-font(19, $weight: bold);
|
84
|
-
margin: 0 0 .5em
|
78
|
+
margin: 0 0 .5em;
|
85
79
|
padding: 0;
|
86
80
|
}
|
87
81
|
|
@@ -120,5 +114,3 @@ $stroke-width: 3px;
|
|
120
114
|
.gem-c-step-nav__circle-step-colon {
|
121
115
|
display: none;
|
122
116
|
}
|
123
|
-
|
124
|
-
// scss-lint:enable SelectorFormat
|
@@ -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.applications_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
|
@@ -83,8 +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,erb}"]
|
88
89
|
|
89
90
|
files.each do |file|
|
90
91
|
data = File.read(file)
|
@@ -0,0 +1,117 @@
|
|
1
|
+
module GovukPublishingComponents
|
2
|
+
class AuditApplications
|
3
|
+
attr_reader :data
|
4
|
+
|
5
|
+
def initialize(path, name)
|
6
|
+
@path = path
|
7
|
+
application_found = application_exists(path)
|
8
|
+
components_found = []
|
9
|
+
@gem_style_references = []
|
10
|
+
|
11
|
+
if application_found
|
12
|
+
templates = Dir["#{path}/app/views/**/*.erb"]
|
13
|
+
stylesheets = Dir["#{path}/app/assets/stylesheets/**/*.scss"]
|
14
|
+
javascripts = Dir["#{path}/app/assets/javascripts/**/*.js"]
|
15
|
+
|
16
|
+
find_components = /(?<=govuk_publishing_components\/components\/)[\/a-zA-Z_-]+(?=['"])/
|
17
|
+
|
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
|
+
|
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_-]+(?=['"])/
|
23
|
+
|
24
|
+
@find_all_javascripts = /\/\/[ ]*= require govuk_publishing_components\/all_components/
|
25
|
+
find_javascripts = /(?<=require govuk_publishing_components\/components\/)[a-zA-Z_-]+/
|
26
|
+
|
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") || []
|
31
|
+
|
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
|
38
|
+
|
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
|
+
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,
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def find_components(files, find, type)
|
74
|
+
components_found = []
|
75
|
+
|
76
|
+
files.each do |file|
|
77
|
+
src = File.read(file)
|
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"
|
83
|
+
end
|
84
|
+
|
85
|
+
components_found.flatten.uniq.sort
|
86
|
+
end
|
87
|
+
|
88
|
+
def find_match(find, src, type)
|
89
|
+
return %w[all] if src.match(@find_all_stylesheets) && type == "stylesheets"
|
90
|
+
return %w[all] if src.match(@find_all_print_stylesheets) && type == "print_stylesheets"
|
91
|
+
return %w[all] if src.match(@find_all_javascripts) && type == "javascripts"
|
92
|
+
|
93
|
+
matches = src.scan(find)
|
94
|
+
all_matches = []
|
95
|
+
matches.each do |match|
|
96
|
+
all_matches << clean_file_name(match.tr('[])\'"', ""))
|
97
|
+
end
|
98
|
+
|
99
|
+
all_matches
|
100
|
+
end
|
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
|
+
|
109
|
+
def clean_file_name(name)
|
110
|
+
name.tr("_-", " ").strip
|
111
|
+
end
|
112
|
+
|
113
|
+
def application_exists(directory)
|
114
|
+
File.directory?(directory)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|