govuk_navigation_helpers 8.2.2 → 9.0.0
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/CHANGELOG.md +5 -0
- data/Rakefile +1 -1
- data/config/step_navs/learn-to-drive-a-car.json +248 -0
- data/govuk_navigation_helpers.gemspec +8 -7
- data/lib/govuk_navigation_helpers.rb +1 -2
- data/lib/govuk_navigation_helpers/configuration.rb +1 -2
- data/lib/govuk_navigation_helpers/step_nav_content.rb +107 -0
- data/lib/govuk_navigation_helpers/taxon_breadcrumbs.rb +3 -2
- data/lib/govuk_navigation_helpers/version.rb +1 -1
- data/spec/related_navigation_sidebar_spec.rb +6 -12
- data/spec/{tasklist_content_spec.rb → step_nav_content_spec.rb} +25 -25
- data/spec/taxon_breadcrumbs_spec.rb +3 -3
- metadata +43 -46
- data/config/tasklists/learn-to-drive-a-car.json +0 -261
- data/lib/govuk_navigation_helpers/current_tasklist_ab_test.rb +0 -65
- data/lib/govuk_navigation_helpers/tasklist_content.rb +0 -118
- data/spec/current_tasklist_ab_test_spec.rb +0 -64
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f8820828e39de3f4448cd51867ab33863f33171
|
4
|
+
data.tar.gz: ccc32400f50f9c8b52942861d56baea10cd5e745
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b81687bb032f4b4811572a6b2c52339acfd28f635faa49ecd327f1fc17a36dec0277383ce238ca04c4e330d32e7650eb5c29b9f5223f7dbc27c9cf9f1cb717a
|
7
|
+
data.tar.gz: 3bbc43ff6e987c2a4295d9f249ba8fae74a704363c2a7b9157aa8bc60dbc89e804ea22f0591abc87d13d5e529bda9a45d0636da0ca3d0ee1e3b27f9cf60ebf6d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
|
+
## 9.0.0
|
4
|
+
* Task lists are now called "step by step navigation". Things have been renamed to support this
|
5
|
+
* The (now) step nav component has an updated data format. Updated /learn-to-drive-a-car to support this
|
6
|
+
* Remove tasklist AB test code as we don't currently need to use this.
|
7
|
+
|
3
8
|
## 8.2.2
|
4
9
|
* Remove get-a-divorce and end-a-civil-partnership content. The schema is changing and these aren't live at the moment
|
5
10
|
* Update secondary content list for learn-to-drive-a-car after performance analysis on which nav works better for these pages.
|
data/Rakefile
CHANGED
@@ -0,0 +1,248 @@
|
|
1
|
+
{
|
2
|
+
"title": "Learn to drive a car: step by step",
|
3
|
+
"base_path": "/learn-to-drive-a-car",
|
4
|
+
"description": "<p>Check what you need to do to learn to drive.</p>",
|
5
|
+
"links": {
|
6
|
+
"breadcrumbs": [
|
7
|
+
{ "title": "Home", "url": "/" },
|
8
|
+
{ "title": "Driving and transport", "url": "/browse/driving"},
|
9
|
+
{ "title": "Learning to drive", "url": "/browse/driving/learning-to-drive"}
|
10
|
+
]
|
11
|
+
},
|
12
|
+
"related_paths": [
|
13
|
+
"/apply-for-your-full-driving-licence",
|
14
|
+
"/automatic-driving-licence-to-manual",
|
15
|
+
"/complain-about-a-driving-instructor",
|
16
|
+
"/driving-licence-fees",
|
17
|
+
"/driving-test-cost",
|
18
|
+
"/dvlaforms",
|
19
|
+
"/find-theory-test-pass-number",
|
20
|
+
"/government/publications/application-for-refunding-out-of-pocket-expenses",
|
21
|
+
"/government/publications/drivers-record-for-learner-drivers",
|
22
|
+
"/government/publications/driving-instructor-grades-explained",
|
23
|
+
"/government/publications/know-your-traffic-signs",
|
24
|
+
"/government/publications/l-plate-size-rules",
|
25
|
+
"/guidance/rules-for-observing-driving-tests",
|
26
|
+
"/report-an-illegal-driving-instructor",
|
27
|
+
"/report-driving-test-impersonation",
|
28
|
+
"/track-your-driving-licence-application",
|
29
|
+
"/driving-lessons-learning-to-drive/practising-with-family-or-friends",
|
30
|
+
"/driving-lessons-learning-to-drive/taking-driving-lessons",
|
31
|
+
"/driving-lessons-learning-to-drive/using-l-and-p-plates",
|
32
|
+
"/driving-test",
|
33
|
+
"/driving-test/changes-december-2017",
|
34
|
+
"/driving-test/disability-health-condition-or-learning-difficulty",
|
35
|
+
"/driving-test/driving-test-faults-result",
|
36
|
+
"/driving-test/test-cancelled-bad-weather",
|
37
|
+
"/driving-test/using-your-own-car",
|
38
|
+
"/driving-test/what-happens-during-test",
|
39
|
+
"/pass-plus/apply-for-a-pass-plus-certificate",
|
40
|
+
"/pass-plus/booking-pass-plus",
|
41
|
+
"/pass-plus/car-insurance-discounts",
|
42
|
+
"/pass-plus/local-councils-offering-discounts",
|
43
|
+
"/pass-plus/how-pass-plus-training-works",
|
44
|
+
"/theory-test",
|
45
|
+
"/theory-test/hazard-perception-test",
|
46
|
+
"/theory-test/if-you-have-safe-road-user-award",
|
47
|
+
"/theory-test/multiple-choice-questions",
|
48
|
+
"/theory-test/pass-mark-and-result",
|
49
|
+
"/theory-test/reading-difficulty-disability-or-health-condition"
|
50
|
+
],
|
51
|
+
"step_by_step_nav": {
|
52
|
+
"steps": [
|
53
|
+
{
|
54
|
+
"title": "Check you're allowed to drive",
|
55
|
+
"contents": [
|
56
|
+
{
|
57
|
+
"type": "paragraph",
|
58
|
+
"text": "Most people can start learning to drive when they’re 17."
|
59
|
+
},
|
60
|
+
{
|
61
|
+
"type": "list",
|
62
|
+
"style": "required",
|
63
|
+
"contents": [
|
64
|
+
{
|
65
|
+
"href": "/vehicles-can-drive",
|
66
|
+
"text": "Check what age you can drive"
|
67
|
+
},
|
68
|
+
{
|
69
|
+
"href": "/legal-obligations-drivers-riders",
|
70
|
+
"text": "Requirements for driving legally"
|
71
|
+
},
|
72
|
+
{
|
73
|
+
"href": "/driving-eyesight-rules",
|
74
|
+
"text": "Driving eyesight rules"
|
75
|
+
}
|
76
|
+
]
|
77
|
+
}
|
78
|
+
]
|
79
|
+
},
|
80
|
+
{
|
81
|
+
"title": "Get a provisional driving licence",
|
82
|
+
"contents": [
|
83
|
+
{
|
84
|
+
"type": "list",
|
85
|
+
"style": "required",
|
86
|
+
"contents": [
|
87
|
+
{
|
88
|
+
"href": "/apply-first-provisional-driving-licence",
|
89
|
+
"text": "Apply for your first provisional driving licence",
|
90
|
+
"context": "£34"
|
91
|
+
}
|
92
|
+
]
|
93
|
+
}
|
94
|
+
]
|
95
|
+
},
|
96
|
+
{
|
97
|
+
"title": "Driving lessons and practice",
|
98
|
+
"contents": [
|
99
|
+
{
|
100
|
+
"type": "paragraph",
|
101
|
+
"text": "You need a provisional driving licence to take lessons or practice."
|
102
|
+
},
|
103
|
+
{
|
104
|
+
"type": "list",
|
105
|
+
"style": "required",
|
106
|
+
"contents": [
|
107
|
+
{
|
108
|
+
"href": "/guidance/the-highway-code",
|
109
|
+
"text": "The Highway Code"
|
110
|
+
},
|
111
|
+
{
|
112
|
+
"href": "/driving-lessons-learning-to-drive",
|
113
|
+
"text": "Taking driving lessons"
|
114
|
+
},
|
115
|
+
{
|
116
|
+
"href": "/find-driving-schools-and-lessons",
|
117
|
+
"text": "Find driving schools, lessons and instructors"
|
118
|
+
},
|
119
|
+
{
|
120
|
+
"href": "/government/publications/car-show-me-tell-me-vehicle-safety-questions",
|
121
|
+
"text": "Practise vehicle safety questions"
|
122
|
+
}
|
123
|
+
]
|
124
|
+
}
|
125
|
+
]
|
126
|
+
},
|
127
|
+
{
|
128
|
+
"title": "Prepare for your theory test",
|
129
|
+
"logic": "and",
|
130
|
+
"contents": [
|
131
|
+
{
|
132
|
+
"type": "list",
|
133
|
+
"style": "required",
|
134
|
+
"contents": [
|
135
|
+
{
|
136
|
+
"href": "/theory-test/revision-and-practice",
|
137
|
+
"text": "Theory test revision and practice"
|
138
|
+
},
|
139
|
+
{
|
140
|
+
"href": "/take-practice-theory-test",
|
141
|
+
"text": "Take a practice theory test"
|
142
|
+
},
|
143
|
+
{
|
144
|
+
"href": "https://www.safedrivingforlife.info/shop/product/official-dvsa-theory-test-kit-app-app",
|
145
|
+
"text": "Theory and hazard perception test app"
|
146
|
+
}
|
147
|
+
]
|
148
|
+
}
|
149
|
+
]
|
150
|
+
},
|
151
|
+
{
|
152
|
+
"title": "Book and manage your theory test",
|
153
|
+
"contents": [
|
154
|
+
{
|
155
|
+
"type": "paragraph",
|
156
|
+
"text": "You need a provisional driving licence to book your theory test."
|
157
|
+
},
|
158
|
+
{
|
159
|
+
"type": "list",
|
160
|
+
"style": "required",
|
161
|
+
"contents": [
|
162
|
+
{
|
163
|
+
"href": "/book-theory-test",
|
164
|
+
"text": "Book your theory test",
|
165
|
+
"context": "£23"
|
166
|
+
},
|
167
|
+
{
|
168
|
+
"href": "/theory-test/what-to-take",
|
169
|
+
"text": "What to take to your test"
|
170
|
+
},
|
171
|
+
{
|
172
|
+
"href": "/change-theory-test",
|
173
|
+
"text": "Change your theory test appointment"
|
174
|
+
},
|
175
|
+
{
|
176
|
+
"href": "/check-theory-test",
|
177
|
+
"text": "Check your theory test appointment details"
|
178
|
+
},
|
179
|
+
{
|
180
|
+
"href": "/cancel-theory-test",
|
181
|
+
"text": "Cancel your theory test"
|
182
|
+
}
|
183
|
+
]
|
184
|
+
}
|
185
|
+
]
|
186
|
+
},
|
187
|
+
{
|
188
|
+
"title": "Book and manage your driving test",
|
189
|
+
"contents": [
|
190
|
+
{
|
191
|
+
"type": "paragraph",
|
192
|
+
"text": "You must pass your theory test before you can book your driving test."
|
193
|
+
},
|
194
|
+
{
|
195
|
+
"type": "list",
|
196
|
+
"style": "required",
|
197
|
+
"contents": [
|
198
|
+
{
|
199
|
+
"href": "/book-driving-test",
|
200
|
+
"text": "Book your driving test",
|
201
|
+
"context": "£62"
|
202
|
+
},
|
203
|
+
{
|
204
|
+
"href": "/driving-test/what-to-take",
|
205
|
+
"text": "What to take to your test"
|
206
|
+
},
|
207
|
+
{
|
208
|
+
"href": "/change-driving-test",
|
209
|
+
"text": "Change your driving test appointment"
|
210
|
+
},
|
211
|
+
{
|
212
|
+
"href": "/check-driving-test",
|
213
|
+
"text": "Check your driving test appointment details"
|
214
|
+
},
|
215
|
+
{
|
216
|
+
"href": "/cancel-driving-test",
|
217
|
+
"text": "Cancel your driving test"
|
218
|
+
}
|
219
|
+
]
|
220
|
+
}
|
221
|
+
]
|
222
|
+
},
|
223
|
+
{
|
224
|
+
"title": "When you pass",
|
225
|
+
"contents": [
|
226
|
+
{
|
227
|
+
"type": "paragraph",
|
228
|
+
"text": "You can start driving as soon as you pass your driving test."
|
229
|
+
},
|
230
|
+
{
|
231
|
+
"type": "paragraph",
|
232
|
+
"text": "You must have an insurance policy that allows you to drive without supervision."
|
233
|
+
},
|
234
|
+
{
|
235
|
+
"type": "list",
|
236
|
+
"style": "required",
|
237
|
+
"contents": [
|
238
|
+
{
|
239
|
+
"href": "/pass-plus",
|
240
|
+
"text": "Find out about Pass Plus training courses"
|
241
|
+
}
|
242
|
+
]
|
243
|
+
}
|
244
|
+
]
|
245
|
+
}
|
246
|
+
]
|
247
|
+
}
|
248
|
+
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'govuk_navigation_helpers/version'
|
@@ -18,19 +19,19 @@ Gem::Specification.new do |spec|
|
|
18
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
20
|
spec.require_paths = ["lib"]
|
20
21
|
|
21
|
-
spec.add_runtime_dependency "gds-api-adapters", ">= 43.0"
|
22
|
-
spec.add_runtime_dependency 'govuk_ab_testing', '~> 2.4'
|
23
22
|
spec.add_runtime_dependency 'activesupport', '~> 5.1'
|
23
|
+
spec.add_runtime_dependency 'gds-api-adapters', '>= 43.0'
|
24
|
+
spec.add_runtime_dependency 'govuk_ab_testing', '~> 2.4'
|
24
25
|
|
25
26
|
spec.add_development_dependency "bundler", "~> 1.6"
|
26
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
-
spec.add_development_dependency "rspec", "~> 3.5"
|
28
27
|
spec.add_development_dependency "gem_publisher", "~> 1.5.0"
|
29
|
-
spec.add_development_dependency "govuk-lint", "~>
|
30
|
-
spec.add_development_dependency "pry-byebug", "~> 3.4"
|
31
|
-
spec.add_development_dependency "yard", "~> 0.9.12"
|
28
|
+
spec.add_development_dependency "govuk-lint", "~> 3.6.0"
|
32
29
|
spec.add_development_dependency "govuk_schemas", "~> 1.0"
|
30
|
+
spec.add_development_dependency "pry-byebug", "~> 3.4"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.5"
|
33
33
|
spec.add_development_dependency "webmock", "~> 2.3"
|
34
|
+
spec.add_development_dependency "yard", "~> 0.9.12"
|
34
35
|
|
35
36
|
spec.required_ruby_version = ">= 2.3.1"
|
36
37
|
end
|
@@ -13,8 +13,7 @@ require_relative "govuk_navigation_helpers/related_navigation_sidebar"
|
|
13
13
|
require_relative "govuk_navigation_helpers/rummager_taxonomy_sidebar_links"
|
14
14
|
require_relative "govuk_navigation_helpers/curated_taxonomy_sidebar_links"
|
15
15
|
|
16
|
-
require_relative "govuk_navigation_helpers/
|
17
|
-
require_relative "govuk_navigation_helpers/current_tasklist_ab_test"
|
16
|
+
require_relative "govuk_navigation_helpers/step_nav_content"
|
18
17
|
|
19
18
|
module GovukNavigationHelpers
|
20
19
|
class NavigationHelper
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module GovukNavigationHelpers
|
2
|
+
class StepNavContent
|
3
|
+
STEP_NAV_NAMES = %w(
|
4
|
+
learn-to-drive-a-car
|
5
|
+
).freeze
|
6
|
+
|
7
|
+
def self.current_step_nav(path)
|
8
|
+
STEP_NAV_NAMES.each do |step_nav_name|
|
9
|
+
step_nav = new(file_name: step_nav_name, path: path)
|
10
|
+
return step_nav if step_nav.current?
|
11
|
+
end
|
12
|
+
nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(file_name: nil, path: nil)
|
16
|
+
@file_name = file_name
|
17
|
+
@path = path
|
18
|
+
end
|
19
|
+
|
20
|
+
def title
|
21
|
+
parsed_file.dig(:title)
|
22
|
+
end
|
23
|
+
|
24
|
+
def base_path
|
25
|
+
parsed_file.dig(:base_path)
|
26
|
+
end
|
27
|
+
|
28
|
+
def step_nav
|
29
|
+
parsed_file.dig(:step_by_step_nav)
|
30
|
+
end
|
31
|
+
|
32
|
+
def skip_link
|
33
|
+
"##{steps.first[:title].downcase.tr(' ', '-')}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def primary_paths
|
37
|
+
primary_content.reject { |href|
|
38
|
+
href.start_with?('http')
|
39
|
+
}.select(&:present?)
|
40
|
+
end
|
41
|
+
|
42
|
+
def steps
|
43
|
+
step_nav.dig(:steps)
|
44
|
+
end
|
45
|
+
|
46
|
+
def related_paths
|
47
|
+
parsed_file.dig(:related_paths)
|
48
|
+
end
|
49
|
+
|
50
|
+
def set_current_step
|
51
|
+
set_step_as_active_if_current_page
|
52
|
+
end
|
53
|
+
|
54
|
+
def show_step_nav?
|
55
|
+
primary_paths.include?(path) ||
|
56
|
+
related_paths.include?(path)
|
57
|
+
end
|
58
|
+
|
59
|
+
def current?
|
60
|
+
primary_paths.include?(path) ||
|
61
|
+
related_paths.include?(path)
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
attr_reader :file_name, :file, :path
|
67
|
+
|
68
|
+
def set_step_as_active_if_current_page
|
69
|
+
steps.each_with_index do |step, step_index|
|
70
|
+
step[:contents].each do |content|
|
71
|
+
next unless content[:contents]
|
72
|
+
|
73
|
+
content[:contents].each do |link|
|
74
|
+
if link[:href] == path
|
75
|
+
link[:active] = true
|
76
|
+
step_nav[:show_step] = step_index + 1
|
77
|
+
step_nav[:highlight_step] = step_index + 1
|
78
|
+
return step_nav
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
step_nav
|
85
|
+
end
|
86
|
+
|
87
|
+
def primary_content
|
88
|
+
list_content = steps.flat_map do |step|
|
89
|
+
step[:contents].select { |item| item[:type] == "list" }
|
90
|
+
.flat_map { |item| item[:contents] }
|
91
|
+
end
|
92
|
+
|
93
|
+
list_content.map { |list_item| list_item[:href] }
|
94
|
+
end
|
95
|
+
|
96
|
+
def parsed_file
|
97
|
+
@parsed_file ||=
|
98
|
+
JSON.parse(
|
99
|
+
File.read(
|
100
|
+
File.join(File.dirname(__FILE__), "../../", "config", "step_navs", "#{file_name}.json")
|
101
|
+
)
|
102
|
+
).deep_symbolize_keys.tap do |json_file|
|
103
|
+
json_file[:step_by_step_nav].merge!(small: true, heading_level: 3)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -9,14 +9,15 @@ module GovukNavigationHelpers
|
|
9
9
|
{
|
10
10
|
title: parent.title,
|
11
11
|
url: parent.base_path,
|
12
|
-
is_page_parent: index
|
12
|
+
is_page_parent: index.zero?
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
16
16
|
ordered_parents << {
|
17
17
|
title: "Home",
|
18
18
|
url: "/",
|
19
|
-
is_page_parent: ordered_parents.empty?
|
19
|
+
is_page_parent: ordered_parents.empty?
|
20
|
+
}
|
20
21
|
|
21
22
|
ordered_breadcrumbs = ordered_parents.reverse
|
22
23
|
ordered_breadcrumbs << { title: content_item.title, is_current_page: true }
|