wovnrb 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 664891e7c37cb4963af455731e9887e3a7a8465e
|
4
|
+
data.tar.gz: 52001654f1c0b5d73a2c12f0e5701840a36f1275
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76ab34adcf751b8025b7855103e2453f7e320549d49609af352971ed56169757661fbd990fe2a471a40eb6cf14a8d490966b3bf1199137bc0c511735fdd06aef
|
7
|
+
data.tar.gz: b36b536fc41e431c1df4384a61fcf832b8eb90e78aeec85c8ac657ad3d204ec22f7174c8fc737988193582e8b8183a2e16ee3f9aabb06a228d144864b4e78d61
|
@@ -14,7 +14,7 @@ module Wovnrb
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def replace(dom, lang)
|
17
|
-
dom.xpath('
|
17
|
+
dom.xpath('//*[match(.)]', MultiTagMatcher.new).each do |node|
|
18
18
|
next if wovn_ignore?(node)
|
19
19
|
|
20
20
|
href = node.get_attribute('href')
|
@@ -34,4 +34,18 @@ module Wovnrb
|
|
34
34
|
href =~ img_files || href =~ audio_files || href =~ video_files || href =~ doc_files
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
class MultiTagMatcher
|
39
|
+
def match(node_set)
|
40
|
+
node_set.find_all { |node| a_tag?(node) || link_tag_with_canonical?(node) }
|
41
|
+
end
|
42
|
+
|
43
|
+
def a_tag?(node)
|
44
|
+
node.name == 'a'
|
45
|
+
end
|
46
|
+
|
47
|
+
def link_tag_with_canonical?(node)
|
48
|
+
node.name == 'link' && node.get_attribute('rel') == 'canonical'
|
49
|
+
end
|
50
|
+
end
|
37
51
|
end
|
data/lib/wovnrb/version.rb
CHANGED
@@ -106,6 +106,24 @@ module Wovnrb
|
|
106
106
|
assert_equal('/en/index.html', link)
|
107
107
|
end
|
108
108
|
|
109
|
+
def test_replace_link_path_with_canonical
|
110
|
+
store = Store.instance
|
111
|
+
replacer = LinkReplacer.new(store, 'path', get_header)
|
112
|
+
dom = Wovnrb.get_dom('<html><head><link rel="canonical" href="http://favy.tips/hello/index.html"></head><body>hello</body></html>')
|
113
|
+
replacer.replace(dom, Lang.new('en'))
|
114
|
+
canonical_href = dom.xpath('//link').find { |d| d.attributes['rel'].value == 'canonical' }.attributes['href'].value
|
115
|
+
assert_equal('http://favy.tips/en/hello/index.html', canonical_href)
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_replace_link_with_style
|
119
|
+
store = Store.instance
|
120
|
+
replacer = LinkReplacer.new(store, 'path', get_header)
|
121
|
+
dom = Wovnrb.get_dom('<html><head><link rel="stylesheet" type="text/css" href="http://favy.tips/hello/index.css"></head><body>hello</body></html>')
|
122
|
+
replacer.replace(dom, Lang.new('en'))
|
123
|
+
href = dom.xpath('//link').find { |d| d.attributes['rel'].value == 'stylesheet' }.attributes['href'].value
|
124
|
+
assert_equal('http://favy.tips/hello/index.css', href, 'Should not change the href')
|
125
|
+
end
|
126
|
+
|
109
127
|
def test_replace_img_link_path
|
110
128
|
store = Store.instance
|
111
129
|
replacer = LinkReplacer.new(store, 'path', get_header)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wovnrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Sandford
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-09-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogumbo
|
@@ -412,7 +412,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
412
412
|
version: '0'
|
413
413
|
requirements: []
|
414
414
|
rubyforge_project:
|
415
|
-
rubygems_version: 2.
|
415
|
+
rubygems_version: 2.2.0
|
416
416
|
signing_key:
|
417
417
|
specification_version: 4
|
418
418
|
summary: Gem for WOVN.io
|