govuk_navigation_helpers 8.2.2 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1816b8fab85ec2930fcf6753fa2e004fe569dd4
4
- data.tar.gz: 508d10c31eaf9a154fe4438cb1fb8dde4c8b00cd
3
+ metadata.gz: 6f8820828e39de3f4448cd51867ab33863f33171
4
+ data.tar.gz: ccc32400f50f9c8b52942861d56baea10cd5e745
5
5
  SHA512:
6
- metadata.gz: d5ae309f9940333528a216fee3115c4bbcd7bb05767ffcf864221a958b87aae9c4668b178e9756094c99ca896a2fc722420419b2fd04808569f0809602261097
7
- data.tar.gz: 4e494d267493f9f33db3fe46abe91685822d763a4acaad9bc18969a4b8f078042666c8a196ec47590b0c2f0a93b30969cdf864484ccd5a8f3ac372609082a66a
6
+ metadata.gz: 8b81687bb032f4b4811572a6b2c52339acfd28f635faa49ecd327f1fc17a36dec0277383ce238ca04c4e330d32e7650eb5c29b9f5223f7dbc27c9cf9f1cb717a
7
+ data.tar.gz: 3bbc43ff6e987c2a4295d9f249ba8fae74a704363c2a7b9157aa8bc60dbc89e804ea22f0591abc87d13d5e529bda9a45d0636da0ca3d0ee1e3b27f9cf60ebf6d
@@ -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
@@ -4,7 +4,7 @@ require "gem_publisher"
4
4
 
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
 
7
- task default: [:spec, :lint]
7
+ task default: %i(spec lint)
8
8
 
9
9
  desc "Publish gem to RubyGems"
10
10
  task :publish_gem do |_t|
@@ -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", "~> 1.2.1"
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/tasklist_content"
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
@@ -19,8 +19,7 @@ module GovukNavigationHelpers
19
19
  end
20
20
 
21
21
  class NoStatsd
22
- def increment(*)
23
- end
22
+ def increment(*); end
24
23
 
25
24
  def time(*)
26
25
  yield
@@ -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 == 0
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 }