slimmer 15.6.0 → 17.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f9dab4037bbee9ec372a2d3093b8645d973ef8db63c8accd2d83bfb6a0f0e46
4
- data.tar.gz: e8551a6f783608f5216ef2caa3ab23b7f15c6e8dca7ef27d1e7cad5b0f58fa2c
3
+ metadata.gz: 0a6d7eb900be169022598a1a09b96d08394d90e55ca451e611bc9de803f900f0
4
+ data.tar.gz: 71243a607e6868ae847544cc1ed6d30acdf031f41b0572ac309fccf93e2814db
5
5
  SHA512:
6
- metadata.gz: 5644a0a8217c1774a288573c9c6953db43c9f8a7b9f6d629a5515a79b953f05f4013cd9e7d55405f6df7e536213569d3e400ec5ae751e5b4a46828a4c93e81f4
7
- data.tar.gz: b5e5d006ad1c69f687efc1201a13b3da4dd5efcbe6620cebf181a4fee49d4bebfc18beb15f2e9b370835c955baa58fa9b79d992d8c4e89484cab2e49c8734733
6
+ metadata.gz: 3d986e7ec508d57b6d949272db05a0a5b25184ffe9195760671d1e72dc5f6397857ae0f5dc35936749ca0eb1cb7880e750a72f36a83d5dddc9792eada2349694
7
+ data.tar.gz: 50f88ad62bb6530f70a8684f7427ce9933525440fbc131669526fc65ebdd8502c7d1e247771a54989842d77be31230b1e60b7f0692b3b5e91fa5767dbff5f73b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ # 17.0.0
2
+
3
+ * BREAKING: Set default template to `gem_layout` and remove references to the deprecated `core_layout`.
4
+
5
+ # 16.0.1
6
+ * Resolve Nokogiri deprecation warning (#277)
7
+
8
+ # 16.0.0
9
+ * BREAKING: Remove NavigationMover processor (#275)
10
+
11
+ # 15.6.1
12
+ * Use safe navigation operator in feedback url swapper (#273)
13
+
1
14
  # 15.6.0
2
15
 
3
16
  * Add feedback url swapper (#271)
data/README.md CHANGED
@@ -57,6 +57,10 @@ class ApplicationController < ActionController::Base
57
57
  end
58
58
  ```
59
59
 
60
+ ## Use in before_action renders
61
+
62
+ If you have a non-default layout and want to render in a before_action method, note that you may have to explicitly call `slimmer_template(:your_template_name)` in the action before rendering. Rendering in a before_action immediately stops the action chain, and since slimmer usually calls slimmer_template as an after_action, it would be skipped over (and you'd get the default layout).
63
+
60
64
  ## Logging
61
65
 
62
66
  Slimmer can be configured with a logger by passing in a logger instance
@@ -9,10 +9,10 @@ module Slimmer::Processors
9
9
  return dest unless is_gem_layout?
10
10
 
11
11
  original_url_without_pii = remove_pii(@request.base_url + @request.fullpath)
12
- dest.at_css(".gem-c-feedback input[name='url']").set_attribute("value", original_url_without_pii)
12
+ dest.at_css(".gem-c-feedback input[name='url']")&.set_attribute("value", original_url_without_pii)
13
13
 
14
14
  full_path_without_pii = remove_pii(@request.fullpath)
15
- dest.at_css(".gem-c-feedback input[name='email_survey_signup[survey_source]']").set_attribute("value", full_path_without_pii)
15
+ dest.at_css(".gem-c-feedback input[name='email_survey_signup[survey_source]']")&.set_attribute("value", full_path_without_pii)
16
16
 
17
17
  dest
18
18
  end
@@ -5,21 +5,21 @@ module Slimmer::Processors
5
5
  @app_name = app_name
6
6
  end
7
7
 
8
- def filter(_src, dest)
9
- head = dest.at_css("head")
8
+ def filter(_old_doc, new_doc)
9
+ head = new_doc.at_css("head")
10
10
 
11
- add_meta_tag("analytics:organisations", @headers[Slimmer::Headers::ORGANISATIONS_HEADER], head)
12
- add_meta_tag("analytics:world-locations", @headers[Slimmer::Headers::WORLD_LOCATIONS_HEADER], head)
13
- add_meta_tag("format", @headers[Slimmer::Headers::FORMAT_HEADER], head)
14
- add_meta_tag("search-result-count", @headers[Slimmer::Headers::RESULT_COUNT_HEADER], head)
15
- add_meta_tag("rendering-application", @app_name, head)
11
+ add_meta_tag("analytics:organisations", @headers[Slimmer::Headers::ORGANISATIONS_HEADER], head, new_doc)
12
+ add_meta_tag("analytics:world-locations", @headers[Slimmer::Headers::WORLD_LOCATIONS_HEADER], head, new_doc)
13
+ add_meta_tag("format", @headers[Slimmer::Headers::FORMAT_HEADER], head, new_doc)
14
+ add_meta_tag("search-result-count", @headers[Slimmer::Headers::RESULT_COUNT_HEADER], head, new_doc)
15
+ add_meta_tag("rendering-application", @app_name, head, new_doc)
16
16
  end
17
17
 
18
18
  private
19
19
 
20
- def add_meta_tag(name, content, head)
20
+ def add_meta_tag(name, content, head, doc)
21
21
  if content
22
- meta_node = Nokogiri::XML::Node.new("meta", head)
22
+ meta_node = Nokogiri::XML::Node.new("meta", doc)
23
23
  meta_node["name"] = "govuk:#{name}"
24
24
  meta_node["content"] = content
25
25
 
@@ -6,25 +6,25 @@ module Slimmer::Processors
6
6
  @response = response
7
7
  end
8
8
 
9
- def filter(_content_document, page_template)
10
- search_form = page_template.at_css("form#search")
9
+ def filter(_old_doc, new_doc)
10
+ search_form = new_doc.at_css("form#search")
11
11
  if search_parameters && search_form
12
12
  search_parameters.each_pair do |name, value|
13
13
  # Value can either be a string or an array of values
14
14
  if value.is_a? Array
15
15
  array_name = "#{name}[]"
16
16
  value.each do |array_value|
17
- add_hidden_input(search_form, array_name, array_value)
17
+ add_hidden_input(search_form, array_name, array_value, new_doc)
18
18
  end
19
19
  else
20
- add_hidden_input(search_form, name, value)
20
+ add_hidden_input(search_form, name, value, new_doc)
21
21
  end
22
22
  end
23
23
  end
24
24
  end
25
25
 
26
- def add_hidden_input(search_form, name, value)
27
- element = Nokogiri::XML::Node.new("input", search_form)
26
+ def add_hidden_input(search_form, name, value, doc)
27
+ element = Nokogiri::XML::Node.new("input", doc)
28
28
  element["type"] = "hidden"
29
29
  element["name"] = name
30
30
  element["value"] = value.to_s
data/lib/slimmer/skin.rb CHANGED
@@ -106,7 +106,6 @@ module Slimmer
106
106
  processors = [
107
107
  Processors::TitleInserter.new,
108
108
  Processors::TagMover.new,
109
- Processors::NavigationMover.new(self),
110
109
  Processors::ConditionalCommentMover.new,
111
110
  Processors::BodyInserter.new(wrapper_id, template_wrapper_id, response.headers),
112
111
  Processors::FeedbackURLSwapper.new(source_request, response.headers),
@@ -120,7 +119,7 @@ module Slimmer
120
119
  Processors::AccountsShower.new(response.headers),
121
120
  ]
122
121
 
123
- template_name = response.headers[Headers::TEMPLATE_HEADER] || "core_layout"
122
+ template_name = response.headers[Headers::TEMPLATE_HEADER] || "gem_layout"
124
123
  process(processors, body, template(template_name), source_request.env)
125
124
  end
126
125
  end
@@ -1,3 +1,3 @@
1
1
  module Slimmer
2
- VERSION = "15.6.0".freeze
2
+ VERSION = "17.0.0".freeze
3
3
  end
data/lib/slimmer.rb CHANGED
@@ -36,7 +36,6 @@ module Slimmer
36
36
  autoload :MetadataInserter, "slimmer/processors/metadata_inserter"
37
37
  autoload :HeaderContextInserter, "slimmer/processors/header_context_inserter"
38
38
  autoload :InsideHeaderInserter, "slimmer/processors/inside_header_inserter"
39
- autoload :NavigationMover, "slimmer/processors/navigation_mover"
40
39
  autoload :SearchPathSetter, "slimmer/processors/search_path_setter"
41
40
  autoload :SearchParameterInserter, "slimmer/processors/search_parameter_inserter"
42
41
  autoload :SearchRemover, "slimmer/processors/search_remover"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slimmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.6.0
4
+ version: 17.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-01 00:00:00.000000000 Z
11
+ date: 2022-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -260,7 +260,6 @@ files:
260
260
  - lib/slimmer/processors/header_context_inserter.rb
261
261
  - lib/slimmer/processors/inside_header_inserter.rb
262
262
  - lib/slimmer/processors/metadata_inserter.rb
263
- - lib/slimmer/processors/navigation_mover.rb
264
263
  - lib/slimmer/processors/search_parameter_inserter.rb
265
264
  - lib/slimmer/processors/search_path_setter.rb
266
265
  - lib/slimmer/processors/search_remover.rb
@@ -1,24 +0,0 @@
1
- class Slimmer::Processors::NavigationMover
2
- def initialize(skin)
3
- @skin = skin
4
- end
5
-
6
- def filter(src, dest)
7
- proposition_header = src.at_css("#proposition-menu")
8
- global_header = dest.at_css("#global-header")
9
- if proposition_header && global_header
10
- proposition_header.remove
11
-
12
- global_header["class"] = [global_header["class"], "with-proposition"].compact.join(" ")
13
-
14
- header_block = Nokogiri::HTML.fragment(proposition_header_block)
15
- header_block.at_css(".content") << proposition_header
16
-
17
- global_header.at_css(".header-wrapper") << header_block
18
- end
19
- end
20
-
21
- def proposition_header_block
22
- @proposition_header_block ||= @skin.template("proposition_menu")
23
- end
24
- end