wovnrb 3.10.1 → 3.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wovnrb/services/html_converter.rb +3 -7
- data/lib/wovnrb/version.rb +1 -1
- data/test/lib/services/html_converter_test.rb +20 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9af6b825254ff58bd7415470d312a1618139b2fbfee00e06107cfdb520fcf600
|
4
|
+
data.tar.gz: f02b9eff43c8169550eabb34762cc1483c81e214eee79c6fa5b2712450bb24a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13ae0af14751d63ba2041cf65d8f1810a8cc9350b6ba42885775c0bb2ecddb1691739e66824893f9cb01e2bc91717429722aef6980232a36e97b0bcc02a75232
|
7
|
+
data.tar.gz: df18a70cd886965d4c83d3d34c55023ac41fdcc54f7b4bdf6fc2debd4803ef4c1f1569bf8408db27b0ef1199de51964ca3df65b32083f52705d81864953840ff
|
@@ -42,7 +42,7 @@ module Wovnrb
|
|
42
42
|
|
43
43
|
def transform_html
|
44
44
|
replace_snippet
|
45
|
-
replace_hreflangs
|
45
|
+
replace_hreflangs if @store.settings['insert_hreflangs']
|
46
46
|
inject_lang_html_tag
|
47
47
|
translate_canonical_tag if @store.settings['translate_canonical_tag']
|
48
48
|
end
|
@@ -54,7 +54,7 @@ module Wovnrb
|
|
54
54
|
|
55
55
|
def replace_dom(marker)
|
56
56
|
strip_snippet
|
57
|
-
strip_hreflangs if
|
57
|
+
strip_hreflangs if @store.settings['insert_hreflangs']
|
58
58
|
|
59
59
|
@dom.traverse { |node| transform_node(node, marker) }
|
60
60
|
|
@@ -120,10 +120,6 @@ module Wovnrb
|
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
|
-
def add_hreflang
|
124
|
-
!!(@store && @headers)
|
125
|
-
end
|
126
|
-
|
127
123
|
def inject_lang_html_tag
|
128
124
|
root = @dom.at_css('html')
|
129
125
|
return unless root
|
@@ -134,7 +130,7 @@ module Wovnrb
|
|
134
130
|
|
135
131
|
def replace_hreflangs
|
136
132
|
strip_hreflang_tags
|
137
|
-
insert_hreflang_tags
|
133
|
+
insert_hreflang_tags
|
138
134
|
end
|
139
135
|
|
140
136
|
def strip_hreflang_tags
|
data/lib/wovnrb/version.rb
CHANGED
@@ -462,6 +462,16 @@ module Wovnrb
|
|
462
462
|
assert_equal(expected_html, converted_html)
|
463
463
|
end
|
464
464
|
|
465
|
+
test 'build API compatible html - with insert_hreflangs: false - original hreflangs are not removed' do
|
466
|
+
settings = default_store_settings
|
467
|
+
settings['insert_hreflangs'] = false
|
468
|
+
converter = prepare_html_converter('<html><head><link rel="alternate" hreflang="en" href="http://my-site.com/"><link rel="alternate" hreflang="vi" href="http://my-site.com/?wovn=vi"></head><body><a>hello</a></body></html>', settings)
|
469
|
+
converted_html, = converter.build_api_compatible_html
|
470
|
+
|
471
|
+
expected_html = "<html lang=\"en\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"https://j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><a>hello</a></body></html>"
|
472
|
+
assert_equal(expected_html, converted_html)
|
473
|
+
end
|
474
|
+
|
465
475
|
test 'Transform HTML - with insert_hreflangs: false - hreflangs are not added' do
|
466
476
|
settings = default_store_settings
|
467
477
|
settings['insert_hreflangs'] = false
|
@@ -472,6 +482,16 @@ module Wovnrb
|
|
472
482
|
assert_equal(expected_html, translated_html)
|
473
483
|
end
|
474
484
|
|
485
|
+
test 'Transform HTML - with insert_hreflangs: false - original hreflangs are not removed' do
|
486
|
+
settings = default_store_settings
|
487
|
+
settings['insert_hreflangs'] = false
|
488
|
+
converter = prepare_html_converter('<html><head><link rel="alternate" hreflang="en" href="http://my-site.com/"><link rel="alternate" hreflang="vi" href="http://my-site.com/?wovn=vi"></head><body><a>hello</a></body></html>', settings)
|
489
|
+
translated_html = converter.build
|
490
|
+
|
491
|
+
expected_html = "<html lang=\"en\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"https://j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&langParamName=wovn&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><a>hello</a></body></html>"
|
492
|
+
assert_equal(expected_html, translated_html)
|
493
|
+
end
|
494
|
+
|
475
495
|
private
|
476
496
|
|
477
497
|
def prepare_html_converter(input_html, store_options = {})
|