slimmer 3.9.4 → 3.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/slimmer.rb +0 -2
- data/lib/slimmer/app.rb +2 -6
- data/lib/slimmer/headers.rb +0 -1
- data/lib/slimmer/skin.rb +0 -13
- data/lib/slimmer/version.rb +1 -1
- metadata +56 -60
- data/lib/slimmer/processors/admin_title_inserter.rb +0 -12
- data/lib/slimmer/processors/search_path_setter.rb +0 -17
- data/test/processors/search_path_setter_test.rb +0 -39
data/README.md
CHANGED
@@ -8,7 +8,7 @@ various other details, such as meta, script, and style tags.
|
|
8
8
|
## Use in a Rails app
|
9
9
|
|
10
10
|
Slimmer provides a Railtie so no configuration is necessary. By default it will use the
|
11
|
-
Plek gem to look for the 'assets' host for the current environment.
|
11
|
+
Plek gem to look for the 'static' (previously 'assets') host for the current environment.
|
12
12
|
|
13
13
|
If you want to use your own set of templates you will need to specify the appropriate host
|
14
14
|
eg.
|
data/lib/slimmer.rb
CHANGED
@@ -25,7 +25,6 @@ module Slimmer
|
|
25
25
|
autoload :Artefact, 'slimmer/artefact'
|
26
26
|
|
27
27
|
module Processors
|
28
|
-
autoload :AdminTitleInserter, 'slimmer/processors/admin_title_inserter'
|
29
28
|
autoload :BodyClassCopier, 'slimmer/processors/body_class_copier'
|
30
29
|
autoload :BodyInserter, 'slimmer/processors/body_inserter'
|
31
30
|
autoload :ConditionalCommentMover, 'slimmer/processors/conditional_comment_mover'
|
@@ -38,7 +37,6 @@ module Slimmer
|
|
38
37
|
autoload :RelatedItemsInserter, 'slimmer/processors/related_items_inserter'
|
39
38
|
autoload :ReportAProblemInserter, 'slimmer/processors/report_a_problem_inserter'
|
40
39
|
autoload :SearchIndexSetter, 'slimmer/processors/search_index_setter'
|
41
|
-
autoload :SearchPathSetter, 'slimmer/processors/search_path_setter'
|
42
40
|
autoload :SectionInserter, 'slimmer/processors/section_inserter'
|
43
41
|
autoload :TagMover, 'slimmer/processors/tag_mover'
|
44
42
|
autoload :TitleInserter, 'slimmer/processors/title_inserter'
|
data/lib/slimmer/app.rb
CHANGED
@@ -23,7 +23,7 @@ module Slimmer
|
|
23
23
|
end
|
24
24
|
|
25
25
|
unless options[:asset_host]
|
26
|
-
options[:asset_host] = Plek.current.find("
|
26
|
+
options[:asset_host] = Plek.current.find("static")
|
27
27
|
end
|
28
28
|
|
29
29
|
@skin = Skin.new options.merge(logger: self.logger)
|
@@ -83,11 +83,7 @@ module Slimmer
|
|
83
83
|
|
84
84
|
rewritten_body = case response.status
|
85
85
|
when 200
|
86
|
-
|
87
|
-
@skin.admin s(response.body)
|
88
|
-
else
|
89
|
-
@skin.success request, response, s(response.body)
|
90
|
-
end
|
86
|
+
@skin.success request, response, s(response.body)
|
91
87
|
when 404
|
92
88
|
@skin.error '404', s(response.body)
|
93
89
|
else
|
data/lib/slimmer/headers.rb
CHANGED
@@ -24,7 +24,6 @@ module Slimmer
|
|
24
24
|
REMOVE_META_VIEWPORT = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:remove_meta_viewport]}"
|
25
25
|
RESULT_COUNT_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:result_count]}"
|
26
26
|
SEARCH_INDEX_HEADER = "#{HEADER_PREFIX}-Search-Index"
|
27
|
-
SEARCH_PATH_HEADER = "#{HEADER_PREFIX}-Search-Path"
|
28
27
|
SKIP_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:skip]}"
|
29
28
|
TEMPLATE_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:template]}"
|
30
29
|
|
data/lib/slimmer/skin.rb
CHANGED
@@ -112,18 +112,6 @@ module Slimmer
|
|
112
112
|
dest.to_html.sub(/<noscript rel=("|')placeholder("|')>/, "")
|
113
113
|
end
|
114
114
|
|
115
|
-
def admin(body)
|
116
|
-
processors = [
|
117
|
-
Processors::TitleInserter.new(),
|
118
|
-
Processors::TagMover.new(),
|
119
|
-
Processors::AdminTitleInserter.new,
|
120
|
-
Processors::FooterRemover.new,
|
121
|
-
Processors::BodyInserter.new(),
|
122
|
-
Processors::BodyClassCopier.new,
|
123
|
-
]
|
124
|
-
process(processors, body, template('admin'))
|
125
|
-
end
|
126
|
-
|
127
115
|
def success(source_request, response, body)
|
128
116
|
artefact = artefact_from_header(response)
|
129
117
|
processors = [
|
@@ -135,7 +123,6 @@ module Slimmer
|
|
135
123
|
Processors::HeaderContextInserter.new(),
|
136
124
|
Processors::SectionInserter.new(artefact),
|
137
125
|
Processors::GoogleAnalyticsConfigurator.new(response, artefact),
|
138
|
-
Processors::SearchPathSetter.new(response),
|
139
126
|
Processors::RelatedItemsInserter.new(self, artefact),
|
140
127
|
Processors::LogoClassInserter.new(artefact),
|
141
128
|
Processors::ReportAProblemInserter.new(self, source_request.url),
|
data/lib/slimmer/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: slimmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 3.9.
|
5
|
+
version: 3.9.5
|
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-11
|
14
|
+
date: 2012-12-11 00:00:00 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: nokogiri
|
@@ -128,9 +128,9 @@ dependencies:
|
|
128
128
|
requirement: &id011 !ruby/object:Gem::Requirement
|
129
129
|
none: false
|
130
130
|
requirements:
|
131
|
-
- -
|
131
|
+
- - ~>
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
133
|
+
version: 0.10.2
|
134
134
|
type: :development
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: *id011
|
@@ -180,58 +180,55 @@ 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/
|
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/
|
189
|
-
- lib/slimmer/
|
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
|
-
- lib/slimmer/processors/meta_viewport_remover.rb
|
193
192
|
- lib/slimmer/processors/search_index_setter.rb
|
194
|
-
- lib/slimmer/processors/
|
195
|
-
- lib/slimmer/processors/
|
196
|
-
- lib/slimmer/processors/footer_remover.rb
|
197
|
-
- lib/slimmer/processors/google_analytics_configurator.rb
|
198
|
-
- lib/slimmer/processors/admin_title_inserter.rb
|
199
|
-
- lib/slimmer/processors/search_path_setter.rb
|
193
|
+
- lib/slimmer/processors/body_class_copier.rb
|
194
|
+
- lib/slimmer/processors/tag_mover.rb
|
200
195
|
- lib/slimmer/processors/title_inserter.rb
|
201
|
-
- lib/slimmer/processors/
|
202
|
-
- lib/slimmer/processors/section_inserter.rb
|
196
|
+
- lib/slimmer/processors/google_analytics_configurator.rb
|
203
197
|
- lib/slimmer/processors/conditional_comment_mover.rb
|
198
|
+
- lib/slimmer/processors/related_items_inserter.rb
|
199
|
+
- lib/slimmer/processors/header_context_inserter.rb
|
204
200
|
- lib/slimmer/processors/body_inserter.rb
|
205
|
-
- lib/slimmer/
|
206
|
-
- lib/slimmer/
|
201
|
+
- lib/slimmer/processors/report_a_problem_inserter.rb
|
202
|
+
- lib/slimmer/processors/meta_viewport_remover.rb
|
203
|
+
- lib/slimmer/processors/campaign_notification_inserter.rb
|
204
|
+
- lib/slimmer/processors/section_inserter.rb
|
205
|
+
- lib/slimmer/processors/footer_remover.rb
|
207
206
|
- lib/slimmer/headers.rb
|
208
|
-
- lib/slimmer/
|
209
|
-
- lib/slimmer/
|
210
|
-
- lib/tasks/slimmer.rake
|
207
|
+
- lib/slimmer/version.rb
|
208
|
+
- lib/slimmer/artefact.rb
|
211
209
|
- Rakefile
|
212
|
-
- test/processors/header_context_inserter_test.rb
|
213
|
-
- test/processors/google_analytics_test.rb
|
214
|
-
- test/processors/body_inserter_test.rb
|
215
|
-
- test/processors/search_index_setter_test.rb
|
216
|
-
- test/processors/meta_viewport_remover_test.rb
|
217
|
-
- test/processors/report_a_problem_inserter_test.rb
|
218
|
-
- test/processors/section_inserter_test.rb
|
219
|
-
- test/processors/campaign_notification_inserter_test.rb
|
220
|
-
- test/processors/search_path_setter_test.rb
|
221
|
-
- test/processors/related_items_inserter_test.rb
|
222
|
-
- test/processors/logo_class_inserter_test.rb
|
223
|
-
- test/test_template_dependency_on_static_test.rb
|
224
210
|
- test/headers_test.rb
|
225
|
-
- test/test_helper.rb
|
226
|
-
- test/typical_usage_test.rb
|
227
211
|
- test/artefact_test.rb
|
228
|
-
- test/
|
212
|
+
- test/fixtures/related.raw.html.erb
|
229
213
|
- test/fixtures/campaign.html.erb
|
230
|
-
- test/fixtures/404.html.erb
|
231
214
|
- test/fixtures/500.html.erb
|
215
|
+
- test/fixtures/404.html.erb
|
232
216
|
- test/fixtures/wrapper.html.erb
|
233
|
-
- test/fixtures/related.raw.html.erb
|
234
217
|
- test/fixtures/report_a_problem.raw.html.erb
|
218
|
+
- test/skin_test.rb
|
219
|
+
- test/processors/campaign_notification_inserter_test.rb
|
220
|
+
- test/processors/meta_viewport_remover_test.rb
|
221
|
+
- test/processors/logo_class_inserter_test.rb
|
222
|
+
- test/processors/search_index_setter_test.rb
|
223
|
+
- test/processors/google_analytics_test.rb
|
224
|
+
- test/processors/report_a_problem_inserter_test.rb
|
225
|
+
- test/processors/body_inserter_test.rb
|
226
|
+
- test/processors/section_inserter_test.rb
|
227
|
+
- test/processors/related_items_inserter_test.rb
|
228
|
+
- test/processors/header_context_inserter_test.rb
|
229
|
+
- test/typical_usage_test.rb
|
230
|
+
- test/test_template_dependency_on_static_test.rb
|
231
|
+
- test/test_helper.rb
|
235
232
|
- bin/render_slimmer_error
|
236
233
|
homepage: http://github.com/alphagov/slimmer
|
237
234
|
licenses: []
|
@@ -246,7 +243,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
246
243
|
requirements:
|
247
244
|
- - ">="
|
248
245
|
- !ruby/object:Gem::Version
|
249
|
-
hash:
|
246
|
+
hash: 273902023069852675
|
250
247
|
segments:
|
251
248
|
- 0
|
252
249
|
version: "0"
|
@@ -255,7 +252,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
255
252
|
requirements:
|
256
253
|
- - ">="
|
257
254
|
- !ruby/object:Gem::Version
|
258
|
-
hash:
|
255
|
+
hash: 273902023069852675
|
259
256
|
segments:
|
260
257
|
- 0
|
261
258
|
version: "0"
|
@@ -267,26 +264,25 @@ signing_key:
|
|
267
264
|
specification_version: 3
|
268
265
|
summary: Thinner than the skinner
|
269
266
|
test_files:
|
270
|
-
- test/processors/header_context_inserter_test.rb
|
271
|
-
- test/processors/google_analytics_test.rb
|
272
|
-
- test/processors/body_inserter_test.rb
|
273
|
-
- test/processors/search_index_setter_test.rb
|
274
|
-
- test/processors/meta_viewport_remover_test.rb
|
275
|
-
- test/processors/report_a_problem_inserter_test.rb
|
276
|
-
- test/processors/section_inserter_test.rb
|
277
|
-
- test/processors/campaign_notification_inserter_test.rb
|
278
|
-
- test/processors/search_path_setter_test.rb
|
279
|
-
- test/processors/related_items_inserter_test.rb
|
280
|
-
- test/processors/logo_class_inserter_test.rb
|
281
|
-
- test/test_template_dependency_on_static_test.rb
|
282
267
|
- test/headers_test.rb
|
283
|
-
- test/test_helper.rb
|
284
|
-
- test/typical_usage_test.rb
|
285
268
|
- test/artefact_test.rb
|
286
|
-
- test/
|
269
|
+
- test/fixtures/related.raw.html.erb
|
287
270
|
- test/fixtures/campaign.html.erb
|
288
|
-
- test/fixtures/404.html.erb
|
289
271
|
- test/fixtures/500.html.erb
|
272
|
+
- test/fixtures/404.html.erb
|
290
273
|
- test/fixtures/wrapper.html.erb
|
291
|
-
- test/fixtures/related.raw.html.erb
|
292
274
|
- test/fixtures/report_a_problem.raw.html.erb
|
275
|
+
- test/skin_test.rb
|
276
|
+
- test/processors/campaign_notification_inserter_test.rb
|
277
|
+
- test/processors/meta_viewport_remover_test.rb
|
278
|
+
- test/processors/logo_class_inserter_test.rb
|
279
|
+
- test/processors/search_index_setter_test.rb
|
280
|
+
- test/processors/google_analytics_test.rb
|
281
|
+
- test/processors/report_a_problem_inserter_test.rb
|
282
|
+
- test/processors/body_inserter_test.rb
|
283
|
+
- test/processors/section_inserter_test.rb
|
284
|
+
- test/processors/related_items_inserter_test.rb
|
285
|
+
- test/processors/header_context_inserter_test.rb
|
286
|
+
- test/typical_usage_test.rb
|
287
|
+
- test/test_template_dependency_on_static_test.rb
|
288
|
+
- test/test_helper.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Slimmer::Processors
|
2
|
-
class SearchPathSetter
|
3
|
-
def initialize(response)
|
4
|
-
@response = response
|
5
|
-
end
|
6
|
-
|
7
|
-
def filter(content_document, page_template)
|
8
|
-
if search_scope && page_template.at_css('form#search')
|
9
|
-
page_template.at_css('form#search').attributes["action"].value = search_scope
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def search_scope
|
14
|
-
@response.headers[Slimmer::Headers::SEARCH_PATH_HEADER]
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
module SearchPathSetterTest
|
4
|
-
|
5
|
-
DOCUMENT_WITH_SEARCH = <<-END
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
</head>
|
9
|
-
<body class="body_class">
|
10
|
-
<div id="wrapper">
|
11
|
-
<form id="search" action="/path/to/search">
|
12
|
-
</form>
|
13
|
-
</div>
|
14
|
-
</body>
|
15
|
-
</html>
|
16
|
-
END
|
17
|
-
|
18
|
-
class WithHeaderTest < SlimmerIntegrationTest
|
19
|
-
headers = {
|
20
|
-
"X-Slimmer-Search-Path" => "/specialist/search",
|
21
|
-
}
|
22
|
-
|
23
|
-
given_response 200, DOCUMENT_WITH_SEARCH, headers
|
24
|
-
|
25
|
-
def test_should_rewrite_search_action
|
26
|
-
search_action = Nokogiri::HTML.parse(last_response.body).at_css('#search')["action"]
|
27
|
-
assert_equal "/specialist/search", search_action
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
class WithoutHeaderTest < SlimmerIntegrationTest
|
32
|
-
given_response 200, DOCUMENT_WITH_SEARCH, {}
|
33
|
-
|
34
|
-
def test_should_leave_original_search_action
|
35
|
-
search_action = Nokogiri::HTML.parse(last_response.body).at_css('#search')["action"]
|
36
|
-
assert_equal "/path/to/search", search_action
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|