slimmer 15.5.0 → 15.5.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 +3 -0
- data/lib/slimmer/processors/accounts_shower.rb +10 -1
- data/lib/slimmer/processors/body_inserter.rb +17 -2
- data/lib/slimmer/skin.rb +2 -1
- data/lib/slimmer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9586ef4f9680eee337f141f0ca07d36786edf1a2e42db7324981fe0b7f64fdcd
|
4
|
+
data.tar.gz: 382289841b35dab136c22cefec16581bb5633f0cbe5036b8299e7d4f737c4159
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d065546672150a1ffa4d9ad548881770d9e62438d54902767d5bd9bc5386ae0b6122e6e5bfd3807a183b2aeb8bc131625962fdde64c3aaae4ec99f102dc378f0
|
7
|
+
data.tar.gz: 12bf26edb4237369c579e557e31773deb2341f9b088389c895d73609a860552f8518783589e49f4f7411bb6981b6d45be9c83d9b52336dd65a6d97a0b0bdd8e1
|
data/CHANGELOG.md
CHANGED
@@ -23,8 +23,15 @@ module Slimmer::Processors
|
|
23
23
|
remove_signed_out(dest)
|
24
24
|
remove_signed_in(dest)
|
25
25
|
end
|
26
|
+
|
27
|
+
if is_navigation_empty?(dest)
|
28
|
+
header_content = dest.at_css(".govuk-header__content")
|
29
|
+
header_content.remove if header_content
|
30
|
+
end
|
26
31
|
end
|
27
32
|
|
33
|
+
private
|
34
|
+
|
28
35
|
def remove_signed_out(dest)
|
29
36
|
signed_out = dest.at_css("#global-header #accounts-signed-out")
|
30
37
|
signed_out_link = dest.css(".gem-c-layout-header [data-link-for='accounts-signed-out']")
|
@@ -45,7 +52,9 @@ module Slimmer::Processors
|
|
45
52
|
end
|
46
53
|
end
|
47
54
|
|
48
|
-
|
55
|
+
def is_navigation_empty?(dest)
|
56
|
+
dest.at_css(".govuk-header__navigation a").nil?
|
57
|
+
end
|
49
58
|
|
50
59
|
def is_gem_layout?
|
51
60
|
@headers[Slimmer::Headers::TEMPLATE_HEADER]&.starts_with?("gem_layout")
|
@@ -1,13 +1,28 @@
|
|
1
1
|
module Slimmer::Processors
|
2
2
|
class BodyInserter
|
3
|
-
def initialize(source_id = "wrapper", destination_id = "wrapper")
|
3
|
+
def initialize(source_id = "wrapper", destination_id = "wrapper", headers = {})
|
4
4
|
@source_selector = "#" + source_id
|
5
5
|
@destination_selector = "#" + destination_id
|
6
|
+
@headers = headers
|
6
7
|
end
|
7
8
|
|
8
9
|
def filter(src, dest)
|
9
|
-
|
10
|
+
source_markup = src.at_css(@source_selector)
|
11
|
+
destination_markup = dest.at_css(@destination_selector)
|
12
|
+
|
13
|
+
css_classes = []
|
14
|
+
css_classes << source_markup.attributes["class"].to_s.split(/ +/) if source_markup.has_attribute?("class")
|
15
|
+
css_classes << destination_markup.attributes["class"].to_s.split(/ +/) if destination_markup.has_attribute?("class")
|
16
|
+
|
17
|
+
body = Nokogiri::HTML.fragment(source_markup.to_html)
|
10
18
|
dest.at_css(@destination_selector).replace(body)
|
19
|
+
dest.at_css(@destination_selector).set_attribute("class", css_classes.flatten.uniq.join(" ")) if is_gem_layout? && css_classes.any?
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def is_gem_layout?
|
25
|
+
@headers[Slimmer::Headers::TEMPLATE_HEADER]&.starts_with?("gem_layout")
|
11
26
|
end
|
12
27
|
end
|
13
28
|
end
|
data/lib/slimmer/skin.rb
CHANGED
@@ -101,13 +101,14 @@ module Slimmer
|
|
101
101
|
|
102
102
|
def success(source_request, response, body)
|
103
103
|
wrapper_id = options[:wrapper_id] || "wrapper"
|
104
|
+
template_wrapper_id = "wrapper" # All templates in Static use `#wrapper`
|
104
105
|
|
105
106
|
processors = [
|
106
107
|
Processors::TitleInserter.new,
|
107
108
|
Processors::TagMover.new,
|
108
109
|
Processors::NavigationMover.new(self),
|
109
110
|
Processors::ConditionalCommentMover.new,
|
110
|
-
Processors::BodyInserter.new(wrapper_id),
|
111
|
+
Processors::BodyInserter.new(wrapper_id, template_wrapper_id, response.headers),
|
111
112
|
Processors::BodyClassCopier.new,
|
112
113
|
Processors::InsideHeaderInserter.new,
|
113
114
|
Processors::HeaderContextInserter.new,
|
data/lib/slimmer/version.rb
CHANGED
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.5.
|
4
|
+
version: 15.5.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: 2021-04-
|
11
|
+
date: 2021-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|