slimmer 3.6.0 → 3.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ require 'uri'
2
+
1
3
  module Slimmer::Processors
2
4
  include ERB::Util
3
5
 
@@ -7,20 +9,21 @@ module Slimmer::Processors
7
9
  end
8
10
 
9
11
  def filter(content_document, page_template)
10
- if search_index && page_template.at_css('form#search')
11
- page_template.at_css('form#search') << hidden_input_element
12
+ if search_index && (form = page_template.at_css('form#search'))
13
+ uri = URI(form['action'])
14
+ uri.fragment = search_index_fragment
15
+ form['action'] = uri.to_s
12
16
  end
13
17
  end
14
18
 
15
19
  private
16
20
 
17
- def search_index
18
- @response.headers[Slimmer::Headers::SEARCH_INDEX_HEADER]
21
+ def search_index_fragment
22
+ "#{search_index}-results"
19
23
  end
20
24
 
21
- def hidden_input_element
22
- html = ERB.new('<input type="hidden" name="search-index" value="<%= search_index %>">').result(binding)
23
- Nokogiri::HTML.fragment(html)
25
+ def search_index
26
+ @response.headers[Slimmer::Headers::SEARCH_INDEX_HEADER]
24
27
  end
25
28
  end
26
29
  end
@@ -1,3 +1,3 @@
1
1
  module Slimmer
2
- VERSION = '3.6.0'
2
+ VERSION = '3.6.1'
3
3
  end
@@ -23,8 +23,8 @@ module SearchIndexSetterTest
23
23
  given_response 200, DOCUMENT_WITH_SEARCH, headers
24
24
 
25
25
  def test_should_insert_index_field
26
- search_index = Nokogiri::HTML.parse(last_response.body).at_css('#search input[name=search-index]')['value']
27
- assert_equal "government", search_index
26
+ search_action = Nokogiri::HTML.parse(last_response.body).at_css('#search')['action']
27
+ assert_equal "/path/to/search#government-results", search_action
28
28
  end
29
29
  end
30
30
 
@@ -32,8 +32,7 @@ module SearchIndexSetterTest
32
32
  given_response 200, DOCUMENT_WITH_SEARCH, {}
33
33
 
34
34
  def test_should_not_insert_index_field
35
- search_index = Nokogiri::HTML.parse(last_response.body).at_css('#search input[name=search-index]')
36
- assert_equal nil, search_index
35
+ assert_equal Nokogiri::HTML.parse(last_response.body).at_css('#search')['action'], '/path/to/search'
37
36
  end
38
37
  end
39
38
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: slimmer
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 3.6.0
5
+ version: 3.6.1
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: 2012-09-28 00:00:00 Z
14
+ date: 2012-10-01 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: nokogiri
@@ -180,53 +180,53 @@ extra_rdoc_files: []
180
180
  files:
181
181
  - README.md
182
182
  - CHANGELOG.md
183
+ - lib/tasks/slimmer.rake
183
184
  - lib/slimmer.rb
184
- - lib/slimmer/app.rb
185
- - lib/slimmer/test_template.rb
186
- - lib/slimmer/version.rb
185
+ - lib/slimmer/skin.rb
187
186
  - lib/slimmer/railtie.rb
188
- - lib/slimmer/processors/tag_mover.rb
189
- - lib/slimmer/processors/body_class_copier.rb
187
+ - lib/slimmer/template.rb
188
+ - lib/slimmer/test_template.rb
189
+ - lib/slimmer/test.rb
190
+ - lib/slimmer/app.rb
190
191
  - lib/slimmer/processors/logo_class_inserter.rb
191
- - lib/slimmer/processors/header_context_inserter.rb
192
192
  - lib/slimmer/processors/search_index_setter.rb
193
- - lib/slimmer/processors/report_a_problem_inserter.rb
194
- - lib/slimmer/processors/footer_remover.rb
195
- - lib/slimmer/processors/google_analytics_configurator.rb
196
- - lib/slimmer/processors/admin_title_inserter.rb
193
+ - lib/slimmer/processors/body_class_copier.rb
194
+ - lib/slimmer/processors/tag_mover.rb
197
195
  - lib/slimmer/processors/search_path_setter.rb
198
196
  - lib/slimmer/processors/title_inserter.rb
199
- - lib/slimmer/processors/related_items_inserter.rb
200
- - lib/slimmer/processors/section_inserter.rb
197
+ - lib/slimmer/processors/google_analytics_configurator.rb
201
198
  - lib/slimmer/processors/conditional_comment_mover.rb
199
+ - lib/slimmer/processors/related_items_inserter.rb
200
+ - lib/slimmer/processors/header_context_inserter.rb
202
201
  - lib/slimmer/processors/body_inserter.rb
203
- - lib/slimmer/artefact.rb
204
- - lib/slimmer/skin.rb
202
+ - lib/slimmer/processors/admin_title_inserter.rb
203
+ - lib/slimmer/processors/report_a_problem_inserter.rb
204
+ - lib/slimmer/processors/section_inserter.rb
205
+ - lib/slimmer/processors/footer_remover.rb
205
206
  - lib/slimmer/headers.rb
206
- - lib/slimmer/template.rb
207
- - lib/slimmer/test.rb
208
- - lib/tasks/slimmer.rake
207
+ - lib/slimmer/version.rb
208
+ - lib/slimmer/artefact.rb
209
209
  - Rakefile
210
- - test/processors/header_context_inserter_test.rb
211
- - test/processors/google_analytics_test.rb
212
- - test/processors/body_inserter_test.rb
210
+ - test/headers_test.rb
211
+ - test/artefact_test.rb
212
+ - test/fixtures/related.raw.html.erb
213
+ - test/fixtures/500.html.erb
214
+ - test/fixtures/404.html.erb
215
+ - test/fixtures/wrapper.html.erb
216
+ - test/fixtures/report_a_problem.raw.html.erb
217
+ - test/skin_test.rb
218
+ - test/processors/logo_class_inserter_test.rb
213
219
  - test/processors/search_index_setter_test.rb
220
+ - test/processors/google_analytics_test.rb
214
221
  - test/processors/report_a_problem_inserter_test.rb
215
- - test/processors/section_inserter_test.rb
222
+ - test/processors/body_inserter_test.rb
216
223
  - test/processors/search_path_setter_test.rb
224
+ - test/processors/section_inserter_test.rb
217
225
  - test/processors/related_items_inserter_test.rb
218
- - test/processors/logo_class_inserter_test.rb
226
+ - test/processors/header_context_inserter_test.rb
227
+ - test/typical_usage_test.rb
219
228
  - test/test_template_dependency_on_static_test.rb
220
- - test/headers_test.rb
221
229
  - test/test_helper.rb
222
- - test/typical_usage_test.rb
223
- - test/artefact_test.rb
224
- - test/skin_test.rb
225
- - test/fixtures/404.html.erb
226
- - test/fixtures/500.html.erb
227
- - test/fixtures/wrapper.html.erb
228
- - test/fixtures/related.raw.html.erb
229
- - test/fixtures/report_a_problem.raw.html.erb
230
230
  - bin/render_slimmer_error
231
231
  homepage: http://github.com/alphagov/slimmer
232
232
  licenses: []
@@ -241,7 +241,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
241
241
  requirements:
242
242
  - - ">="
243
243
  - !ruby/object:Gem::Version
244
- hash: 2398001210038307961
244
+ hash: 4260756547194608291
245
245
  segments:
246
246
  - 0
247
247
  version: "0"
@@ -250,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
250
  requirements:
251
251
  - - ">="
252
252
  - !ruby/object:Gem::Version
253
- hash: 2398001210038307961
253
+ hash: 4260756547194608291
254
254
  segments:
255
255
  - 0
256
256
  version: "0"
@@ -262,23 +262,23 @@ signing_key:
262
262
  specification_version: 3
263
263
  summary: Thinner than the skinner
264
264
  test_files:
265
- - test/processors/header_context_inserter_test.rb
266
- - test/processors/google_analytics_test.rb
267
- - test/processors/body_inserter_test.rb
265
+ - test/headers_test.rb
266
+ - test/artefact_test.rb
267
+ - test/fixtures/related.raw.html.erb
268
+ - test/fixtures/500.html.erb
269
+ - test/fixtures/404.html.erb
270
+ - test/fixtures/wrapper.html.erb
271
+ - test/fixtures/report_a_problem.raw.html.erb
272
+ - test/skin_test.rb
273
+ - test/processors/logo_class_inserter_test.rb
268
274
  - test/processors/search_index_setter_test.rb
275
+ - test/processors/google_analytics_test.rb
269
276
  - test/processors/report_a_problem_inserter_test.rb
270
- - test/processors/section_inserter_test.rb
277
+ - test/processors/body_inserter_test.rb
271
278
  - test/processors/search_path_setter_test.rb
279
+ - test/processors/section_inserter_test.rb
272
280
  - test/processors/related_items_inserter_test.rb
273
- - test/processors/logo_class_inserter_test.rb
281
+ - test/processors/header_context_inserter_test.rb
282
+ - test/typical_usage_test.rb
274
283
  - test/test_template_dependency_on_static_test.rb
275
- - test/headers_test.rb
276
284
  - test/test_helper.rb
277
- - test/typical_usage_test.rb
278
- - test/artefact_test.rb
279
- - test/skin_test.rb
280
- - test/fixtures/404.html.erb
281
- - test/fixtures/500.html.erb
282
- - test/fixtures/wrapper.html.erb
283
- - test/fixtures/related.raw.html.erb
284
- - test/fixtures/report_a_problem.raw.html.erb