kmz_compressor 2.1.4 → 2.3.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 87e3ddcda31c6d84a2d9ff00db0228352cf3895e04a8649c09f656029c11a049
4
+ data.tar.gz: 14237e8098be57d691fd5dacaa136e7ad103db432e1fc6ef2cde03ffae5d2c63
5
+ SHA512:
6
+ metadata.gz: 89df6178e339c13482fd1121c3366448f2f1b4f1c95415246356b8c7d862c2bc17a855ae276d157ad0027ddc0ffa001c257deb1d3527c15dbf7b1ac9be03b3e7
7
+ data.tar.gz: ee2e4f709f7ae7f775a9900cf0407aa07ecaa4a66a53ad706c38c705bb83a448e3de05fcaaae194e6da7cdfe7e10f80a3f5441fc493fb0eb769a22d06be45a4b
@@ -16,7 +16,8 @@ window.MapLayerManager = function(map){
16
16
  var requestTimestamp = new Date;
17
17
  var retryDelay = retryDelay || 2000;
18
18
 
19
- kmlURL = sanitizeURI(kmlURL);
19
+ kmlURL = prepareUrl(kmlURL);
20
+
20
21
  options = jQuery.extend(true, {zIndex:getDrawOrder(layerName)}, options); // Deep copy the options in case they are changed between now and when the map is ready to load
21
22
 
22
23
  return $.ajax(kmlURL, {type:'head', statusCode:{
@@ -24,7 +25,7 @@ window.MapLayerManager = function(map){
24
25
  200: function(){
25
26
  if (!requestTimestamps[layerName] || requestTimestamps[layerName] < requestTimestamp){
26
27
  requestTimestamps[layerName] = requestTimestamp;
27
- loadKMLLayer(cachedKMZURL(kmlURL), layerName, options)
28
+ loadKMLLayerWithoutExtraParams(cachedKMZURL(kmlURL), layerName, options)
28
29
  }
29
30
  }
30
31
  }}).error(function(){
@@ -34,8 +35,11 @@ window.MapLayerManager = function(map){
34
35
  }
35
36
 
36
37
  function loadKMLLayer(kmlURL, layerName, options) {
37
- // Replace spaces with pluses so we don't have problems with some things turning them into %20s and some not
38
- kmlURL = sanitizeURI(kmlURL);
38
+ kmlURL = prepareUrl(kmlURL);
39
+ loadKMLLayerWithoutExtraParams(kmlURL, layerName, options)
40
+ }
41
+
42
+ function loadKMLLayerWithoutExtraParams(kmlURL, layerName, options) {
39
43
  options = jQuery.extend(true, {zIndex:getDrawOrder(layerName), map:map}, options);
40
44
 
41
45
  var kmlLayer = new google.maps.KmlLayer(kmlURL, options);
@@ -182,7 +186,7 @@ window.MapLayerManager = function(map){
182
186
 
183
187
  for (var i = 0; i < layerNames.length; i++){
184
188
  var layer = getLayer(layerNames[i])
185
- if (layer.error){
189
+ if (!layer || layer.error){
186
190
  continue
187
191
  }
188
192
 
@@ -269,33 +273,56 @@ window.MapLayerManager = function(map){
269
273
  })
270
274
  }
271
275
 
272
- // Replace spaces with pluses so we don't have problems with some things turning them into %20s and some not
273
- // Matches the middleware process
274
- function sanitizeURI(uri){
276
+ function prepareUrl(kmlURL) {
277
+ kmlURL = sanitizeURI(kmlURL);
278
+ kmlURL = addExtraParams(kmlURL, window.MapLayerManager.extraParams);
279
+ return kmlURL;
280
+ }
281
+
282
+ function sanitizeURI(uri) {
275
283
  var url = urlToObject(uri)
276
- var pathname = ('/' + decodeURI(url.pathname)).replace(/^\/+/, '/').trim() // Ensure there is a leading slash (IE doesn't provide one, Chrome does, FF does)
277
- var search = decodeURIComponent(url.search.replace(/\+/g, '%20')).trim().replace(/^\?/, '') // Ensure all "plus spaces" are hex encoded spaces
284
+ var pathname = ('/' + decodeURI(url.pathname)).replace(/^\/+/, '/').trim() // Ensure there is a leading slash (IE doesn't provide one, Chrome does, FF does)
278
285
 
279
- output = pathname
286
+ var search = url.search.replace(/%26/g, '%2526').replace(/%3D/g, '%253D') // Double encode & and = or else we will be unable to tell them apart from unencoded ones
287
+ search = search.replace(/\+/g, '%20') // Ensure all "plus spaces" are hex encoded spaces
288
+ search = decodeURIComponent(search).trim().replace(/^\?/, '') // Remove any leading ?
280
289
 
281
- if (search !== ''){
282
- output += '?'
283
- }
290
+ output = pathname
291
+ if (search !== '') { output += '?' }
284
292
 
285
293
  // Encode the individual uri components
286
294
  output += $.map(search.split('&'), function(component){
287
295
  return $.map(component.split('='), function(kv){
296
+ // Unencode double encoded & and = from earlier
297
+ kv = kv.replace(/%26/g, '&').replace(/%3D/g, '=')
298
+
299
+ kv = encodeURIComponent(kv)
300
+
288
301
  // HACK: Firefox 'helps' us out by encoding apostrophes as %27 in AJAX requests, However its encodeURIcomponent method
289
302
  // does not. This difference causes a mismatch between the url we use to calculate the cache path in the browser
290
303
  // and on the server. This hack undoes the damage. See https://bugzilla.mozilla.org/show_bug.cgi?id=407172
291
- return encodeURIComponent(kv).replace(/'/g, '%27')
304
+ kv = kv.replace(/'/g, '%27')
305
+
306
+ return kv
292
307
  }).join('=')
293
308
  }).join('&')
309
+
294
310
  url.href = output
295
311
 
296
312
  return url.href
297
313
  }
298
314
 
315
+ function addExtraParams(url, extraParams) {
316
+ url = urlToObject(url)
317
+ var paramString = $.param(extraParams || {})
318
+
319
+ if (paramString) {
320
+ url.search = url.search ? url.search + '&' + paramString : paramString
321
+ }
322
+
323
+ return url.href
324
+ }
325
+
299
326
  function closeInfowindowsExcept(layerName){
300
327
  eachLayer(function(layer){
301
328
  if (layer.name != layerName){
@@ -340,6 +367,7 @@ window.MapLayerManager = function(map){
340
367
  $(manager).trigger(data).trigger(nameData)
341
368
  }
342
369
 
370
+
343
371
  // INIT
344
372
 
345
373
  // Because google events sometimes get missed, we ensure we're up to date every now and again
@@ -6,7 +6,7 @@ require 'kmz_compressor/middleware'
6
6
  module KMZCompressor
7
7
  class Railtie < Rails::Railtie
8
8
  initializer "kmz_compressor.init" do |app|
9
- app.config.middleware.use "KMZCompressor::Middleware"
9
+ app.config.middleware.use KMZCompressor::Middleware
10
10
 
11
11
  Mime::Type.register "application/vnd.google-earth.kml+xml", :kml
12
12
  end
@@ -1,3 +1,3 @@
1
1
  module KMZCompressor
2
- VERSION = "2.1.4"
2
+ VERSION = "2.3.1"
3
3
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kmz_compressor
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4
5
- prerelease:
4
+ version: 2.3.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ryan Wallace
@@ -10,46 +9,36 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2015-04-15 00:00:00.000000000 Z
12
+ date: 2021-03-15 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rails
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
18
  - - ">="
21
19
  - !ruby/object:Gem::Version
22
20
  version: '3.1'
23
- - - "<"
24
- - !ruby/object:Gem::Version
25
- version: 4.2.0
26
21
  type: :runtime
27
22
  prerelease: false
28
23
  version_requirements: !ruby/object:Gem::Requirement
29
- none: false
30
24
  requirements:
31
25
  - - ">="
32
26
  - !ruby/object:Gem::Version
33
27
  version: '3.1'
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: 4.2.0
37
28
  - !ruby/object:Gem::Dependency
38
29
  name: rubyzip
39
30
  requirement: !ruby/object:Gem::Requirement
40
- none: false
41
31
  requirements:
42
- - - "~>"
32
+ - - ">="
43
33
  - !ruby/object:Gem::Version
44
- version: 1.1.4
34
+ version: 1.0.0
45
35
  type: :runtime
46
36
  prerelease: false
47
37
  version_requirements: !ruby/object:Gem::Requirement
48
- none: false
49
38
  requirements:
50
- - - "~>"
39
+ - - ">="
51
40
  - !ruby/object:Gem::Version
52
- version: 1.1.4
41
+ version: 1.0.0
53
42
  description: Rack Middleware which retrieves KML from Rails and produces KMZ for the
54
43
  client.
55
44
  email:
@@ -58,41 +47,38 @@ executables: []
58
47
  extensions: []
59
48
  extra_rdoc_files: []
60
49
  files:
50
+ - MIT-LICENSE
51
+ - README.rdoc
52
+ - app/assets/javascripts/kmz_compressor.js
61
53
  - app/assets/javascripts/kmz_compressor/map_layer_manager.js
62
54
  - app/assets/javascripts/kmz_compressor/polyfills.js
63
55
  - app/assets/javascripts/kmz_compressor/sha2.js
64
- - app/assets/javascripts/kmz_compressor.js
65
- - app/helpers/kmz_compressor/kml_helper.rb
56
+ - lib/kmz_compressor.rb
66
57
  - lib/kmz_compressor/controller_extensions.rb
67
58
  - lib/kmz_compressor/engine.rb
68
59
  - lib/kmz_compressor/middleware.rb
69
60
  - lib/kmz_compressor/railtie.rb
70
61
  - lib/kmz_compressor/version.rb
71
- - lib/kmz_compressor.rb
72
- - MIT-LICENSE
73
- - README.rdoc
74
62
  homepage: http://github.com/culturecode/kmz_compressor
75
63
  licenses: []
64
+ metadata: {}
76
65
  post_install_message:
77
66
  rdoc_options: []
78
67
  require_paths:
79
68
  - lib
80
69
  required_ruby_version: !ruby/object:Gem::Requirement
81
- none: false
82
70
  requirements:
83
71
  - - ">="
84
72
  - !ruby/object:Gem::Version
85
73
  version: '0'
86
74
  required_rubygems_version: !ruby/object:Gem::Requirement
87
- none: false
88
75
  requirements:
89
76
  - - ">="
90
77
  - !ruby/object:Gem::Version
91
78
  version: '0'
92
79
  requirements: []
93
- rubyforge_project:
94
- rubygems_version: 1.8.25
80
+ rubygems_version: 3.0.3
95
81
  signing_key:
96
- specification_version: 3
82
+ specification_version: 4
97
83
  summary: Rack Middleware which retrieves KML from Rails and produces KMZ for the client.
98
84
  test_files: []
@@ -1,8 +0,0 @@
1
- module KmzCompressor
2
- module KmlHelper
3
- # Converts KML colours which are BBGGRR into web colours which are RRGGBB
4
- def kml_colour(html_hex_colour)
5
- html_hex_colour.gsub(/([0-9A-F][0-9A-F])([0-9A-F][0-9A-F])([0-9A-F][0-9A-F])/i, '\3\2\1')
6
- end
7
- end
8
- end