slimmer 3.14.0 → 3.15.0
Sign up to get free protection for your applications and to get access to all the features.
data/lib/slimmer.rb
CHANGED
@@ -34,6 +34,7 @@ module Slimmer
|
|
34
34
|
autoload :GoogleAnalyticsConfigurator, 'slimmer/processors/google_analytics_configurator'
|
35
35
|
autoload :HeaderContextInserter, 'slimmer/processors/header_context_inserter'
|
36
36
|
autoload :LogoClassInserter, 'slimmer/processors/logo_class_inserter'
|
37
|
+
autoload :NavigationMover, 'slimmer/processors/navigation_mover'
|
37
38
|
autoload :MetaViewportRemover, 'slimmer/processors/meta_viewport_remover'
|
38
39
|
autoload :RelatedItemsInserter, 'slimmer/processors/related_items_inserter'
|
39
40
|
autoload :ReportAProblemInserter, 'slimmer/processors/report_a_problem_inserter'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Slimmer::Processors::NavigationMover
|
2
|
+
|
3
|
+
def initialize(skin)
|
4
|
+
@skin = skin
|
5
|
+
end
|
6
|
+
|
7
|
+
def filter(src, dest)
|
8
|
+
proposition_header = src.at_css("#proposition-menu")
|
9
|
+
global_header = dest.at_css("#global-header")
|
10
|
+
if proposition_header && global_header
|
11
|
+
proposition_header.remove
|
12
|
+
|
13
|
+
global_header['class'] = [global_header['class'], 'with-proposition'].compact.join(' ')
|
14
|
+
|
15
|
+
header_block = Nokogiri::HTML.fragment(proposition_header_block)
|
16
|
+
header_block.at_css('.content') << proposition_header
|
17
|
+
|
18
|
+
global_header.at_css('.header-wrapper') << header_block
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def proposition_header_block
|
23
|
+
@proposition_header_block ||= @skin.template('proposition_menu')
|
24
|
+
end
|
25
|
+
end
|
data/lib/slimmer/skin.rb
CHANGED
@@ -117,6 +117,7 @@ module Slimmer
|
|
117
117
|
processors = [
|
118
118
|
Processors::TitleInserter.new(),
|
119
119
|
Processors::TagMover.new(),
|
120
|
+
Processors::NavigationMover.new(self),
|
120
121
|
Processors::ConditionalCommentMover.new(),
|
121
122
|
Processors::BodyInserter.new(options[:wrapper_id] || 'wrapper'),
|
122
123
|
Processors::BodyClassCopier.new,
|
data/lib/slimmer/version.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class NavigationMoverTest < MiniTest::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@proposition_header_block = File.read( File.dirname(__FILE__) + "/../fixtures/proposition_menu.html.erb" )
|
7
|
+
@skin = stub("Skin", :template => @proposition_header_block)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_should_add_proposition_menu
|
11
|
+
source = as_nokogiri %{
|
12
|
+
<html>
|
13
|
+
<body>
|
14
|
+
<div id="proposition-menu"></div>
|
15
|
+
</body>
|
16
|
+
</html>
|
17
|
+
}
|
18
|
+
template = as_nokogiri %{
|
19
|
+
<html>
|
20
|
+
<body>
|
21
|
+
<div id="global-header"><div class="header-wrapper"></div></div>
|
22
|
+
<div id="wrapper"></div>
|
23
|
+
</body>
|
24
|
+
</html>
|
25
|
+
}
|
26
|
+
|
27
|
+
Slimmer::Processors::NavigationMover.new(@skin).filter(source, template)
|
28
|
+
assert_in template, "div#global-header.with-proposition"
|
29
|
+
assert_in template, "div#global-header #proposition-menu a", "Navigation item"
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_should_not_add_proposition_menu_if_not_in_source
|
33
|
+
source = as_nokogiri %{
|
34
|
+
<html>
|
35
|
+
<body>
|
36
|
+
<div id="wrapper"></div>
|
37
|
+
</body>
|
38
|
+
</html>
|
39
|
+
}
|
40
|
+
template = as_nokogiri %{
|
41
|
+
<html>
|
42
|
+
<body>
|
43
|
+
<div id="global_header"><div class="header-wrapper"></div></div>
|
44
|
+
<div id="wrapper"></div>
|
45
|
+
</body>
|
46
|
+
</html>
|
47
|
+
}
|
48
|
+
|
49
|
+
@skin.expects(:template).never # Shouldn't fetch template when not inserting block
|
50
|
+
Slimmer::Processors::NavigationMover.new(@skin).filter(source, template)
|
51
|
+
assert_not_in template, "div#proposition_menu"
|
52
|
+
end
|
53
|
+
end
|
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.15.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-04-09 00:00:00 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: nokogiri
|
@@ -181,55 +181,58 @@ files:
|
|
181
181
|
- README.md
|
182
182
|
- CHANGELOG.md
|
183
183
|
- lib/tasks/slimmer.rake
|
184
|
-
- lib/slimmer
|
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
|
185
193
|
- lib/slimmer/processors/body_class_copier.rb
|
194
|
+
- lib/slimmer/processors/tag_mover.rb
|
195
|
+
- lib/slimmer/processors/title_inserter.rb
|
186
196
|
- lib/slimmer/processors/google_analytics_configurator.rb
|
197
|
+
- lib/slimmer/processors/navigation_mover.rb
|
198
|
+
- lib/slimmer/processors/conditional_comment_mover.rb
|
187
199
|
- lib/slimmer/processors/related_items_inserter.rb
|
200
|
+
- lib/slimmer/processors/header_context_inserter.rb
|
188
201
|
- lib/slimmer/processors/body_inserter.rb
|
189
|
-
- lib/slimmer/processors/logo_class_inserter.rb
|
190
202
|
- lib/slimmer/processors/report_a_problem_inserter.rb
|
191
|
-
- lib/slimmer/processors/
|
203
|
+
- lib/slimmer/processors/meta_viewport_remover.rb
|
192
204
|
- lib/slimmer/processors/campaign_notification_inserter.rb
|
193
|
-
- lib/slimmer/processors/conditional_comment_mover.rb
|
194
205
|
- lib/slimmer/processors/beta_notice_inserter.rb
|
195
206
|
- lib/slimmer/processors/section_inserter.rb
|
196
|
-
- lib/slimmer/processors/
|
197
|
-
- lib/slimmer/processors/title_inserter.rb
|
198
|
-
- lib/slimmer/processors/search_index_setter.rb
|
199
|
-
- lib/slimmer/processors/header_context_inserter.rb
|
200
|
-
- lib/slimmer/processors/meta_viewport_remover.rb
|
201
|
-
- lib/slimmer/template.rb
|
202
|
-
- lib/slimmer/railtie.rb
|
203
|
-
- lib/slimmer/test.rb
|
204
|
-
- lib/slimmer/artefact.rb
|
205
|
-
- lib/slimmer/skin.rb
|
206
|
-
- lib/slimmer/app.rb
|
207
|
+
- lib/slimmer/processors/footer_remover.rb
|
207
208
|
- lib/slimmer/headers.rb
|
208
|
-
- lib/slimmer/
|
209
|
-
- lib/slimmer.rb
|
209
|
+
- lib/slimmer/version.rb
|
210
|
+
- lib/slimmer/artefact.rb
|
210
211
|
- Rakefile
|
211
|
-
- test/processors/meta_viewport_remover_test.rb
|
212
|
-
- test/processors/related_items_inserter_test.rb
|
213
|
-
- test/processors/report_a_problem_inserter_test.rb
|
214
|
-
- test/processors/section_inserter_test.rb
|
215
|
-
- test/processors/google_analytics_test.rb
|
216
|
-
- test/processors/search_index_setter_test.rb
|
217
|
-
- test/processors/header_context_inserter_test.rb
|
218
|
-
- test/processors/body_inserter_test.rb
|
219
|
-
- test/processors/logo_class_inserter_test.rb
|
220
|
-
- test/processors/campaign_notification_inserter_test.rb
|
221
|
-
- test/artefact_test.rb
|
222
|
-
- test/skin_test.rb
|
223
212
|
- test/headers_test.rb
|
224
|
-
- test/
|
225
|
-
- test/
|
213
|
+
- test/artefact_test.rb
|
214
|
+
- test/fixtures/related.raw.html.erb
|
215
|
+
- test/fixtures/campaign.html.erb
|
226
216
|
- test/fixtures/500.html.erb
|
227
217
|
- test/fixtures/404.html.erb
|
218
|
+
- test/fixtures/proposition_menu.html.erb
|
228
219
|
- test/fixtures/beta_notice.html.erb
|
229
|
-
- test/fixtures/report_a_problem.raw.html.erb
|
230
|
-
- test/fixtures/campaign.html.erb
|
231
|
-
- test/fixtures/related.raw.html.erb
|
232
220
|
- test/fixtures/wrapper.html.erb
|
221
|
+
- test/fixtures/report_a_problem.raw.html.erb
|
222
|
+
- test/skin_test.rb
|
223
|
+
- test/processors/campaign_notification_inserter_test.rb
|
224
|
+
- test/processors/meta_viewport_remover_test.rb
|
225
|
+
- test/processors/logo_class_inserter_test.rb
|
226
|
+
- test/processors/navigation_mover_test.rb
|
227
|
+
- test/processors/search_index_setter_test.rb
|
228
|
+
- test/processors/google_analytics_test.rb
|
229
|
+
- test/processors/report_a_problem_inserter_test.rb
|
230
|
+
- test/processors/body_inserter_test.rb
|
231
|
+
- test/processors/section_inserter_test.rb
|
232
|
+
- test/processors/related_items_inserter_test.rb
|
233
|
+
- test/processors/header_context_inserter_test.rb
|
234
|
+
- test/typical_usage_test.rb
|
235
|
+
- test/test_template_dependency_on_static_test.rb
|
233
236
|
- test/test_helper.rb
|
234
237
|
- bin/render_slimmer_error
|
235
238
|
homepage: http://github.com/alphagov/slimmer
|
@@ -245,7 +248,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
245
248
|
requirements:
|
246
249
|
- - ">="
|
247
250
|
- !ruby/object:Gem::Version
|
248
|
-
hash: -
|
251
|
+
hash: -467376133944042160
|
249
252
|
segments:
|
250
253
|
- 0
|
251
254
|
version: "0"
|
@@ -254,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
257
|
requirements:
|
255
258
|
- - ">="
|
256
259
|
- !ruby/object:Gem::Version
|
257
|
-
hash: -
|
260
|
+
hash: -467376133944042160
|
258
261
|
segments:
|
259
262
|
- 0
|
260
263
|
version: "0"
|
@@ -266,26 +269,28 @@ signing_key:
|
|
266
269
|
specification_version: 3
|
267
270
|
summary: Thinner than the skinner
|
268
271
|
test_files:
|
269
|
-
- test/processors/meta_viewport_remover_test.rb
|
270
|
-
- test/processors/related_items_inserter_test.rb
|
271
|
-
- test/processors/report_a_problem_inserter_test.rb
|
272
|
-
- test/processors/section_inserter_test.rb
|
273
|
-
- test/processors/google_analytics_test.rb
|
274
|
-
- test/processors/search_index_setter_test.rb
|
275
|
-
- test/processors/header_context_inserter_test.rb
|
276
|
-
- test/processors/body_inserter_test.rb
|
277
|
-
- test/processors/logo_class_inserter_test.rb
|
278
|
-
- test/processors/campaign_notification_inserter_test.rb
|
279
|
-
- test/artefact_test.rb
|
280
|
-
- test/skin_test.rb
|
281
272
|
- test/headers_test.rb
|
282
|
-
- test/
|
283
|
-
- test/
|
273
|
+
- test/artefact_test.rb
|
274
|
+
- test/fixtures/related.raw.html.erb
|
275
|
+
- test/fixtures/campaign.html.erb
|
284
276
|
- test/fixtures/500.html.erb
|
285
277
|
- test/fixtures/404.html.erb
|
278
|
+
- test/fixtures/proposition_menu.html.erb
|
286
279
|
- test/fixtures/beta_notice.html.erb
|
287
|
-
- test/fixtures/report_a_problem.raw.html.erb
|
288
|
-
- test/fixtures/campaign.html.erb
|
289
|
-
- test/fixtures/related.raw.html.erb
|
290
280
|
- test/fixtures/wrapper.html.erb
|
281
|
+
- test/fixtures/report_a_problem.raw.html.erb
|
282
|
+
- test/skin_test.rb
|
283
|
+
- test/processors/campaign_notification_inserter_test.rb
|
284
|
+
- test/processors/meta_viewport_remover_test.rb
|
285
|
+
- test/processors/logo_class_inserter_test.rb
|
286
|
+
- test/processors/navigation_mover_test.rb
|
287
|
+
- test/processors/search_index_setter_test.rb
|
288
|
+
- test/processors/google_analytics_test.rb
|
289
|
+
- test/processors/report_a_problem_inserter_test.rb
|
290
|
+
- test/processors/body_inserter_test.rb
|
291
|
+
- test/processors/section_inserter_test.rb
|
292
|
+
- test/processors/related_items_inserter_test.rb
|
293
|
+
- test/processors/header_context_inserter_test.rb
|
294
|
+
- test/typical_usage_test.rb
|
295
|
+
- test/test_template_dependency_on_static_test.rb
|
291
296
|
- test/test_helper.rb
|