slimmer 15.5.1 → 16.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/slimmer/processors/feedback_url_swapper.rb +34 -0
- data/lib/slimmer/processors/metadata_inserter.rb +9 -9
- data/lib/slimmer/processors/search_parameter_inserter.rb +6 -6
- data/lib/slimmer/skin.rb +1 -1
- data/lib/slimmer/version.rb +1 -1
- data/lib/slimmer.rb +1 -1
- metadata +3 -3
- data/lib/slimmer/processors/navigation_mover.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9fa11bce76f394cdd62bf87754f0a9fe701d12318de438129e6d09c8595ce6d
|
4
|
+
data.tar.gz: d12897d944a227f8bef8c7c07038136e598ac2ab6f285698d4a75a70855c716a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6bc30a38aa60c2582b5fb4b7fbdc9c542e4852f75941dc72edf783a145f9a347c4c2ac8afe454b4d130da4767cb22056cea63f6b6866c6cf080c521d0d95b90
|
7
|
+
data.tar.gz: 82a4a80af07e8c9554fab7934a02055b30f125a6239ee429375e7a16d893805ab3ad374f77ca2c4b76cacdba1a4d4010b80ea0c9cd760d4502712ad1bac4502c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# 16.0.1
|
2
|
+
* Resolve Nokogiri deprecation warning (#277)
|
3
|
+
|
4
|
+
# 16.0.0
|
5
|
+
* BREAKING: Remove NavigationMover processor (#275)
|
6
|
+
|
7
|
+
# 15.6.1
|
8
|
+
* Use safe navigation operator in feedback url swapper (#273)
|
9
|
+
|
10
|
+
# 15.6.0
|
11
|
+
|
12
|
+
* Add feedback url swapper (#271)
|
13
|
+
|
1
14
|
# 15.5.1
|
2
15
|
* Update gem_layout template support (#267)
|
3
16
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Slimmer::Processors
|
2
|
+
class FeedbackURLSwapper
|
3
|
+
def initialize(request, headers)
|
4
|
+
@headers = headers
|
5
|
+
@request = request
|
6
|
+
end
|
7
|
+
|
8
|
+
def filter(_src, dest)
|
9
|
+
return dest unless is_gem_layout?
|
10
|
+
|
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)
|
13
|
+
|
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)
|
16
|
+
|
17
|
+
dest
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# This PII removal is also found in the [feedback component in the GOV.UK
|
23
|
+
# Publishing Components gem](https://git.io/JcCIE), and any changes made
|
24
|
+
# need to be kept in sync.
|
25
|
+
def remove_pii(string)
|
26
|
+
email_regex = /[^\s=\/?&]+(?:@|%40)[^\s=\/?&]+/
|
27
|
+
string.dup.force_encoding("UTF-8").gsub(email_regex, "[email]")
|
28
|
+
end
|
29
|
+
|
30
|
+
def is_gem_layout?
|
31
|
+
@headers[Slimmer::Headers::TEMPLATE_HEADER]&.starts_with?("gem_layout")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -5,21 +5,21 @@ module Slimmer::Processors
|
|
5
5
|
@app_name = app_name
|
6
6
|
end
|
7
7
|
|
8
|
-
def filter(
|
9
|
-
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",
|
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(
|
10
|
-
search_form =
|
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",
|
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,9 +106,9 @@ 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),
|
111
|
+
Processors::FeedbackURLSwapper.new(source_request, response.headers),
|
112
112
|
Processors::BodyClassCopier.new,
|
113
113
|
Processors::InsideHeaderInserter.new,
|
114
114
|
Processors::HeaderContextInserter.new,
|
data/lib/slimmer/version.rb
CHANGED
data/lib/slimmer.rb
CHANGED
@@ -32,10 +32,10 @@ module Slimmer
|
|
32
32
|
autoload :BodyClassCopier, "slimmer/processors/body_class_copier"
|
33
33
|
autoload :BodyInserter, "slimmer/processors/body_inserter"
|
34
34
|
autoload :ConditionalCommentMover, "slimmer/processors/conditional_comment_mover"
|
35
|
+
autoload :FeedbackURLSwapper, "slimmer/processors/feedback_url_swapper"
|
35
36
|
autoload :MetadataInserter, "slimmer/processors/metadata_inserter"
|
36
37
|
autoload :HeaderContextInserter, "slimmer/processors/header_context_inserter"
|
37
38
|
autoload :InsideHeaderInserter, "slimmer/processors/inside_header_inserter"
|
38
|
-
autoload :NavigationMover, "slimmer/processors/navigation_mover"
|
39
39
|
autoload :SearchPathSetter, "slimmer/processors/search_path_setter"
|
40
40
|
autoload :SearchParameterInserter, "slimmer/processors/search_parameter_inserter"
|
41
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:
|
4
|
+
version: 16.0.1
|
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:
|
11
|
+
date: 2022-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -256,10 +256,10 @@ files:
|
|
256
256
|
- lib/slimmer/processors/body_class_copier.rb
|
257
257
|
- lib/slimmer/processors/body_inserter.rb
|
258
258
|
- lib/slimmer/processors/conditional_comment_mover.rb
|
259
|
+
- lib/slimmer/processors/feedback_url_swapper.rb
|
259
260
|
- lib/slimmer/processors/header_context_inserter.rb
|
260
261
|
- lib/slimmer/processors/inside_header_inserter.rb
|
261
262
|
- lib/slimmer/processors/metadata_inserter.rb
|
262
|
-
- lib/slimmer/processors/navigation_mover.rb
|
263
263
|
- lib/slimmer/processors/search_parameter_inserter.rb
|
264
264
|
- lib/slimmer/processors/search_path_setter.rb
|
265
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
|