wovnrb 2.5.1 → 2.6.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
  SHA256:
3
- metadata.gz: a1667b83e9b8a2a2a79d1c152c71fac66ecc1acfe98b53f062e6929dda1d267c
4
- data.tar.gz: 6fe79d1445f3e87ebd65e9d5beca3c173da6e3ae25e92de97c9b85bed95c8547
3
+ metadata.gz: 87e1de8bb4d4e0aacac97628ff3f02cc52756f710897e92124d9c05019125fe3
4
+ data.tar.gz: 4cfa377c062238076d77f77e1dc4d8b4a1f539fb78751b8b3a846e0fe70b3269
5
5
  SHA512:
6
- metadata.gz: 560317e910fdf2966f10919126b8e7ec255ce07a9325bcd24c610eda52bb2686347e76e7123e9ffe0c22d7373220aab5e270b3d63a324dda1acec6c5a1c0d9cb
7
- data.tar.gz: dbcb9693c55eb8a5b7e77d1b98e53d1bd8ae15989d498e585505a2b04137bf068ab20f4efedf4205c1c412d2882e33774875ffa14294635e2e0f1772efbda08a
6
+ metadata.gz: eb76b8e1d6049620933f25f7921940fd6006b04fda13fba82f86f414906878c6c6c84d93918935a9ab2548c525fb116000e8480cac5c444265f92bdffaf38b5f
7
+ data.tar.gz: 1771496f33d419c64fdf3b3be112db32e5dc8d788c3f4cd3dc14ee3e25e272106dc8d93cd86df5e8fe56dde2ec1e2ba1efa60575b5054fb6223a674f1f833af3
@@ -109,7 +109,7 @@ module Wovnrb
109
109
  end
110
110
 
111
111
  def api_uri
112
- Addressable::URI.parse(@store.settings['api_url'])
112
+ Addressable::URI.parse(@store.settings['api_url'] + '/v0/')
113
113
  end
114
114
 
115
115
  def api_timeout
@@ -142,10 +142,14 @@ module Wovnrb
142
142
  # Remove wovn snippet code from dom
143
143
  def strip_snippet
144
144
  @dom.xpath('//script').each do |script_node|
145
- script_node.remove if script_node['src'] && script_node['src'] =~ /^\/\/j.(dev-)?wovn.io(:3000)?\//
145
+ script_node.remove if (script_node['src'] && widget_urls.any? { |url| script_node['src'].include? url }) || script_node['data-wovnio'].present?
146
146
  end
147
147
  end
148
148
 
149
+ def widget_urls
150
+ [@store.settings['api_url'] + '/widget', 'j.wovn.io', 'j.dev-wovn.io:3000']
151
+ end
152
+
149
153
  def insert_snippet(adds_backend_error_mark = true)
150
154
  parent_node = @dom.at_css('head') || @dom.at_css('body') || @dom.at_css('html')
151
155
  return unless parent_node
data/lib/wovnrb/store.rb CHANGED
@@ -23,7 +23,7 @@ module Wovnrb
23
23
  'lang_param_name' => 'wovn',
24
24
  'query' => [],
25
25
  'ignore_class' => [],
26
- 'api_url' => 'https://wovn.global.ssl.fastly.net/v0/',
26
+ 'api_url' => 'https://wovn.global.ssl.fastly.net',
27
27
  'api_timeout_seconds' => 1.0,
28
28
  'default_lang' => 'en',
29
29
  'supported_langs' => ['en'],
@@ -157,7 +157,7 @@ module Wovnrb
157
157
 
158
158
  if @settings['wovn_dev_mode']
159
159
  if @settings['api_url'] == self.class.default_settings['api_url']
160
- @settings['api_url'] = 'http://dev-wovn.io:3001/v0/'
160
+ @settings['api_url'] = 'http://dev-wovn.io:3001'
161
161
  end
162
162
 
163
163
  if @settings['api_timeout_seconds'] == self.class.default_settings['api_timeout_seconds']
@@ -1,3 +1,3 @@
1
1
  module Wovnrb
2
- VERSION = '2.5.1'.freeze
2
+ VERSION = '2.6.0'.freeze
3
3
  end
@@ -154,11 +154,17 @@ module Wovnrb
154
154
  end
155
155
 
156
156
  def test_replace_snippet
157
- converter = prepare_html_converter('<html><head><script src="/a"></script><script src="//j.wovn.io/1" async="true"</head></html>')
157
+ converter = prepare_html_converter('<html><head>
158
+ <script src="/a"></script>
159
+ <script src="//j.wovn.io/1" async="true">
160
+ <script src="//j.wovn.io/1" data-wovnio="key=2wpv0n" async></script>
161
+ <script src="https//cdn.wovn.io/" data-wovnio="key=2wpv0n async></script>
162
+ <script src="https://wovn.global.ssl.fastly.net/widget/abcdef></script>
163
+ </head></html>')
158
164
  converter.send(:replace_snippet)
159
165
 
160
166
  expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&amp;backend=true&amp;currentLang=en&amp;defaultLang=en&amp;urlPattern=query&amp;langCodeAliases={}&amp;langParamName=wovn&amp;version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><script src=\"/a\"></script></head><body></body></html>"
161
- assert_equal(expected_html, converter.send(:html))
167
+ assert_equal(expected_html.gsub(/\s+/, ''), converter.send(:html).gsub(/\s+/, ''))
162
168
  end
163
169
 
164
170
  def test_replace_hreflangs
@@ -133,7 +133,7 @@ module Wovnrb
133
133
 
134
134
  assert(store.dev_mode?)
135
135
  assert_equal('dev-wovn.io', store.wovn_host)
136
- assert_equal('http://dev-wovn.io:3001/v0/', store.settings['api_url'])
136
+ assert_equal('http://dev-wovn.io:3001', store.settings['api_url'])
137
137
  assert_equal(3, store.settings['api_timeout_seconds'])
138
138
  end
139
139
 
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: 2.5.1
4
+ version: 2.6.0
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: 2021-03-31 00:00:00.000000000 Z
12
+ date: 2021-04-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -463,7 +463,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
463
463
  - !ruby/object:Gem::Version
464
464
  version: '0'
465
465
  requirements: []
466
- rubygems_version: 3.0.3
466
+ rubyforge_project:
467
+ rubygems_version: 2.7.6.2
467
468
  signing_key:
468
469
  specification_version: 4
469
470
  summary: Gem for WOVN.io