slimmer 12.0.0 → 12.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/slimmer/processors/tag_mover.rb +12 -7
- data/lib/slimmer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fe9e4eda5103f993a3fa049fe354360ee1d61ea
|
4
|
+
data.tar.gz: b674f301bcc0452d3ce81634a4ab280625b6d69d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 130dff1f1186dce4297636f1bdb037f0a1d6448f61cd14a28bda29447ca41d310a92e9afa1952d1dc43adbe651d15645ee8434756fa65d0933009f4591f5b4b1
|
7
|
+
data.tar.gz: bddee67fbe4cef3c30bbc058c7bdec7cecd0d2974d802877190bba9131c3ce1051311fa8dfdcb72cd6723b519d898f95bf79127cb9b30fdd0730de6cda6cdb80
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# 12.1.0
|
2
|
+
|
3
|
+
* Make sure that the metatags defined in the application are inserted at the
|
4
|
+
top of the page. This means that third parties will see the custom metatags
|
5
|
+
like `og:image` first, and template tags like the default sharing image second (#218)
|
6
|
+
|
1
7
|
# 12.0.0
|
2
8
|
|
3
9
|
* Remove the "report a problem" feature. This is now being covered by the
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Slimmer::Processors
|
2
2
|
class TagMover
|
3
|
-
def filter(src,dest)
|
4
|
-
move_tags(src, dest, 'script', :
|
5
|
-
move_tags(src, dest, 'link', :
|
6
|
-
move_tags(src, dest, 'meta', :
|
7
|
-
move_tags(src, dest, 'meta', :
|
3
|
+
def filter(src, dest)
|
4
|
+
move_tags(src, dest, 'script', dest_node: 'body', keys: %w(src inner_html))
|
5
|
+
move_tags(src, dest, 'link', must_have: ['href'])
|
6
|
+
move_tags(src, dest, 'meta', must_have: %w(name content), keys: ['name', 'content', 'http-equiv'], insertion_location: :top)
|
7
|
+
move_tags(src, dest, 'meta', must_have: %w(property content), keys: %w(property content), insertion_location: :top)
|
8
8
|
end
|
9
9
|
|
10
10
|
def include_tag?(node, min_attrs)
|
@@ -22,7 +22,7 @@ module Slimmer::Processors
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def wrap_node(src, node)
|
25
|
-
if node.previous_sibling.to_s =~ /<!--\[if[^\]]+\]><!-->/
|
25
|
+
if node.previous_sibling.to_s =~ /<!--\[if[^\]]+\]><!-->/ && node.next_sibling.to_s == '<!--<![endif]-->'
|
26
26
|
node = Nokogiri::XML::NodeSet.new(src, [node.previous_sibling, node, node.next_sibling])
|
27
27
|
end
|
28
28
|
node
|
@@ -40,7 +40,12 @@ module Slimmer::Processors
|
|
40
40
|
if include_tag?(node, min_attrs) && !already_there.include?(tag_fingerprint(node, comparison_attrs))
|
41
41
|
node = wrap_node(src, node)
|
42
42
|
node.remove
|
43
|
-
|
43
|
+
|
44
|
+
if opts[:insertion_location] == :top
|
45
|
+
dest.at_xpath("/html/#{dest_node}").prepend_child(node)
|
46
|
+
else
|
47
|
+
dest.at_xpath("/html/#{dest_node}") << node
|
48
|
+
end
|
44
49
|
end
|
45
50
|
end
|
46
51
|
end
|
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: 12.
|
4
|
+
version: 12.1.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: 2018-
|
11
|
+
date: 2018-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|