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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55f0a341bbb309da449a52a668b281087674586c
4
- data.tar.gz: e090f9302dfd9dea5d91184a50942bfe9751bd02
3
+ metadata.gz: 4fe9e4eda5103f993a3fa049fe354360ee1d61ea
4
+ data.tar.gz: b674f301bcc0452d3ce81634a4ab280625b6d69d
5
5
  SHA512:
6
- metadata.gz: 464f4d805159cd667d1cdc3478fba42e18741e4f7d3978c717b608098099fb3b87f56b83c9b31f61ee8bd2fa1acaf7778ab62be006d363365bd673162b2d18ad
7
- data.tar.gz: 7aa2bb20cb3c5a3151949436d6e2d36cae311ee31552ef17cb7e254f2a2569c93205dec13b0e5baf6e155c862714af4a1ec6379165cd23275929ffcec2bec1b7
6
+ metadata.gz: 130dff1f1186dce4297636f1bdb037f0a1d6448f61cd14a28bda29447ca41d310a92e9afa1952d1dc43adbe651d15645ee8434756fa65d0933009f4591f5b4b1
7
+ data.tar.gz: bddee67fbe4cef3c30bbc058c7bdec7cecd0d2974d802877190bba9131c3ce1051311fa8dfdcb72cd6723b519d898f95bf79127cb9b30fdd0730de6cda6cdb80
@@ -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', :dest_node => 'body', :keys => ['src', 'inner_html'])
5
- move_tags(src, dest, 'link', :must_have => ['href'])
6
- move_tags(src, dest, 'meta', :must_have => ['name', 'content'], :keys => ['name', 'content', 'http-equiv'])
7
- move_tags(src, dest, 'meta', :must_have => ['property', 'content'], :keys => ['property', 'content'])
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[^\]]+\]><!-->/ and node.next_sibling.to_s == '<!--<![endif]-->'
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
- dest.at_xpath("/html/#{dest_node}") << node
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
@@ -1,3 +1,3 @@
1
1
  module Slimmer
2
- VERSION = '12.0.0'
2
+ VERSION = '12.1.0'
3
3
  end
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.0.0
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-02-15 00:00:00.000000000 Z
11
+ date: 2018-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri