slimmer 3.16.0 → 3.17.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.
@@ -5,7 +5,7 @@ module Slimmer::Processors
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def filter(src, dest)
|
8
|
-
if @artefact and (list = dest.at_css('
|
8
|
+
if @artefact and (list = dest.at_css('#global-breadcrumb ol'))
|
9
9
|
if (section = @artefact.primary_section)
|
10
10
|
sections = recurse_sections(section)
|
11
11
|
current = sections.pop
|
data/lib/slimmer/version.rb
CHANGED
@@ -11,8 +11,8 @@
|
|
11
11
|
<body>
|
12
12
|
<header id="global-header"><h1>I AM A TITLE</h1></header>
|
13
13
|
|
14
|
-
<div id="global-
|
15
|
-
<
|
14
|
+
<div id="global-breadcrumb" class="header-context">
|
15
|
+
<ol role="navigation"><li>MySite</li></ol>
|
16
16
|
</div>
|
17
17
|
|
18
18
|
<div id="wrapper" class="group">
|
@@ -24,7 +24,29 @@ class SectionInserterTest < MiniTest::Unit::TestCase
|
|
24
24
|
template = as_nokogiri %{
|
25
25
|
<html>
|
26
26
|
<body>
|
27
|
-
<div class="header-context">
|
27
|
+
<div id="global-breadcrumb" class="header-context">
|
28
|
+
<ol role="navigation">
|
29
|
+
<li><a href="/">Home</a></li>
|
30
|
+
</ol>
|
31
|
+
</div>
|
32
|
+
</body>
|
33
|
+
</html>
|
34
|
+
}
|
35
|
+
|
36
|
+
Slimmer::Processors::SectionInserter.new(artefact).filter(:any_source, template)
|
37
|
+
list = template.at_css("#global-breadcrumb ol")
|
38
|
+
assert_in list, "li:nth-child(1)", %{<a href="/">Home</a>}
|
39
|
+
assert_in list, "li:nth-child(2)", %{<strong><a href="https://www.test.gov.uk/browse/business">Business</a></strong>}
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_should_add_section_link_with_old_version_of_markup
|
43
|
+
artefact = create_artefact("something",
|
44
|
+
"section_slug" => "business")
|
45
|
+
|
46
|
+
template = as_nokogiri %{
|
47
|
+
<html>
|
48
|
+
<body>
|
49
|
+
<div id="global-breadcrumb" class="header-context">
|
28
50
|
<nav role="navigation">
|
29
51
|
<ol class="group">
|
30
52
|
<li><a href="/">Home</a></li>
|
@@ -36,7 +58,7 @@ class SectionInserterTest < MiniTest::Unit::TestCase
|
|
36
58
|
}
|
37
59
|
|
38
60
|
Slimmer::Processors::SectionInserter.new(artefact).filter(:any_source, template)
|
39
|
-
list = template.at_css("
|
61
|
+
list = template.at_css("#global-breadcrumb nav[role=navigation] ol")
|
40
62
|
assert_in list, "li:nth-child(1)", %{<a href="/">Home</a>}
|
41
63
|
assert_in list, "li:nth-child(2)", %{<strong><a href="https://www.test.gov.uk/browse/business">Business</a></strong>}
|
42
64
|
end
|
@@ -49,17 +71,15 @@ class SectionInserterTest < MiniTest::Unit::TestCase
|
|
49
71
|
template = as_nokogiri %{
|
50
72
|
<html>
|
51
73
|
<body>
|
52
|
-
<div class="header-context">
|
53
|
-
<
|
54
|
-
<ol class="group"><li><a href="/">Home</a></li></ol>
|
55
|
-
</nav>
|
74
|
+
<div id="global-breadcrumb" class="header-context">
|
75
|
+
<ol role="navigation"><li><a href="/">Home</a></li></ol>
|
56
76
|
</div>
|
57
77
|
</body>
|
58
78
|
</html>
|
59
79
|
}
|
60
80
|
|
61
81
|
Slimmer::Processors::SectionInserter.new(artefact).filter(:any_source, template)
|
62
|
-
list = template.at_css("
|
82
|
+
list = template.at_css("#global-breadcrumb ol")
|
63
83
|
assert_in list, "li:nth-child(1)", %{<a href="/">Home</a>}
|
64
84
|
assert_in list, "li:nth-child(2)", %{<a href="https://www.test.gov.uk/browse/business">Business</a>}
|
65
85
|
assert_in list, "li:nth-child(3)", %{<strong><a href="https://www.test.gov.uk/browse/business/employing-people">Employing people</a></strong>}
|
@@ -73,20 +93,18 @@ class SectionInserterTest < MiniTest::Unit::TestCase
|
|
73
93
|
template = as_nokogiri %{
|
74
94
|
<html>
|
75
95
|
<body>
|
76
|
-
<div class="header-context">
|
77
|
-
<
|
78
|
-
<
|
79
|
-
|
80
|
-
|
81
|
-
</ol>
|
82
|
-
</nav>
|
96
|
+
<div id="global-breadcrumb" class="header-context">
|
97
|
+
<ol role="navigation">
|
98
|
+
<li><a href="/">Home</a></li>
|
99
|
+
<li><a href="/browse">All Sections</a></li>
|
100
|
+
</ol>
|
83
101
|
</div>
|
84
102
|
</body>
|
85
103
|
</html>
|
86
104
|
}
|
87
105
|
|
88
106
|
Slimmer::Processors::SectionInserter.new(artefact).filter(:any_source, template)
|
89
|
-
list = template.at_css("
|
107
|
+
list = template.at_css("#global-breadcrumb ol")
|
90
108
|
assert_in list, "li:nth-child(1)", %{<a href="/">Home</a>}
|
91
109
|
assert_in list, "li:nth-child(2)", %{<a href="/browse">All Sections</a>}
|
92
110
|
assert_in list, "li:nth-child(3)", %{<a href="https://www.test.gov.uk/browse/business">Business</a>}
|
@@ -94,7 +112,9 @@ class SectionInserterTest < MiniTest::Unit::TestCase
|
|
94
112
|
end
|
95
113
|
|
96
114
|
def test_should_do_nothing_if_navigation_not_in_template
|
97
|
-
artefact = create_artefact("something"
|
115
|
+
artefact = create_artefact("something",
|
116
|
+
"section_slug" => "business",
|
117
|
+
"subsection_slug" => "employing-people")
|
98
118
|
template = as_nokogiri %{
|
99
119
|
<html>
|
100
120
|
<body>
|
@@ -103,24 +123,22 @@ class SectionInserterTest < MiniTest::Unit::TestCase
|
|
103
123
|
}
|
104
124
|
|
105
125
|
Slimmer::Processors::SectionInserter.new(artefact).filter(:any_source, template)
|
106
|
-
assert_not_in template, "
|
126
|
+
assert_not_in template, "ol[role=navigation]"
|
107
127
|
end
|
108
128
|
|
109
129
|
def test_should_do_nothing_with_no_artefact
|
110
130
|
template = as_nokogiri %{
|
111
131
|
<html>
|
112
132
|
<body>
|
113
|
-
<div class="header-context">
|
114
|
-
<
|
115
|
-
<ol class="group"><li><a href="/">Home</a></li></ol>
|
116
|
-
</nav>
|
133
|
+
<div id="global-breadcrumb" class="header-context">
|
134
|
+
<ol role="navigation"><li><a href="/">Home</a></li></ol>
|
117
135
|
</div>
|
118
136
|
</body>
|
119
137
|
</html>
|
120
138
|
}
|
121
139
|
|
122
140
|
Slimmer::Processors::SectionInserter.new(nil).filter(:any_source, template)
|
123
|
-
list = template.at_css("
|
141
|
+
list = template.at_css("#global-breadcrumb ol")
|
124
142
|
assert_in list, "li:nth-child(1)", %{<a href="/">Home</a>}
|
125
143
|
assert_not_in list, "li:nth-child(2)"
|
126
144
|
end
|
@@ -131,19 +149,17 @@ class SectionInserterTest < MiniTest::Unit::TestCase
|
|
131
149
|
template = as_nokogiri %{
|
132
150
|
<html>
|
133
151
|
<body>
|
134
|
-
<div class="header-context">
|
135
|
-
<
|
136
|
-
<
|
137
|
-
|
138
|
-
</ol>
|
139
|
-
</nav>
|
152
|
+
<div id="global-breadcrumb" class="header-context">
|
153
|
+
<ol role="navigation">
|
154
|
+
<li><a href="/">Home</a></li>
|
155
|
+
</ol>
|
140
156
|
</div>
|
141
157
|
</body>
|
142
158
|
</html>
|
143
159
|
}
|
144
160
|
|
145
161
|
Slimmer::Processors::SectionInserter.new(artefact).filter(:any_source, template)
|
146
|
-
list = template.at_css("
|
162
|
+
list = template.at_css("#global-breadcrumb ol")
|
147
163
|
assert_in list, "li:nth-child(1)", %{<a href="/">Home</a>}
|
148
164
|
end
|
149
165
|
|
@@ -155,20 +171,18 @@ class SectionInserterTest < MiniTest::Unit::TestCase
|
|
155
171
|
template = as_nokogiri %{
|
156
172
|
<html>
|
157
173
|
<body>
|
158
|
-
<div class="header-context">
|
159
|
-
<
|
160
|
-
<
|
161
|
-
|
162
|
-
|
163
|
-
</ol>
|
164
|
-
</nav>
|
174
|
+
<div id="global-breadcrumb" class="header-context">
|
175
|
+
<ol role="navigation">
|
176
|
+
<li><a href="/">Home</a></li>
|
177
|
+
<li><a href="/browse">All Sections</a></li>
|
178
|
+
</ol>
|
165
179
|
</div>
|
166
180
|
</body>
|
167
181
|
</html>
|
168
182
|
}
|
169
183
|
|
170
184
|
Slimmer::Processors::SectionInserter.new(artefact).filter(:any_source, template)
|
171
|
-
list = template.at_css("
|
185
|
+
list = template.at_css("#global-breadcrumb ol")
|
172
186
|
assert_in list, "li:nth-child(1)", %{<a href="/">Home</a>}
|
173
187
|
assert_in list, "li:nth-child(2)", %{<a href="/browse">All Sections</a>}
|
174
188
|
assert_in list, "li:nth-child(3)", %{<a href="https://www.test.gov.uk/browse/business">Business</a>}
|
data/test/typical_usage_test.rb
CHANGED
@@ -130,7 +130,7 @@ module TypicalUsage
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def test_should_insert_section_links_into_the_navigation
|
133
|
-
assert_rendered_in_template "
|
133
|
+
assert_rendered_in_template "#global-breadcrumb ol li a[href='https://www.test.gov.uk/browse/this-section']", "This section"
|
134
134
|
end
|
135
135
|
|
136
136
|
def test_should_add_logo_classes_to_wrapper
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: slimmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 3.
|
5
|
+
version: 3.17.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ben Griffiths
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-06-18 00:00:00 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: nokogiri
|
@@ -181,60 +181,60 @@ files:
|
|
181
181
|
- README.md
|
182
182
|
- CHANGELOG.md
|
183
183
|
- lib/tasks/slimmer.rake
|
184
|
-
- lib/slimmer.rb
|
185
|
-
- lib/slimmer/skin.rb
|
186
|
-
- lib/slimmer/railtie.rb
|
187
|
-
- lib/slimmer/template.rb
|
188
|
-
- lib/slimmer/test_template.rb
|
189
|
-
- lib/slimmer/test.rb
|
190
|
-
- lib/slimmer/app.rb
|
191
|
-
- lib/slimmer/processors/logo_class_inserter.rb
|
192
|
-
- lib/slimmer/processors/search_index_setter.rb
|
184
|
+
- lib/slimmer/version.rb
|
193
185
|
- lib/slimmer/processors/body_class_copier.rb
|
194
|
-
- lib/slimmer/processors/tag_mover.rb
|
195
|
-
- lib/slimmer/processors/search_path_setter.rb
|
196
|
-
- lib/slimmer/processors/title_inserter.rb
|
197
186
|
- lib/slimmer/processors/google_analytics_configurator.rb
|
198
|
-
- lib/slimmer/processors/navigation_mover.rb
|
199
|
-
- lib/slimmer/processors/conditional_comment_mover.rb
|
200
187
|
- lib/slimmer/processors/related_items_inserter.rb
|
201
|
-
- lib/slimmer/processors/header_context_inserter.rb
|
202
188
|
- lib/slimmer/processors/body_inserter.rb
|
189
|
+
- lib/slimmer/processors/logo_class_inserter.rb
|
203
190
|
- lib/slimmer/processors/report_a_problem_inserter.rb
|
204
|
-
- lib/slimmer/processors/
|
191
|
+
- lib/slimmer/processors/footer_remover.rb
|
205
192
|
- lib/slimmer/processors/campaign_notification_inserter.rb
|
193
|
+
- lib/slimmer/processors/conditional_comment_mover.rb
|
206
194
|
- lib/slimmer/processors/beta_notice_inserter.rb
|
207
195
|
- lib/slimmer/processors/section_inserter.rb
|
208
|
-
- lib/slimmer/processors/
|
209
|
-
- lib/slimmer/
|
210
|
-
- lib/slimmer/
|
196
|
+
- lib/slimmer/processors/search_path_setter.rb
|
197
|
+
- lib/slimmer/processors/navigation_mover.rb
|
198
|
+
- lib/slimmer/processors/tag_mover.rb
|
199
|
+
- lib/slimmer/processors/title_inserter.rb
|
200
|
+
- lib/slimmer/processors/search_index_setter.rb
|
201
|
+
- lib/slimmer/processors/header_context_inserter.rb
|
202
|
+
- lib/slimmer/processors/meta_viewport_remover.rb
|
203
|
+
- lib/slimmer/template.rb
|
204
|
+
- lib/slimmer/railtie.rb
|
205
|
+
- lib/slimmer/test.rb
|
211
206
|
- lib/slimmer/artefact.rb
|
207
|
+
- lib/slimmer/skin.rb
|
208
|
+
- lib/slimmer/app.rb
|
209
|
+
- lib/slimmer/headers.rb
|
210
|
+
- lib/slimmer/test_template.rb
|
211
|
+
- lib/slimmer.rb
|
212
212
|
- Rakefile
|
213
|
-
- test/
|
213
|
+
- test/processors/meta_viewport_remover_test.rb
|
214
|
+
- test/processors/related_items_inserter_test.rb
|
215
|
+
- test/processors/report_a_problem_inserter_test.rb
|
216
|
+
- test/processors/section_inserter_test.rb
|
217
|
+
- test/processors/google_analytics_test.rb
|
218
|
+
- test/processors/search_index_setter_test.rb
|
219
|
+
- test/processors/header_context_inserter_test.rb
|
220
|
+
- test/processors/body_inserter_test.rb
|
221
|
+
- test/processors/logo_class_inserter_test.rb
|
222
|
+
- test/processors/campaign_notification_inserter_test.rb
|
223
|
+
- test/processors/navigation_mover_test.rb
|
224
|
+
- test/processors/search_path_setter_test.rb
|
214
225
|
- test/artefact_test.rb
|
215
|
-
- test/
|
216
|
-
- test/
|
226
|
+
- test/skin_test.rb
|
227
|
+
- test/headers_test.rb
|
228
|
+
- test/test_template_dependency_on_static_test.rb
|
229
|
+
- test/typical_usage_test.rb
|
217
230
|
- test/fixtures/500.html.erb
|
218
231
|
- test/fixtures/404.html.erb
|
219
232
|
- test/fixtures/proposition_menu.html.erb
|
220
233
|
- test/fixtures/beta_notice.html.erb
|
221
|
-
- test/fixtures/wrapper.html.erb
|
222
234
|
- test/fixtures/report_a_problem.raw.html.erb
|
223
|
-
- test/
|
224
|
-
- test/
|
225
|
-
- test/
|
226
|
-
- test/processors/logo_class_inserter_test.rb
|
227
|
-
- test/processors/navigation_mover_test.rb
|
228
|
-
- test/processors/search_index_setter_test.rb
|
229
|
-
- test/processors/google_analytics_test.rb
|
230
|
-
- test/processors/report_a_problem_inserter_test.rb
|
231
|
-
- test/processors/body_inserter_test.rb
|
232
|
-
- test/processors/search_path_setter_test.rb
|
233
|
-
- test/processors/section_inserter_test.rb
|
234
|
-
- test/processors/related_items_inserter_test.rb
|
235
|
-
- test/processors/header_context_inserter_test.rb
|
236
|
-
- test/typical_usage_test.rb
|
237
|
-
- test/test_template_dependency_on_static_test.rb
|
235
|
+
- test/fixtures/campaign.html.erb
|
236
|
+
- test/fixtures/related.raw.html.erb
|
237
|
+
- test/fixtures/wrapper.html.erb
|
238
238
|
- test/test_helper.rb
|
239
239
|
- bin/render_slimmer_error
|
240
240
|
homepage: http://github.com/alphagov/slimmer
|
@@ -250,7 +250,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
250
250
|
requirements:
|
251
251
|
- - ">="
|
252
252
|
- !ruby/object:Gem::Version
|
253
|
-
hash:
|
253
|
+
hash: 4605535357493844384
|
254
254
|
segments:
|
255
255
|
- 0
|
256
256
|
version: "0"
|
@@ -259,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
259
|
requirements:
|
260
260
|
- - ">="
|
261
261
|
- !ruby/object:Gem::Version
|
262
|
-
hash:
|
262
|
+
hash: 4605535357493844384
|
263
263
|
segments:
|
264
264
|
- 0
|
265
265
|
version: "0"
|
@@ -271,29 +271,29 @@ signing_key:
|
|
271
271
|
specification_version: 3
|
272
272
|
summary: Thinner than the skinner
|
273
273
|
test_files:
|
274
|
-
- test/
|
274
|
+
- test/processors/meta_viewport_remover_test.rb
|
275
|
+
- test/processors/related_items_inserter_test.rb
|
276
|
+
- test/processors/report_a_problem_inserter_test.rb
|
277
|
+
- test/processors/section_inserter_test.rb
|
278
|
+
- test/processors/google_analytics_test.rb
|
279
|
+
- test/processors/search_index_setter_test.rb
|
280
|
+
- test/processors/header_context_inserter_test.rb
|
281
|
+
- test/processors/body_inserter_test.rb
|
282
|
+
- test/processors/logo_class_inserter_test.rb
|
283
|
+
- test/processors/campaign_notification_inserter_test.rb
|
284
|
+
- test/processors/navigation_mover_test.rb
|
285
|
+
- test/processors/search_path_setter_test.rb
|
275
286
|
- test/artefact_test.rb
|
276
|
-
- test/
|
277
|
-
- test/
|
287
|
+
- test/skin_test.rb
|
288
|
+
- test/headers_test.rb
|
289
|
+
- test/test_template_dependency_on_static_test.rb
|
290
|
+
- test/typical_usage_test.rb
|
278
291
|
- test/fixtures/500.html.erb
|
279
292
|
- test/fixtures/404.html.erb
|
280
293
|
- test/fixtures/proposition_menu.html.erb
|
281
294
|
- test/fixtures/beta_notice.html.erb
|
282
|
-
- test/fixtures/wrapper.html.erb
|
283
295
|
- test/fixtures/report_a_problem.raw.html.erb
|
284
|
-
- test/
|
285
|
-
- test/
|
286
|
-
- test/
|
287
|
-
- test/processors/logo_class_inserter_test.rb
|
288
|
-
- test/processors/navigation_mover_test.rb
|
289
|
-
- test/processors/search_index_setter_test.rb
|
290
|
-
- test/processors/google_analytics_test.rb
|
291
|
-
- test/processors/report_a_problem_inserter_test.rb
|
292
|
-
- test/processors/body_inserter_test.rb
|
293
|
-
- test/processors/search_path_setter_test.rb
|
294
|
-
- test/processors/section_inserter_test.rb
|
295
|
-
- test/processors/related_items_inserter_test.rb
|
296
|
-
- test/processors/header_context_inserter_test.rb
|
297
|
-
- test/typical_usage_test.rb
|
298
|
-
- test/test_template_dependency_on_static_test.rb
|
296
|
+
- test/fixtures/campaign.html.erb
|
297
|
+
- test/fixtures/related.raw.html.erb
|
298
|
+
- test/fixtures/wrapper.html.erb
|
299
299
|
- test/test_helper.rb
|