wovnrb 0.2.03 → 0.2.04
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +8 -8
- data/lib/wovnrb/headers.rb +5 -0
- data/lib/wovnrb/version.rb +1 -1
- data/test/lib/headers_test.rb +44 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b14f7b1db39f462612fbfb5437c8b9a57ab0545
|
4
|
+
data.tar.gz: 216b7d095a9ab39fe039ecd7a86cb421f93edbba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03c36df5a7edb5fc443124eafdf338d272d009b7c612188512cf24ec272f68538808b4c7dd312fa37822b96cf25200afde4185a6c8c6593d9939f00a1f0e5015
|
7
|
+
data.tar.gz: 79114a464d34be6fb01dd0091bec13f58823d14f61f6308a964cff85cf24d69f43b35838e4bde1ab80eddc49aede2fe984a82a5057276bedce15d98e5d7d4ac8
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -38,8 +38,8 @@ Insert the following into either config/application.rb or config/environments/.
|
|
38
38
|
...
|
39
39
|
|
40
40
|
config.wovnrb = {
|
41
|
-
:user_token => '2Wle3',
|
42
|
-
:secret_key => 'secret',
|
41
|
+
:user_token => '2Wle3',
|
42
|
+
:secret_key => 'secret',
|
43
43
|
}
|
44
44
|
|
45
45
|
...
|
@@ -55,8 +55,8 @@ Insert the following into either the Application File or config.ru.
|
|
55
55
|
require 'wovnrb'
|
56
56
|
|
57
57
|
use Wovnrb::Interceptor, {
|
58
|
-
:user_token => '2Wle3',
|
59
|
-
:secret_key => 'secret',
|
58
|
+
:user_token => '2Wle3',
|
59
|
+
:secret_key => 'secret',
|
60
60
|
}
|
61
61
|
|
62
62
|
...
|
@@ -100,15 +100,15 @@ parameters | Translated page's URL | Notes
|
|
100
100
|
|
101
101
|
### 2.4. query
|
102
102
|
|
103
|
-
|
103
|
+
WOVN.io ignores query parameters when searching translated page. If you want to add query parameter to translated page's URL, you should configure "query" parameter. (You need to configure WOVN.io too)
|
104
104
|
|
105
105
|
https://wovn.io/ja/contact?os=mac&keyboard=us
|
106
106
|
|
107
|
-
If the defualt_lang is 'en', and the query is set to '
|
107
|
+
If the defualt_lang is 'en', and the query is set to '', the above URL will be modified into the following URL to search for the page's translation.
|
108
108
|
|
109
|
-
https://wovn.io/contact
|
109
|
+
https://wovn.io/contact
|
110
110
|
|
111
|
-
If the default_lang is 'en', and the query is set to 'os
|
111
|
+
If the default_lang is 'en', and the query is set to 'os', the above URL will be modified into the following URL to search for the page's translation.
|
112
112
|
|
113
113
|
https://wovn.io/contact?os=mac
|
114
114
|
|
data/lib/wovnrb/headers.rb
CHANGED
@@ -55,6 +55,8 @@ module Wovnrb
|
|
55
55
|
end
|
56
56
|
if query_vals.length > 0
|
57
57
|
@query = "?#{query_vals.sort.join('&')}"
|
58
|
+
else
|
59
|
+
@query = ''
|
58
60
|
end
|
59
61
|
else
|
60
62
|
@query = ''
|
@@ -170,6 +172,9 @@ module Wovnrb
|
|
170
172
|
if @env.has_key?('ORIGINAL_FULLPATH')
|
171
173
|
@env['ORIGINAL_FULLPATH'] = remove_lang(@env['ORIGINAL_FULLPATH'])
|
172
174
|
end
|
175
|
+
if @env.has_key?('HTTP_REFERER')
|
176
|
+
@env["HTTP_REFERER"] = remove_lang(@env["HTTP_REFERER"])
|
177
|
+
end
|
173
178
|
end
|
174
179
|
@env
|
175
180
|
end
|
data/lib/wovnrb/version.rb
CHANGED
data/test/lib/headers_test.rb
CHANGED
@@ -82,7 +82,25 @@ class HeadersTest < Minitest::Test
|
|
82
82
|
assert_equal('wovn.io', h.unmasked_host)
|
83
83
|
assert_equal('localhost', env['HTTP_HOST'])
|
84
84
|
assert_equal('localhost', env['SERVER_NAME'])
|
85
|
-
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_initialize_without_query
|
88
|
+
env = Wovnrb.get_env
|
89
|
+
h = Wovnrb::Headers.new(env, Wovnrb.get_settings)
|
90
|
+
assert_equal('wovn.io/dashboard', h.redis_url)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_initialize_with_query
|
94
|
+
env = Wovnrb.get_env
|
95
|
+
h = Wovnrb::Headers.new(env, Wovnrb.get_settings('query' => ['param']))
|
96
|
+
assert_equal('wovn.io/dashboard?param=val', h.redis_url)
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_initialize_with_not_matching_query
|
100
|
+
env = Wovnrb.get_env
|
101
|
+
h = Wovnrb::Headers.new(env, Wovnrb.get_settings('query' => ['aaa']))
|
102
|
+
assert_equal('wovn.io/dashboard', h.redis_url)
|
103
|
+
end
|
86
104
|
|
87
105
|
#########################
|
88
106
|
# REQUEST_OUT
|
@@ -106,6 +124,31 @@ class HeadersTest < Minitest::Test
|
|
106
124
|
assert_equal('wovn.io', env['HTTP_X_FORWARDED_HOST'])
|
107
125
|
end
|
108
126
|
|
127
|
+
def test_request_out_http_referer_subdomain
|
128
|
+
h = Wovnrb::Headers.new(
|
129
|
+
Wovnrb.get_env(
|
130
|
+
'SERVER_NAME' => 'ja.wovn.io',
|
131
|
+
'REQUEST_URI' => '/test',
|
132
|
+
'HTTP_REFERER' => 'http://ja.wovn.io/test',
|
133
|
+
),
|
134
|
+
Wovnrb.get_settings(
|
135
|
+
'url_pattern' => 'subdomain',
|
136
|
+
'url_pattern_reg' => '^(?<lang>[^.]+).',
|
137
|
+
),
|
138
|
+
)
|
139
|
+
env = h.request_out('ja')
|
140
|
+
assert_equal('http://wovn.io/test', env['HTTP_REFERER'])
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_request_out_http_referer_path
|
144
|
+
h = Wovnrb::Headers.new(
|
145
|
+
Wovnrb.get_env('REQUEST_URI' => '/ja/test', 'HTTP_REFERER' => 'http://wovn.io/ja/test'),
|
146
|
+
Wovnrb.get_settings,
|
147
|
+
)
|
148
|
+
env = h.request_out('ja')
|
149
|
+
assert_equal('http://wovn.io/test', env['HTTP_REFERER'])
|
150
|
+
end
|
151
|
+
|
109
152
|
#########################
|
110
153
|
# GET SETTINGS
|
111
154
|
#########################
|
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.2.
|
4
|
+
version: 0.2.04
|
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: 2016-
|
12
|
+
date: 2016-05-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogumbo
|
@@ -350,7 +350,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
350
350
|
version: '0'
|
351
351
|
requirements: []
|
352
352
|
rubyforge_project:
|
353
|
-
rubygems_version: 2.
|
353
|
+
rubygems_version: 2.2.0
|
354
354
|
signing_key:
|
355
355
|
specification_version: 4
|
356
356
|
summary: Gem for WOVN.io
|
@@ -374,3 +374,4 @@ test_files:
|
|
374
374
|
- test/lib/wovnrb_test.rb
|
375
375
|
- test/services/url_test.rb
|
376
376
|
- test/test_helper.rb
|
377
|
+
has_rdoc:
|