wovnrb 0.1.74 → 0.1.75
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wovnrb/version.rb +1 -1
- data/lib/wovnrb.rb +4 -4
- data/test/lib/wovnrb_test.rb +23 -5
- 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: 37a05795a25eed03a2e212e5291760287dadbacf
|
4
|
+
data.tar.gz: cc4b37b9a59a19807a8eb0baecc4cf1a2e0bb4d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27b1226fe54882b00d0857b6dba8cfaa2792bc75d1d30e1f0f32af87a50bbc4b2bddd39002efacc2ca0409c9bbf2e6319b9e74d7d38698612542866fcec9b052
|
7
|
+
data.tar.gz: c2bc66eba4d4d7d151e64cbeb6817b2bac3649f04773d3f81ca8dc4c7113a19ff3c25117785507a4062bb3bd5608c0b663139f4da64271441edb3f99304f4924
|
data/lib/wovnrb/version.rb
CHANGED
data/lib/wovnrb.rb
CHANGED
@@ -25,7 +25,7 @@ module Wovnrb
|
|
25
25
|
if STORE.settings['test_mode'] && STORE.settings['test_url'] != headers.url
|
26
26
|
return @app.call(env)
|
27
27
|
end
|
28
|
-
|
28
|
+
#redirect if the path is set to the default language (for SEO purposes)
|
29
29
|
if (headers.path_lang == STORE.settings['default_lang'])
|
30
30
|
redirect_headers = headers.redirect(STORE.settings['default_lang'])
|
31
31
|
return [307, redirect_headers, ['']]
|
@@ -96,7 +96,7 @@ module Wovnrb
|
|
96
96
|
new_href = lang_url + current_dir + '/' + href.gsub(/^\.\//, '')
|
97
97
|
elsif href =~ /^\/.*$/
|
98
98
|
# /path
|
99
|
-
new_href = lang_url +
|
99
|
+
new_href = lang_url + href
|
100
100
|
else
|
101
101
|
# path
|
102
102
|
new_href = lang_url + current_dir + '/' + href
|
@@ -193,7 +193,7 @@ module Wovnrb
|
|
193
193
|
|
194
194
|
# REMOVE WIDGET
|
195
195
|
d.xpath('//script').each do |script_node|
|
196
|
-
if script_node['src'] && script_node['src'].include?('//j.wovn.io
|
196
|
+
if script_node['src'] && script_node['src'].include?('//j.(dev-)?wovn.io(:3000)?/')
|
197
197
|
script_node.remove
|
198
198
|
end
|
199
199
|
end
|
@@ -205,7 +205,7 @@ module Wovnrb
|
|
205
205
|
insert_node = Nokogiri::XML::Node.new('script', d)
|
206
206
|
# TODO: CHANGE THIS BACK; Should be '//j.wovn.io/0' in production
|
207
207
|
insert_node['src'] = '//j.wovn.io/0'
|
208
|
-
#
|
208
|
+
#insert_node['src'] = '//j.dev-wovn.io:3000/0'
|
209
209
|
version = defined?(VERSION) ? VERSION : ''
|
210
210
|
insert_node['data-wovnio'] = "key=#{STORE.settings['user_token']}&backend=true¤tLang=#{lang}&defaultLang=#{STORE.settings['default_lang']}&urlPattern=#{STORE.settings['url_pattern']}&version=#{version}"
|
211
211
|
# do this so that there will be a closing tag (better compatibility with browsers)
|
data/test/lib/wovnrb_test.rb
CHANGED
@@ -32,6 +32,24 @@ class WovnrbTest < Minitest::Test
|
|
32
32
|
assert_equal("http://www.facebook.com", i.add_lang_code("http://www.facebook.com", 'subdomain', 'zh-cht', h))
|
33
33
|
end
|
34
34
|
|
35
|
+
def test_add_lang_code_relative_slash_href_url_with_path
|
36
|
+
i = Wovnrb::Interceptor.new(get_app)
|
37
|
+
h = Wovnrb::Headers.new(get_env('url' => 'http://fr.favy.tips/topics/44'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
38
|
+
assert_equal("http://fr.favy.tips/topics/50", i.add_lang_code("/topics/50", 'subdomain', 'fr', h))
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_add_lang_code_relative_dot_href_url_with_path
|
42
|
+
i = Wovnrb::Interceptor.new(get_app)
|
43
|
+
h = Wovnrb::Headers.new(get_env('url' => 'http://fr.favy.tips/topics/44'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
44
|
+
assert_equal("http://fr.favy.tips/topics/44/topics/50", i.add_lang_code("./topics/50", 'subdomain', 'fr', h))
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_add_lang_code_relative_two_dots_href_url_with_path
|
48
|
+
i = Wovnrb::Interceptor.new(get_app)
|
49
|
+
h = Wovnrb::Headers.new(get_env('url' => 'http://fr.favy.tips/topics/44'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
50
|
+
assert_equal("http://fr.favy.tips/topics/50", i.add_lang_code("../topics/50", 'subdomain', 'fr', h))
|
51
|
+
end
|
52
|
+
|
35
53
|
def test_add_lang_code_trad_chinese
|
36
54
|
i = Wovnrb::Interceptor.new(get_app)
|
37
55
|
h = Wovnrb::Headers.new(get_env('url' => 'http://favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
@@ -319,15 +337,15 @@ class WovnrbTest < Minitest::Test
|
|
319
337
|
when "value_double_quote"
|
320
338
|
body = "<html><body><h1>Mr.BelvedereFanClub</h1><div wovn-ignore=\"value\"><p>Hello</p></div></body></html>"
|
321
339
|
when "empty_translated"
|
322
|
-
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/0\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version
|
340
|
+
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/0\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"\"><p>Hello</p></div>\n</body>\n</html>\n"
|
323
341
|
when "empty_single_quote_translated"
|
324
|
-
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/0\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version
|
342
|
+
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/0\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"\"><p>Hello</p></div>\n</body>\n</html>\n"
|
325
343
|
when "empty_double_quote_translated"
|
326
|
-
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/0\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version
|
344
|
+
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/0\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"\"><p>Hello</p></div>\n</body>\n</html>\n"
|
327
345
|
when "value_single_quote_translated"
|
328
|
-
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/0\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version
|
346
|
+
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/0\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"value\"><p>Hello</p></div>\n</body>\n</html>\n"
|
329
347
|
when "value_double_quote_translated"
|
330
|
-
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/0\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version
|
348
|
+
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/0\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"value\"><p>Hello</p></div>\n</body>\n</html>\n"
|
331
349
|
else # "" case
|
332
350
|
body = "<html><body><h1>Mr. Belvedere Fan Club</h1>
|
333
351
|
<div><p>Hello</p></div>
|
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: 0.1.
|
4
|
+
version: 0.1.75
|
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: 2015-11-
|
12
|
+
date: 2015-11-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogumbo
|