slimmer 6.0.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9764cb7281a906d7133016e1d48fc732a2d5ad50
4
+ data.tar.gz: 7020a355e1246293785e8a0be2f92d03a31e02b3
5
+ SHA512:
6
+ metadata.gz: bb99ec91c22a9e76db811c330b8466ba2f5217915f770045c14a48028d7533bc8d365cf8b23b85e27dbbceea55a1a2b310369a670579aa9becdadd5960afcd0a
7
+ data.tar.gz: 88920a6e6fe1d6ebda6f43870e1e09dd7b9e06ac979843c6d6247fc1e3261e03e1aa467fefc2d5d3f7724c2c93e8e62d2c85ed277203834153f4a8c95132af75
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 7.0.0
2
+
3
+ * Remove AlphaLabelInserter, BetaNoticeInserter, BetaLabelInserter. These are
4
+ now better handled by govuk_components
5
+ * Remove LogoClassInserter. BusinessLink and DirectGov branding is being
6
+ removed so we don't need to insert their logos
7
+ * Loosen Nokogiri dependency. Rails 4.2 needs Nokogiri 1.6.0 and above.
8
+
1
9
  # 6.0.0
2
10
 
3
11
  * Change ComponentResolver to use a bespoke tag - `test-govuk-component` - when
@@ -15,7 +23,7 @@
15
23
  # 5.0.1
16
24
 
17
25
  * Fix MetaViewportRemover to not raise an exception if there is no meta
18
- viewport tag. Issue became apparent in 4.3.1.
26
+ viewport tag. Issue became apparent in 4.3.1.
19
27
 
20
28
  # 5.0.0
21
29
 
data/lib/slimmer.rb CHANGED
@@ -22,16 +22,12 @@ module Slimmer
22
22
  autoload :ComponentResolver, 'slimmer/component_resolver'
23
23
 
24
24
  module Processors
25
- autoload :AlphaLabelInserter, 'slimmer/processors/alpha_label_inserter'
26
- autoload :BetaNoticeInserter, 'slimmer/processors/beta_notice_inserter'
27
- autoload :BetaLabelInserter, 'slimmer/processors/beta_label_inserter'
28
25
  autoload :BodyClassCopier, 'slimmer/processors/body_class_copier'
29
26
  autoload :BodyInserter, 'slimmer/processors/body_inserter'
30
27
  autoload :ConditionalCommentMover, 'slimmer/processors/conditional_comment_mover'
31
28
  autoload :FooterRemover, 'slimmer/processors/footer_remover'
32
29
  autoload :GoogleAnalyticsConfigurator, 'slimmer/processors/google_analytics_configurator'
33
30
  autoload :HeaderContextInserter, 'slimmer/processors/header_context_inserter'
34
- autoload :LogoClassInserter, 'slimmer/processors/logo_class_inserter'
35
31
  autoload :NavigationMover, 'slimmer/processors/navigation_mover'
36
32
  autoload :MetaViewportRemover, 'slimmer/processors/meta_viewport_remover'
37
33
  autoload :RelatedItemsInserter, 'slimmer/processors/related_items_inserter'
@@ -26,12 +26,6 @@ class Slimmer::Artefact
26
26
  section
27
27
  end
28
28
 
29
- def legacy_sources
30
- tags_of_type('legacy_source').map do |t|
31
- id_to_slug(t["id"])
32
- end
33
- end
34
-
35
29
  def related_artefacts
36
30
  return [] unless self.related
37
31
  self.related.map do |r|
@@ -5,10 +5,7 @@ module Slimmer
5
5
  HEADER_PREFIX = "X-Slimmer"
6
6
 
7
7
  SLIMMER_HEADER_MAPPING = {
8
- alpha_label: "Alpha-Label",
9
8
  application_name: "Application-Name",
10
- beta: "Beta",
11
- beta_label: "Beta-Label",
12
9
  format: "Format",
13
10
  page_owner: "Page-Owner",
14
11
  proposition: "Proposition",
@@ -23,11 +20,8 @@ module Slimmer
23
20
  template: "Template",
24
21
  }
25
22
 
26
- ALPHA_LABEL = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:alpha_label]}"
27
23
  APPLICATION_NAME_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:application_name]}"
28
24
  ARTEFACT_HEADER = "#{HEADER_PREFIX}-Artefact"
29
- BETA_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:beta]}"
30
- BETA_LABEL = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:beta_label]}"
31
25
  FORMAT_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:format]}"
32
26
  ORGANISATIONS_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:organisations]}"
33
27
  REPORT_A_PROBLEM_FORM = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:report_a_problem]}"
data/lib/slimmer/skin.rb CHANGED
@@ -121,15 +121,11 @@ module Slimmer
121
121
  Processors::SearchParameterInserter.new(response),
122
122
  Processors::SearchPathSetter.new(response),
123
123
  Processors::RelatedItemsInserter.new(self, artefact),
124
- Processors::LogoClassInserter.new(artefact),
125
124
  Processors::ReportAProblemInserter.new(self,
126
125
  source_request.url,
127
126
  response.headers,
128
127
  wrapper_id),
129
128
  Processors::MetaViewportRemover.new(self, response.headers),
130
- Processors::BetaNoticeInserter.new(self, response.headers),
131
- Processors::BetaLabelInserter.new(self, response.headers),
132
- Processors::AlphaLabelInserter.new(self, response.headers),
133
129
  ]
134
130
 
135
131
  template_name = response.headers[Headers::TEMPLATE_HEADER] || 'wrapper'
@@ -1,3 +1,3 @@
1
1
  module Slimmer
2
- VERSION = '6.0.0'
2
+ VERSION = '7.0.0'
3
3
  end
@@ -22,12 +22,12 @@ describe Slimmer::Artefact do
22
22
  end
23
23
 
24
24
  it "should ignore other tag types" do
25
- @data["tags"].unshift(tag_for_slug("businesslink", "legacy_source"))
25
+ @data["tags"].unshift(tag_for_slug("other_tag", "another_tag"))
26
26
  assert_equal @tag1, Slimmer::Artefact.new(@data).primary_section
27
27
  end
28
28
 
29
29
  it "should return nil if there are no sections" do
30
- @data["tags"] = [tag_for_slug("businesslink", "legacy_source")]
30
+ @data["tags"] = [tag_for_slug("other_tag", "another_tag")]
31
31
  assert_equal nil, Slimmer::Artefact.new(@data).primary_section
32
32
  end
33
33
 
@@ -89,30 +89,6 @@ describe Slimmer::Artefact do
89
89
  end
90
90
  end
91
91
 
92
- describe "Legacy sources" do
93
- before do
94
- @data = artefact_for_slug('something')
95
- end
96
-
97
- it "should return the slugs of all legacy_source tags" do
98
- @data["tags"] << tag_for_slug('businesslink', 'legacy_source')
99
- @data["tags"] << tag_for_slug('directgov', 'legacy_source')
100
- assert_equal ['businesslink', 'directgov'], Slimmer::Artefact.new(@data).legacy_sources.sort
101
- end
102
-
103
- it "should not include other tags" do
104
- @data["tags"] << tag_for_slug('businesslink', 'legacy_source')
105
- @data["tags"] << tag_for_slug('business', 'proposition')
106
- @data["tags"] << tag_for_slug('directgov', 'legacy_source')
107
- assert_equal ['businesslink', 'directgov'], Slimmer::Artefact.new(@data).legacy_sources.sort
108
- end
109
-
110
- it "should return empty array if the data hs no tags element" do
111
- @data.delete("tags")
112
- assert_equal [], Slimmer::Artefact.new(@data).legacy_sources
113
- end
114
- end
115
-
116
92
  describe "method_missing accessing artefact fields" do
117
93
  before do
118
94
  @data = artefact_for_slug('something')
@@ -25,13 +25,6 @@
25
25
  <a href="#content">Return to top &uarr;</a>
26
26
  </nav>
27
27
  </div>
28
- <div id="legacy-sources">
29
- <p>This replaces</p>
30
- <ul>
31
- <li class="directgov">Directgov</li>
32
- <li class="businesslink">Business Link</li>
33
- </ul>
34
- </div>
35
28
  </div>
36
29
 
37
30
  </div>
data/test/test_helper.rb CHANGED
@@ -92,9 +92,6 @@ class SlimmerIntegrationTest < MiniTest::Test
92
92
  use_template(template_name)
93
93
  use_template('related.raw')
94
94
  use_template('report_a_problem.raw')
95
- use_template('alpha_label')
96
- use_template('beta_notice')
97
- use_template('beta_label')
98
95
 
99
96
  fetch_page
100
97
  end
@@ -90,7 +90,6 @@ module TypicalUsage
90
90
  def setup
91
91
  super
92
92
  @artefact = artefact_for_slug_in_a_section("some-article", 'this-section')
93
- @artefact["tags"] << tag_for_slug("directgov", "legacy_source")
94
93
  given_response 200, %{
95
94
  <html>
96
95
  <head><title>The title of the page</title>
@@ -132,15 +131,6 @@ module TypicalUsage
132
131
  def test_should_insert_section_links_into_the_navigation
133
132
  assert_rendered_in_template "#global-breadcrumb ol li a[href='https://www.test.gov.uk/browse/this-section']", "This section"
134
133
  end
135
-
136
- def test_should_add_logo_classes_to_wrapper
137
- assert_rendered_in_template "#wrapper.directgov"
138
- end
139
-
140
- def test_should_not_add_beta_notice_to_non_beta_pages
141
- assert_no_selector "body.beta"
142
- assert_no_selector ".beta-notice"
143
- end
144
134
  end
145
135
 
146
136
  class ConditionalCommentTest < SlimmerIntegrationTest
@@ -255,34 +245,6 @@ module TypicalUsage
255
245
  end
256
246
  end
257
247
 
258
- class BetaLabelInserterTest < SlimmerIntegrationTest
259
- def test_should_add_beta_label
260
- given_response 200, %{
261
- <html>
262
- <body class="wibble">
263
- <div id="wrapper">The body of the page</div>
264
- </body>
265
- </html>
266
- }, { Slimmer::Headers::BETA_LABEL => 'after:#wrapper' }
267
-
268
- assert_rendered_in_template '.beta-label'
269
- end
270
- end
271
-
272
- class AlphaLabelInserterTest < SlimmerIntegrationTest
273
- def test_should_add_alpha_label
274
- given_response 200, %{
275
- <html>
276
- <body class="wibble">
277
- <div id="wrapper">The body of the page</div>
278
- </body>
279
- </html>
280
- }, { Slimmer::Headers::ALPHA_LABEL => 'after:#wrapper' }
281
-
282
- assert_rendered_in_template '.alpha-label'
283
- end
284
- end
285
-
286
248
  class Error500ResponseTest < SlimmerIntegrationTest
287
249
  given_response 500, %{
288
250
  <html>
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slimmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
5
- prerelease:
4
+ version: 7.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ben Griffiths
@@ -10,184 +9,238 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2014-12-22 00:00:00.000000000 Z
12
+ date: 2015-02-13 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: nokogiri
17
- requirement: &19898920 !ruby/object:Gem::Requirement
18
- none: false
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  requirements:
20
- - - ~>
18
+ - - ">="
21
19
  - !ruby/object:Gem::Version
22
20
  version: 1.5.0
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: 1.7.0
23
24
  type: :runtime
24
25
  prerelease: false
25
- version_requirements: *19898920
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: 1.5.0
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.7.0
26
34
  - !ruby/object:Gem::Dependency
27
35
  name: rack
28
- requirement: &19914280 !ruby/object:Gem::Requirement
29
- none: false
36
+ requirement: !ruby/object:Gem::Requirement
30
37
  requirements:
31
- - - ! '>='
38
+ - - ">="
32
39
  - !ruby/object:Gem::Version
33
40
  version: 1.3.5
34
41
  type: :runtime
35
42
  prerelease: false
36
- version_requirements: *19914280
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.3.5
37
48
  - !ruby/object:Gem::Dependency
38
49
  name: plek
39
- requirement: &19912620 !ruby/object:Gem::Requirement
40
- none: false
50
+ requirement: !ruby/object:Gem::Requirement
41
51
  requirements:
42
- - - ! '>='
52
+ - - ">="
43
53
  - !ruby/object:Gem::Version
44
54
  version: 1.1.0
45
55
  type: :runtime
46
56
  prerelease: false
47
- version_requirements: *19912620
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.1.0
48
62
  - !ruby/object:Gem::Dependency
49
63
  name: json
50
- requirement: &19911480 !ruby/object:Gem::Requirement
51
- none: false
64
+ requirement: !ruby/object:Gem::Requirement
52
65
  requirements:
53
- - - ! '>='
66
+ - - ">="
54
67
  - !ruby/object:Gem::Version
55
68
  version: '0'
56
69
  type: :runtime
57
70
  prerelease: false
58
- version_requirements: *19911480
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
59
76
  - !ruby/object:Gem::Dependency
60
77
  name: null_logger
61
- requirement: &19910020 !ruby/object:Gem::Requirement
62
- none: false
78
+ requirement: !ruby/object:Gem::Requirement
63
79
  requirements:
64
- - - ! '>='
80
+ - - ">="
65
81
  - !ruby/object:Gem::Version
66
82
  version: '0'
67
83
  type: :runtime
68
84
  prerelease: false
69
- version_requirements: *19910020
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
70
90
  - !ruby/object:Gem::Dependency
71
91
  name: rest-client
72
- requirement: &19908180 !ruby/object:Gem::Requirement
73
- none: false
92
+ requirement: !ruby/object:Gem::Requirement
74
93
  requirements:
75
- - - ! '>='
94
+ - - ">="
76
95
  - !ruby/object:Gem::Version
77
96
  version: '0'
78
97
  type: :runtime
79
98
  prerelease: false
80
- version_requirements: *19908180
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
81
104
  - !ruby/object:Gem::Dependency
82
105
  name: activesupport
83
- requirement: &19907040 !ruby/object:Gem::Requirement
84
- none: false
106
+ requirement: !ruby/object:Gem::Requirement
85
107
  requirements:
86
- - - ! '>='
108
+ - - ">="
87
109
  - !ruby/object:Gem::Version
88
110
  version: '0'
89
111
  type: :runtime
90
112
  prerelease: false
91
- version_requirements: *19907040
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
92
118
  - !ruby/object:Gem::Dependency
93
119
  name: minitest
94
- requirement: &19931140 !ruby/object:Gem::Requirement
95
- none: false
120
+ requirement: !ruby/object:Gem::Requirement
96
121
  requirements:
97
- - - ~>
122
+ - - "~>"
98
123
  - !ruby/object:Gem::Version
99
124
  version: '5.4'
100
125
  type: :development
101
126
  prerelease: false
102
- version_requirements: *19931140
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '5.4'
103
132
  - !ruby/object:Gem::Dependency
104
133
  name: rake
105
- requirement: &19954060 !ruby/object:Gem::Requirement
106
- none: false
134
+ requirement: !ruby/object:Gem::Requirement
107
135
  requirements:
108
- - - ~>
136
+ - - "~>"
109
137
  - !ruby/object:Gem::Version
110
138
  version: 0.9.2.2
111
139
  type: :development
112
140
  prerelease: false
113
- version_requirements: *19954060
141
+ version_requirements: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 0.9.2.2
114
146
  - !ruby/object:Gem::Dependency
115
147
  name: rack-test
116
- requirement: &19952100 !ruby/object:Gem::Requirement
117
- none: false
148
+ requirement: !ruby/object:Gem::Requirement
118
149
  requirements:
119
- - - ~>
150
+ - - "~>"
120
151
  - !ruby/object:Gem::Version
121
152
  version: 0.6.1
122
153
  type: :development
123
154
  prerelease: false
124
- version_requirements: *19952100
155
+ version_requirements: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.6.1
125
160
  - !ruby/object:Gem::Dependency
126
161
  name: mocha
127
- requirement: &19950820 !ruby/object:Gem::Requirement
128
- none: false
162
+ requirement: !ruby/object:Gem::Requirement
129
163
  requirements:
130
- - - ~>
164
+ - - "~>"
131
165
  - !ruby/object:Gem::Version
132
166
  version: '1.1'
133
167
  type: :development
134
168
  prerelease: false
135
- version_requirements: *19950820
169
+ version_requirements: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '1.1'
136
174
  - !ruby/object:Gem::Dependency
137
175
  name: webmock
138
- requirement: &19949700 !ruby/object:Gem::Requirement
139
- none: false
176
+ requirement: !ruby/object:Gem::Requirement
140
177
  requirements:
141
- - - =
178
+ - - '='
142
179
  - !ruby/object:Gem::Version
143
180
  version: 1.18.0
144
181
  type: :development
145
182
  prerelease: false
146
- version_requirements: *19949700
183
+ version_requirements: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '='
186
+ - !ruby/object:Gem::Version
187
+ version: 1.18.0
147
188
  - !ruby/object:Gem::Dependency
148
189
  name: therubyracer
149
- requirement: &19972060 !ruby/object:Gem::Requirement
150
- none: false
190
+ requirement: !ruby/object:Gem::Requirement
151
191
  requirements:
152
- - - ~>
192
+ - - "~>"
153
193
  - !ruby/object:Gem::Version
154
194
  version: 0.10.2
155
195
  type: :development
156
196
  prerelease: false
157
- version_requirements: *19972060
197
+ version_requirements: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: 0.10.2
158
202
  - !ruby/object:Gem::Dependency
159
203
  name: gem_publisher
160
- requirement: &19970640 !ruby/object:Gem::Requirement
161
- none: false
204
+ requirement: !ruby/object:Gem::Requirement
162
205
  requirements:
163
- - - ~>
206
+ - - "~>"
164
207
  - !ruby/object:Gem::Version
165
- version: 1.1.1
208
+ version: 1.5.0
166
209
  type: :development
167
210
  prerelease: false
168
- version_requirements: *19970640
211
+ version_requirements: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: 1.5.0
169
216
  - !ruby/object:Gem::Dependency
170
217
  name: gds-api-adapters
171
- requirement: &19969780 !ruby/object:Gem::Requirement
172
- none: false
218
+ requirement: !ruby/object:Gem::Requirement
173
219
  requirements:
174
- - - =
220
+ - - '='
175
221
  - !ruby/object:Gem::Version
176
222
  version: 2.7.1
177
223
  type: :development
178
224
  prerelease: false
179
- version_requirements: *19969780
225
+ version_requirements: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - '='
228
+ - !ruby/object:Gem::Version
229
+ version: 2.7.1
180
230
  - !ruby/object:Gem::Dependency
181
231
  name: timecop
182
- requirement: &19968420 !ruby/object:Gem::Requirement
183
- none: false
232
+ requirement: !ruby/object:Gem::Requirement
184
233
  requirements:
185
- - - ~>
234
+ - - "~>"
186
235
  - !ruby/object:Gem::Version
187
236
  version: 0.5.1
188
237
  type: :development
189
238
  prerelease: false
190
- version_requirements: *19968420
239
+ version_requirements: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: 0.5.1
191
244
  description: Rack middleware for skinning pages using a specific template
192
245
  email:
193
246
  - bengriffiths@gmail.com
@@ -197,114 +250,93 @@ executables:
197
250
  extensions: []
198
251
  extra_rdoc_files: []
199
252
  files:
200
- - README.md
201
253
  - CHANGELOG.md
202
- - lib/slimmer/i18n_backend.rb
203
- - lib/slimmer/railtie.rb
204
- - lib/slimmer/headers.rb
205
- - lib/slimmer/skin.rb
254
+ - README.md
255
+ - Rakefile
256
+ - bin/render_slimmer_error
257
+ - lib/slimmer.rb
206
258
  - lib/slimmer/app.rb
207
- - lib/slimmer/test_templates/header_footer_only.html
208
- - lib/slimmer/test_templates/alpha_label.html
209
- - lib/slimmer/test_templates/wrapper.html
210
- - lib/slimmer/test_templates/beta_notice.html
211
- - lib/slimmer/test_templates/beta_label.html
212
- - lib/slimmer/test.rb
213
- - lib/slimmer/version.rb
214
- - lib/slimmer/test_helpers/shared_templates.rb
215
259
  - lib/slimmer/artefact.rb
216
- - lib/slimmer/shared_templates.rb
217
- - lib/slimmer/govuk_request_id.rb
218
- - lib/slimmer/template.rb
219
- - lib/slimmer/component_resolver.rb
220
260
  - lib/slimmer/cache.rb
221
- - lib/slimmer/processors/header_context_inserter.rb
222
- - lib/slimmer/processors/navigation_mover.rb
223
- - lib/slimmer/processors/google_analytics_configurator.rb
224
- - lib/slimmer/processors/logo_class_inserter.rb
225
- - lib/slimmer/processors/section_inserter.rb
226
- - lib/slimmer/processors/tag_mover.rb
227
- - lib/slimmer/processors/meta_viewport_remover.rb
261
+ - lib/slimmer/component_resolver.rb
262
+ - lib/slimmer/govuk_request_id.rb
263
+ - lib/slimmer/headers.rb
264
+ - lib/slimmer/i18n_backend.rb
228
265
  - lib/slimmer/processors/body_class_copier.rb
229
- - lib/slimmer/processors/beta_label_inserter.rb
230
- - lib/slimmer/processors/report_a_problem_inserter.rb
231
- - lib/slimmer/processors/title_inserter.rb
232
- - lib/slimmer/processors/search_parameter_inserter.rb
233
266
  - lib/slimmer/processors/body_inserter.rb
234
- - lib/slimmer/processors/alpha_label_inserter.rb
267
+ - lib/slimmer/processors/conditional_comment_mover.rb
235
268
  - lib/slimmer/processors/footer_remover.rb
236
- - lib/slimmer/processors/beta_notice_inserter.rb
269
+ - lib/slimmer/processors/google_analytics_configurator.rb
270
+ - lib/slimmer/processors/header_context_inserter.rb
271
+ - lib/slimmer/processors/meta_viewport_remover.rb
272
+ - lib/slimmer/processors/navigation_mover.rb
237
273
  - lib/slimmer/processors/related_items_inserter.rb
274
+ - lib/slimmer/processors/report_a_problem_inserter.rb
275
+ - lib/slimmer/processors/search_parameter_inserter.rb
238
276
  - lib/slimmer/processors/search_path_setter.rb
239
- - lib/slimmer/processors/conditional_comment_mover.rb
277
+ - lib/slimmer/processors/section_inserter.rb
278
+ - lib/slimmer/processors/tag_mover.rb
279
+ - lib/slimmer/processors/title_inserter.rb
280
+ - lib/slimmer/railtie.rb
281
+ - lib/slimmer/shared_templates.rb
282
+ - lib/slimmer/skin.rb
283
+ - lib/slimmer/template.rb
284
+ - lib/slimmer/test.rb
285
+ - lib/slimmer/test_helpers/shared_templates.rb
286
+ - lib/slimmer/test_templates/header_footer_only.html
287
+ - lib/slimmer/test_templates/wrapper.html
288
+ - lib/slimmer/version.rb
240
289
  - lib/tasks/slimmer.rake
241
- - lib/slimmer.rb
242
- - Rakefile
243
- - test/component_resolver_test.rb
244
- - test/changelog_test.rb
245
- - test/test_helpers/shared_templates_test.rb
246
- - test/typical_usage_test.rb
247
- - test/skin_test.rb
248
- - test/deprecated_usage_test.rb
249
290
  - test/artefact_test.rb
250
- - test/fixtures/wrapper.html.erb
291
+ - test/cache_test.rb
292
+ - test/changelog_test.rb
293
+ - test/component_resolver_test.rb
294
+ - test/fixtures/404.html.erb
295
+ - test/fixtures/410.html.erb
251
296
  - test/fixtures/500.html.erb
252
297
  - test/fixtures/proposition_menu.html.erb
253
- - test/fixtures/410.html.erb
254
- - test/fixtures/alpha_label.html.erb
255
- - test/fixtures/404.html.erb
256
- - test/fixtures/report_a_problem.raw.html.erb
257
- - test/fixtures/beta_label.html.erb
258
298
  - test/fixtures/related.raw.html.erb
259
- - test/fixtures/beta_notice.html.erb
299
+ - test/fixtures/report_a_problem.raw.html.erb
300
+ - test/fixtures/wrapper.html.erb
260
301
  - test/headers_test.rb
261
- - test/test_template_dependency_on_static_test.rb
262
- - test/cache_test.rb
263
- - test/test_helper.rb
264
- - test/processors/header_context_inserter_test.rb
265
302
  - test/processors/body_inserter_test.rb
266
- - test/processors/navigation_mover_test.rb
267
- - test/processors/related_items_inserter_test.rb
268
- - test/processors/search_path_setter_test.rb
269
303
  - test/processors/google_analytics_test.rb
304
+ - test/processors/header_context_inserter_test.rb
270
305
  - test/processors/meta_viewport_remover_test.rb
271
- - test/processors/alpha_label_inserter_test.rb
306
+ - test/processors/navigation_mover_test.rb
307
+ - test/processors/related_items_inserter_test.rb
308
+ - test/processors/report_a_problem_inserter_test.rb
272
309
  - test/processors/search_parameter_inserter_test.rb
310
+ - test/processors/search_path_setter_test.rb
273
311
  - test/processors/section_inserter_test.rb
274
- - test/processors/report_a_problem_inserter_test.rb
275
312
  - test/processors/tag_mover_test.rb
276
- - test/processors/logo_class_inserter_test.rb
277
- - test/processors/beta_label_inserter_test.rb
278
- - bin/render_slimmer_error
313
+ - test/skin_test.rb
314
+ - test/test_helper.rb
315
+ - test/test_helpers/shared_templates_test.rb
316
+ - test/test_template_dependency_on_static_test.rb
317
+ - test/typical_usage_test.rb
279
318
  homepage: http://github.com/alphagov/slimmer
280
319
  licenses: []
320
+ metadata: {}
281
321
  post_install_message:
282
322
  rdoc_options: []
283
323
  require_paths:
284
324
  - lib
285
325
  required_ruby_version: !ruby/object:Gem::Requirement
286
- none: false
287
326
  requirements:
288
- - - ! '>='
327
+ - - ">="
289
328
  - !ruby/object:Gem::Version
290
329
  version: '0'
291
- segments:
292
- - 0
293
- hash: -1405185890624183511
294
330
  required_rubygems_version: !ruby/object:Gem::Requirement
295
- none: false
296
331
  requirements:
297
- - - ! '>='
332
+ - - ">="
298
333
  - !ruby/object:Gem::Version
299
334
  version: '0'
300
- segments:
301
- - 0
302
- hash: -1405185890624183511
303
335
  requirements: []
304
336
  rubyforge_project: slimmer
305
- rubygems_version: 1.8.11
337
+ rubygems_version: 2.2.2
306
338
  signing_key:
307
- specification_version: 3
339
+ specification_version: 4
308
340
  summary: Thinner than the skinner
309
341
  test_files:
310
342
  - test/component_resolver_test.rb
@@ -312,18 +344,14 @@ test_files:
312
344
  - test/test_helpers/shared_templates_test.rb
313
345
  - test/typical_usage_test.rb
314
346
  - test/skin_test.rb
315
- - test/deprecated_usage_test.rb
316
347
  - test/artefact_test.rb
317
348
  - test/fixtures/wrapper.html.erb
318
349
  - test/fixtures/500.html.erb
319
350
  - test/fixtures/proposition_menu.html.erb
320
351
  - test/fixtures/410.html.erb
321
- - test/fixtures/alpha_label.html.erb
322
352
  - test/fixtures/404.html.erb
323
353
  - test/fixtures/report_a_problem.raw.html.erb
324
- - test/fixtures/beta_label.html.erb
325
354
  - test/fixtures/related.raw.html.erb
326
- - test/fixtures/beta_notice.html.erb
327
355
  - test/headers_test.rb
328
356
  - test/test_template_dependency_on_static_test.rb
329
357
  - test/cache_test.rb
@@ -335,10 +363,7 @@ test_files:
335
363
  - test/processors/search_path_setter_test.rb
336
364
  - test/processors/google_analytics_test.rb
337
365
  - test/processors/meta_viewport_remover_test.rb
338
- - test/processors/alpha_label_inserter_test.rb
339
366
  - test/processors/search_parameter_inserter_test.rb
340
367
  - test/processors/section_inserter_test.rb
341
368
  - test/processors/report_a_problem_inserter_test.rb
342
369
  - test/processors/tag_mover_test.rb
343
- - test/processors/logo_class_inserter_test.rb
344
- - test/processors/beta_label_inserter_test.rb
@@ -1,35 +0,0 @@
1
- module Slimmer::Processors
2
- class AlphaLabelInserter
3
- def initialize(skin, headers)
4
- @skin = skin
5
- @headers = headers
6
- end
7
-
8
- def filter(content_document, page_template)
9
- if should_add_alpha_label?
10
- if position == 'before'
11
- page_template.at_css(selector).add_previous_sibling(alpha_label_block)
12
- elsif position == 'after'
13
- page_template.at_css(selector).add_next_sibling(alpha_label_block)
14
- end
15
- end
16
- end
17
-
18
- def should_add_alpha_label?
19
- !! @headers[Slimmer::Headers::ALPHA_LABEL]
20
- end
21
-
22
- def alpha_label_block
23
- @alpha_label_block ||= @skin.template('alpha_label').to_s
24
- end
25
-
26
- private
27
- def selector
28
- @headers[Slimmer::Headers::ALPHA_LABEL].gsub(/.*:/, '')
29
- end
30
-
31
- def position
32
- @headers[Slimmer::Headers::ALPHA_LABEL].gsub(/:.*/, '')
33
- end
34
- end
35
- end
@@ -1,35 +0,0 @@
1
- module Slimmer::Processors
2
- class BetaLabelInserter
3
- def initialize(skin, headers)
4
- @skin = skin
5
- @headers = headers
6
- end
7
-
8
- def filter(content_document, page_template)
9
- if should_add_beta_label?
10
- if position == 'before'
11
- page_template.at_css(selector).add_previous_sibling(beta_label_block)
12
- elsif position == 'after'
13
- page_template.at_css(selector).add_next_sibling(beta_label_block)
14
- end
15
- end
16
- end
17
-
18
- def should_add_beta_label?
19
- !! @headers[Slimmer::Headers::BETA_LABEL]
20
- end
21
-
22
- def beta_label_block
23
- @beta_label_block ||= @skin.template('beta_label').to_s
24
- end
25
-
26
- private
27
- def selector
28
- @headers[Slimmer::Headers::BETA_LABEL].gsub(/.*:/, '')
29
- end
30
-
31
- def position
32
- @headers[Slimmer::Headers::BETA_LABEL].gsub(/:.*/, '')
33
- end
34
- end
35
- end
@@ -1,35 +0,0 @@
1
- module Slimmer::Processors
2
- class BetaNoticeInserter
3
- def initialize(skin, headers)
4
- @skin = skin
5
- @headers = headers
6
- end
7
-
8
- def filter(content_document, page_template)
9
- if should_add_beta_notice?
10
- warn "[DEPRECATION WARNING] BETA_HEADER is deprecated. Use BETA_LABEL instead."
11
- page_template.css('body').add_class('beta')
12
- if header = page_template.at_css('#global-header')
13
- header.add_next_sibling(beta_notice_block)
14
- end
15
- if footer = page_template.at_css('footer#footer')
16
- footer.add_previous_sibling(add_footer_class(beta_notice_block))
17
- end
18
- end
19
- end
20
-
21
- def should_add_beta_notice?
22
- !! @headers[Slimmer::Headers::BETA_HEADER]
23
- end
24
-
25
- def add_footer_class(block)
26
- block = Nokogiri::HTML.fragment(block)
27
- block.child['class'] = "#{block.child['class']} js-footer"
28
- block
29
- end
30
-
31
- def beta_notice_block
32
- @beta_notice_block ||= @skin.template('beta_notice')
33
- end
34
- end
35
- end
@@ -1,20 +0,0 @@
1
- module Slimmer
2
- module Processors
3
- class LogoClassInserter
4
- LOGO_CLASSES = %w(businesslink directgov)
5
-
6
- def initialize(artefact)
7
- @artefact = artefact
8
- end
9
-
10
- def filter(source, dest)
11
- return unless @artefact
12
- classes_to_use = LOGO_CLASSES & @artefact.legacy_sources
13
- wrapper = dest.css('#wrapper')
14
- classes_to_use.each do |klass|
15
- wrapper.add_class(klass)
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1 +0,0 @@
1
- <div class="alpha-label"><p>This page is ALPHA.</p></div>
@@ -1 +0,0 @@
1
- <div class="beta-label"><p>This page is BETA.</p></div>
@@ -1 +0,0 @@
1
- <div class="beta-notice"><p>This page is BETA.</p></div>
@@ -1,25 +0,0 @@
1
- require_relative "test_helper"
2
-
3
- module DeprecatedUsage
4
- class BetaNoticeInserterTest < SlimmerIntegrationTest
5
- def test_should_add_beta_warnings
6
- Slimmer::Processors::BetaNoticeInserter.any_instance.
7
- expects(:warn).
8
- with(regexp_matches(/BETA_HEADER is deprecated. Use BETA_LABEL instead/))
9
-
10
- given_response 200, %{
11
- <html>
12
- <body class="wibble">
13
- <div id="wrapper">The body of the page</div>
14
- </body>
15
- </html>
16
- }, {Slimmer::Headers::BETA_HEADER => '1'}
17
-
18
- # beta notice after cookie bar
19
- assert_rendered_in_template "body.beta.wibble #global-header + div.beta-notice"
20
-
21
- # beta notice before footer
22
- assert_rendered_in_template "body.beta.wibble div.beta-notice.js-footer + #footer"
23
- end
24
- end
25
- end
@@ -1 +0,0 @@
1
- <div class="alpha-label"><p>This page is ALPHA.</p></div>
@@ -1 +0,0 @@
1
- <div class="beta-label"><p>This page is BETA.</p></div>
@@ -1,3 +0,0 @@
1
- <div class="beta-notice">
2
- <p>This page is in beta</p>
3
- </div>
@@ -1,42 +0,0 @@
1
- require_relative "../test_helper"
2
-
3
- class AlphaLabelInserterTest < MiniTest::Test
4
-
5
- def setup
6
- super
7
- alpha_label_block = '<div class="alpha-label"><p>This page is ALPHA.</p></div>'
8
- @skin = stub("Skin", :template => alpha_label_block)
9
- @template = as_nokogiri %{
10
- <html><body><div><div id="wrapper"><header id="main">GOV.UK</header></div></div></body></html>
11
- }
12
- end
13
-
14
- def test_should_add_alpha_label_after
15
-
16
- headers = {
17
- Slimmer::Headers::ALPHA_LABEL => "after:header#main"
18
- }
19
-
20
- Slimmer::Processors::AlphaLabelInserter.new(@skin, headers).filter(nil, @template)
21
-
22
- assert_in @template, '#main + .alpha-label'
23
- end
24
-
25
- def test_should_add_alpha_label_before
26
- headers = {
27
- Slimmer::Headers::ALPHA_LABEL => "before:header#main"
28
- }
29
-
30
- Slimmer::Processors::AlphaLabelInserter.new(@skin, headers).filter(nil, @template)
31
-
32
- assert_in @template, '.alpha-label + #main'
33
- end
34
-
35
- def test_should_not_add_alpha_label
36
- headers = {}
37
-
38
- Slimmer::Processors::AlphaLabelInserter.new(@skin, headers).filter(nil, @template)
39
-
40
- assert_not_in @template, '.alpha-label'
41
- end
42
- end
@@ -1,42 +0,0 @@
1
- require_relative "../test_helper"
2
-
3
- class BetaLabelInserterTest < MiniTest::Test
4
-
5
- def setup
6
- super
7
- beta_label_block = '<div class="beta-label"><p>This page is BETA.</p></div>'
8
- @skin = stub("Skin", :template => beta_label_block)
9
- @template = as_nokogiri %{
10
- <html><body><div><div id="wrapper"><header id="main">GOV.UK</header></div></div></body></html>
11
- }
12
- end
13
-
14
- def test_should_add_beta_label_after
15
-
16
- headers = {
17
- Slimmer::Headers::BETA_LABEL => "after:header#main"
18
- }
19
-
20
- Slimmer::Processors::BetaLabelInserter.new(@skin, headers).filter(nil, @template)
21
-
22
- assert_in @template, '#main + .beta-label'
23
- end
24
-
25
- def test_should_add_beta_label_before
26
- headers = {
27
- Slimmer::Headers::BETA_LABEL => "before:header#main"
28
- }
29
-
30
- Slimmer::Processors::BetaLabelInserter.new(@skin, headers).filter(nil, @template)
31
-
32
- assert_in @template, '.beta-label + #main'
33
- end
34
-
35
- def test_should_not_add_beta_label
36
- headers = {}
37
-
38
- Slimmer::Processors::BetaLabelInserter.new(@skin, headers).filter(nil, @template)
39
-
40
- assert_not_in @template, '.beta-label'
41
- end
42
- end
@@ -1,81 +0,0 @@
1
- require_relative "../test_helper.rb"
2
- require 'gds_api/test_helpers/content_api'
3
-
4
- describe Slimmer::Processors::LogoClassInserter do
5
- include GdsApi::TestHelpers::ContentApi
6
-
7
- def artefact_with_legacy_source_tags(legacy_sources)
8
- artefact = artefact_for_slug("vat")
9
- legacy_sources.each do |legacy_source|
10
- artefact["tags"] << tag_for_slug(legacy_source, "legacy_source")
11
- end
12
- Slimmer::Artefact.new(artefact)
13
- end
14
-
15
- def business_link_artefact
16
- artefact_with_legacy_source_tags(["businesslink"])
17
- end
18
-
19
- def directgov_artefact
20
- artefact_with_legacy_source_tags(["directgov"])
21
- end
22
-
23
- def business_link_and_directgov_artefact
24
- artefact_with_legacy_source_tags(["directgov", "businesslink"])
25
- end
26
-
27
- def process(artefact, template)
28
- Slimmer::Processors::LogoClassInserter.new(artefact).filter(:any_source, template)
29
- end
30
-
31
- def example_template
32
- as_nokogiri %{
33
- <html><body><div><div id="wrapper"></div></div></body></html>
34
- }
35
- end
36
-
37
- it "should add businesslink class to the wrapper" do
38
- template = example_template
39
- process(business_link_artefact, template)
40
- assert_in template, "div#wrapper.businesslink"
41
- end
42
-
43
- it "should add multiple classes to the wrapper" do
44
- template = example_template
45
- artefact = business_link_and_directgov_artefact
46
- process(artefact, template)
47
- assert_in template, "div#wrapper.businesslink.directgov"
48
- end
49
-
50
- it "should ignore non-known tags" do
51
- template = example_template
52
- artefact = artefact_with_legacy_source_tags(["businesslink", "business", "fooey"])
53
- process(artefact, template)
54
- assert_in template, "div#wrapper.businesslink"
55
- assert_not_in template, "div#wrapper.business"
56
- assert_not_in template, "div#wrapper.fooey"
57
- end
58
-
59
- it "should do nothing if the #wrapper element doesn't exist" do
60
- artefact = directgov_artefact
61
- template = as_nokogiri %{
62
- <html><body><div><div id="not_wrapper"></div></div></body></html>
63
- }
64
- process(artefact, template)
65
- assert_in template, "div#not_wrapper"
66
- assert_not_in template, "div#wrapper"
67
- end
68
-
69
- it "should do nothing if the artefact has no tag_ids" do
70
- template = example_template
71
- artefact = Slimmer::Artefact.new(artefact_for_slug("vat"))
72
- process(artefact, template)
73
- assert_in template, "div#wrapper"
74
- end
75
-
76
- it "should not blow up without an artefact" do
77
- template = example_template
78
- processor = Slimmer::Processors::LogoClassInserter.new(nil)
79
- processor.filter(:any_source, template)
80
- end
81
- end