wiselinks 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wiselinks (0.7.0)
4
+ wiselinks (0.7.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Wiselinks-0.7.0
2
+ * Wiselinks-0.7.1
3
3
  * @copyright 2012-2013 Igor Alexandrov, Alexey Solilin, Julia Egorova, Alexandr Borisov
4
4
  * @preserve https://github.com/igor-alexandrov/wiselinks
5
5
  */
@@ -126,7 +126,7 @@
126
126
  };
127
127
 
128
128
  Link.prototype._cross_origin_link = function(link) {
129
- return (location.protocol !== link.protocol) || (location.host.split(':')[0] !== link.host.split(':')[0]);
129
+ return (location.protocol !== link.protocol) || (location.port !== link.port) || (location.host.split(':')[0] !== link.host.split(':')[0]);
130
130
  };
131
131
 
132
132
  Link.prototype._non_standard_click = function(event) {
@@ -286,13 +286,13 @@
286
286
  dataType: "html"
287
287
  }).done(function(data, status, xhr) {
288
288
  var assets_digest, url;
289
- url = xhr.getResponseHeader('X-Wiselinks-Url');
289
+ url = self._normalize(xhr.getResponseHeader('X-Wiselinks-Url'));
290
290
  assets_digest = xhr.getResponseHeader('X-Wiselinks-Assets-Digest');
291
291
  if (self._assets_changed(assets_digest)) {
292
292
  return window.location.reload(true);
293
293
  } else {
294
294
  state = History.getState();
295
- if ((url != null) && url !== encodeURI(state.url)) {
295
+ if ((url != null) && (url !== encodeURI(self._normalize(state.url)))) {
296
296
  self._redirect_to(url, $target, state, xhr);
297
297
  }
298
298
  $target.html(data);
@@ -306,6 +306,14 @@
306
306
  });
307
307
  };
308
308
 
309
+ RequestManager.prototype._normalize = function(url) {
310
+ if (url == null) {
311
+ return;
312
+ }
313
+ url = url.replace(/\/+$/, '');
314
+ return url;
315
+ };
316
+
309
317
  RequestManager.prototype._assets_changed = function(assets_digest) {
310
318
  return (this.options.assets_digest != null) && this.options.assets_digest !== assets_digest;
311
319
  };
@@ -16,17 +16,17 @@
16
16
  (function(){var c;c=function(){function c(d,e){this.page=d;this.$form=e}c.prototype.process=function(){var d;d=this;return d._include_blank_url_params()?d.page.load(d._url(),d._target(),d._type()):d._without_blank_url_params(function(){return d.page.load(d._url(),d._target(),d._type())})};c.prototype._without_blank_url_params=function(d){var e;e=this.$form.find("select:not(:disabled),input:not(:disabled)").filter(function(){return!$(this).val()});e.attr("disabled",!0);d();return e.attr("disabled",
17
17
  !1)};c.prototype._params=function(){var d,e,b,f,c,q;d={};q=this.$form.serializeArray();f=0;for(c=q.length;f<c;f++)e=q[f],"utf8"!==e.name&&(b=-1!==e.name.indexOf("[]",e.name.length-2)?e.name.substr(0,e.name.length-2):e.name,d[b]=null!=d[b]?d[b]+(","+e.value):e.value);return d};c.prototype._include_blank_url_params=function(){return!0===this.$form.data("include-blank-url-params")};c.prototype._optimize_url_params=function(){return!1!==this.$form.data("optimize-url-params")};c.prototype._type=function(){return"partial"===
18
18
  this.$form.data("push")?"partial":"template"};c.prototype._target=function(){return this.$form.data("target")};c.prototype._url=function(){var d,e,b;var f;if(this._optimize_url_params()){e=[];f=this._params();for(d in f)b=f[d],e.push(""+d+"="+encodeURIComponent(b));d=e.join("&")}else d=this.$form.serialize();e=this.$form.attr("action");0<d.length&&(e+="?"+d);return e};return c}();null==window._Wiselinks&&(window._Wiselinks={});window._Wiselinks.Form=c;c=function(){function c(d,e){this.page=d;this.$link=
19
- e}c.prototype.allows_process=function(d){return!(this._cross_origin_link(d.currentTarget)||this._non_standard_click(d))};c.prototype.process=function(){var d;d="partial"===this.$link.data("push")?"partial":"template";return this.page.load(this.$link.attr("href"),this.$link.data("target"),d)};c.prototype._cross_origin_link=function(d){return location.protocol!==d.protocol||location.host.split(":")[0]!==d.host.split(":")[0]};c.prototype._non_standard_click=function(d){return d.metaKey||d.ctrlKey||d.shiftKey||
20
- d.altKey};return c}();void 0===window._Wiselinks&&(window._Wiselinks={});window._Wiselinks.Link=c;c=function(){function c(d,e){var b;this.$target=d;this.options=e;b=this;this.template_id=(new Date).getTime();this.request_manager=new _Wiselinks.RequestManager(this.options);b._try_target(this.$target);History.emulated.pushState&&!0===this.options.html4&&(-1===window.location.href.indexOf("#!")&&(!0===this.options.html4_normalize_path&&window.location.pathname!==this.options.html4_root_path)&&(window.location.href=
21
- ""+window.location.protocol+"// "+window.location.host+" "+this.options.html4_root_path+"#! "+window.location.pathname),-1!==window.location.hash.indexOf("#!")&&b._call(b._make_state(window.location.hash.substring(2))));History.Adapter.bind(window,"statechange",function(d,e){var c;c=History.getState();return b._template_id_changed(c)?b._call(b._reset_state(c)):b._call(c)});$(document).on("click","a[data-push], a[data-replace]",function(d){var e;if((e=new _Wiselinks.Link(b,
22
- $(this))).allows_process(d))return d.preventDefault(),e.process(),!1});$(document).on("submit","form[data-push], form[data-replace]",function(d){var e;if(e=new _Wiselinks.Form(b,$(this)))return d.preventDefault(),e.process(),!1})}c.prototype.load=function(d,e,b){null==b&&(b="template");"partial"!==b&&(this.template_id=(new Date).getTime());null!=e&&this._try_target($(e));return History.pushState({timestamp:(new Date).getTime(),template_id:this.template_id,render:b,target:e,referer:window.location.href},
19
+ e}c.prototype.allows_process=function(d){return!(this._cross_origin_link(d.currentTarget)||this._non_standard_click(d))};c.prototype.process=function(){var d;d="partial"===this.$link.data("push")?"partial":"template";return this.page.load(this.$link.attr("href"),this.$link.data("target"),d)};c.prototype._cross_origin_link=function(d){return location.protocol!==d.protocol||location.port!==d.port||location.host.split(":")[0]!==d.host.split(":")[0]};c.prototype._non_standard_click=function(d){return d.metaKey||
20
+ d.ctrlKey||d.shiftKey||d.altKey};return c}();void 0===window._Wiselinks&&(window._Wiselinks={});window._Wiselinks.Link=c;c=function(){function c(d,e){var b;this.$target=d;this.options=e;b=this;this.template_id=(new Date).getTime();this.request_manager=new _Wiselinks.RequestManager(this.options);b._try_target(this.$target);History.emulated.pushState&&!0===this.options.html4&&(-1===window.location.href.indexOf("#!")&&(!0===this.options.html4_normalize_path&&window.location.pathname!==this.options.html4_root_path)&&
21
+ (window.location.href=""+window.location.protocol+"// "+window.location.host+" "+this.options.html4_root_path+"#! "+window.location.pathname),-1!==window.location.hash.indexOf("#!")&&b._call(b._make_state(window.location.hash.substring(2))));History.Adapter.bind(window,"statechange",function(d,e){var c;c=History.getState();return b._template_id_changed(c)?b._call(b._reset_state(c)):b._call(c)});$(document).on("click","a[data-push], a[data-replace]",function(d){var e;if((e=
22
+ new _Wiselinks.Link(b,$(this))).allows_process(d))return d.preventDefault(),e.process(),!1});$(document).on("submit","form[data-push], form[data-replace]",function(d){var e;if(e=new _Wiselinks.Form(b,$(this)))return d.preventDefault(),e.process(),!1})}c.prototype.load=function(d,e,b){null==b&&(b="template");"partial"!==b&&(this.template_id=(new Date).getTime());null!=e&&this._try_target($(e));return History.pushState({timestamp:(new Date).getTime(),template_id:this.template_id,render:b,target:e,referer:window.location.href},
23
23
  document.title,d)};c.prototype.reload=function(){return History.replaceState({timestamp:(new Date).getTime(),template_id:this.template_id,render:"template",referer:window.location.href},document.title,History.getState().url)};c.prototype._call=function(d){var e;e=null!=d.data.target?$(d.data.target):this.$target;return this.request_manager.call(e,d)};c.prototype._template_id_changed=function(d){return null==d.data.template_id||d.data.template_id!==this.template_id};c.prototype._make_state=function(d,
24
24
  e,b,f){null==b&&(b="template");return{url:d,data:{target:e,render:b,referer:f}}};c.prototype._reset_state=function(d){null==d.data&&(d.data={});d.data.target=null;d.data.render="template";return d};c.prototype._try_target=function(d){if(0===d.length&&"exception"===this.options.target_missing)throw Error("[Wiselinks] Target missing: `"+d.selector+"`");};return c}();void 0===window._Wiselinks&&(window._Wiselinks={});window._Wiselinks.Page=c;c=function(){function c(d){this.options=null!=d?d:{}}c.prototype.call=
25
- function(d,c){var b;b=this;if(null!=this.redirected)this.redirected=null;else return b._loading(d,c),$.ajax({url:c.url,headers:{"X-Wiselinks":c.data.render,"X-Wiselinks-Referer":c.data.referer},dataType:"html"}).done(function(f,g,k){var l,h;h=k.getResponseHeader("X-Wiselinks-Url");l=k.getResponseHeader("X-Wiselinks-Assets-Digest");if(b._assets_changed(l))return window.location.reload(!0);c=History.getState();null!=h&&h!==encodeURI(c.url)&&b._redirect_to(h,d,c,k);d.html(f);b._title(k.getResponseHeader("X-Wiselinks-Title"));
26
- return b._done(d,g,c.url,f)}).fail(function(f,g,k){return b._fail(d,g,c.url,k)}).always(function(f,g,k){return b._always(d,g,c.url)})};c.prototype._assets_changed=function(d){return null!=this.options.assets_digest&&this.options.assets_digest!==d};c.prototype._redirect_to=function(d,c,b,f){f&&4>f.readyState&&(f.onreadystatechange=$.noop,f.abort());this.redirected=!0;$(document).trigger("page:redirected",[c,b.data.render,d]);return History.replaceState(b.data,document.title,d)};c.prototype._loading=
27
- function(d,c){return $(document).trigger("page:loading",[d,c.data.render,c.url])};c.prototype._done=function(d,c,b,f){return $(document).trigger("page:done",[d,c,b,f])};c.prototype._fail=function(d,c,b,f){return $(document).trigger("page:fail",[d,c,b,f])};c.prototype._always=function(d,c,b){return $(document).trigger("page:always",[d,c,b])};c.prototype._title=function(d){if(null!=d)return $(document).trigger("page:title",decodeURI(d)),document.title=decodeURI(d)};return c}();void 0===window._Wiselinks&&
28
- (window._Wiselinks={});window._Wiselinks.RequestManager=c;c=function(){function c(d,e){null==d&&(d=$("body"));this.options=null!=e?e:{};this._try_jquery();this.options=$.extend(this._defaults(),this.options);this.enabled()&&(this.page=new _Wiselinks.Page(d,this.options))}c.prototype.enabled=function(){return!History.emulated.pushState||!0===this.options.html4};c.prototype.load=function(c,e,b){null==b&&(b="template");return this.page.load(c,e,b)};c.prototype.reload=function(){return this.page.reload()};
29
- c.prototype._defaults=function(){return{html4:!0,html4_root_path:"/",html4_normalize_path:!0,target_missing:null,assets_digest:$("meta[name='assets-digest']").attr("content")}};c.prototype._try_jquery=function(){if(null==window.jQuery)throw Error("[Wiselinks] jQuery is not loaded");};return c}();window.Wiselinks=c}).call(this);
25
+ function(d,c){var b;b=this;if(null!=this.redirected)this.redirected=null;else return b._loading(d,c),$.ajax({url:c.url,headers:{"X-Wiselinks":c.data.render,"X-Wiselinks-Referer":c.data.referer},dataType:"html"}).done(function(f,g,k){var l,h;h=b._normalize(k.getResponseHeader("X-Wiselinks-Url"));l=k.getResponseHeader("X-Wiselinks-Assets-Digest");if(b._assets_changed(l))return window.location.reload(!0);c=History.getState();null!=h&&h!==encodeURI(b._normalize(c.url))&&b._redirect_to(h,d,c,k);d.html(f);
26
+ b._title(k.getResponseHeader("X-Wiselinks-Title"));return b._done(d,g,c.url,f)}).fail(function(f,g,k){return b._fail(d,g,c.url,k)}).always(function(f,g,k){return b._always(d,g,c.url)})};c.prototype._normalize=function(d){if(null!=d)return d=d.replace(/\/+$/,"")};c.prototype._assets_changed=function(d){return null!=this.options.assets_digest&&this.options.assets_digest!==d};c.prototype._redirect_to=function(d,c,b,f){f&&4>f.readyState&&(f.onreadystatechange=$.noop,f.abort());this.redirected=!0;$(document).trigger("page:redirected",
27
+ [c,b.data.render,d]);return History.replaceState(b.data,document.title,d)};c.prototype._loading=function(d,c){return $(document).trigger("page:loading",[d,c.data.render,c.url])};c.prototype._done=function(d,c,b,f){return $(document).trigger("page:done",[d,c,b,f])};c.prototype._fail=function(d,c,b,f){return $(document).trigger("page:fail",[d,c,b,f])};c.prototype._always=function(d,c,b){return $(document).trigger("page:always",[d,c,b])};c.prototype._title=function(d){if(null!=d)return $(document).trigger("page:title",
28
+ decodeURI(d)),document.title=decodeURI(d)};return c}();void 0===window._Wiselinks&&(window._Wiselinks={});window._Wiselinks.RequestManager=c;c=function(){function c(d,e){null==d&&(d=$("body"));this.options=null!=e?e:{};this._try_jquery();this.options=$.extend(this._defaults(),this.options);this.enabled()&&(this.page=new _Wiselinks.Page(d,this.options))}c.prototype.enabled=function(){return!History.emulated.pushState||!0===this.options.html4};c.prototype.load=function(c,e,b){null==b&&(b="template");
29
+ return this.page.load(c,e,b)};c.prototype.reload=function(){return this.page.reload()};c.prototype._defaults=function(){return{html4:!0,html4_root_path:"/",html4_normalize_path:!0,target_missing:null,assets_digest:$("meta[name='assets-digest']").attr("content")}};c.prototype._try_jquery=function(){if(null==window.jQuery)throw Error("[Wiselinks] jQuery is not loaded");};return c}();window.Wiselinks=c}).call(this);
30
30
  (function(c,q){var d=c.History=c.History||{},e=c.jQuery;if("undefined"!==typeof d.Adapter)throw Error("History.js Adapter has already been loaded...");d.Adapter={bind:function(b,c,d){e(b).bind(c,d)},trigger:function(b,c,d){e(b).trigger(c,d)},extractEventData:function(b,c,d){return c&&c.originalEvent&&c.originalEvent[b]||d&&d[b]||q},onDomLoad:function(b){e(b)}};"undefined"!==typeof d.init&&d.init()})(window);
31
31
  (function(c,q){var d=c.document,e=c.setInterval||e,b=c.History=c.History||{};if("undefined"!==typeof b.initHtml4)throw Error("History.js HTML4 Support has already been loaded...");b.initHtml4=function(){if("undefined"!==typeof b.initHtml4.initialized)return!1;b.initHtml4.initialized=!0;b.enabled=!0;b.savedHashes=[];b.isLastHash=function(c){var d=b.getHashByIndex();return c===d};b.saveHash=function(c){if(b.isLastHash(c))return!1;b.savedHashes.push(c);return!0};b.getHashByIndex=function(c){var d=null;
32
32
  return d="undefined"===typeof c?b.savedHashes[b.savedHashes.length-1]:0>c?b.savedHashes[b.savedHashes.length+c]:b.savedHashes[c]};b.discardedHashes={};b.discardedStates={};b.discardState=function(c,d,e){var l=b.getHashByState(c);b.discardedStates[l]={discardedState:c,backState:e,forwardState:d};return!0};b.discardHash=function(c,d,e){b.discardedHashes[c]={discardedHash:c,backState:e,forwardState:d};return!0};b.discardedState=function(c){c=b.getHashByState(c);return b.discardedStates[c]||!1};b.discardedHash=
Binary file
@@ -17,6 +17,7 @@ class Link
17
17
  #
18
18
  _cross_origin_link: (link) ->
19
19
  (location.protocol != link.protocol) ||
20
+ (location.port != link.port) ||
20
21
  (location.host.split(':')[0] != link.host.split(':')[0])
21
22
 
22
23
  _non_standard_click: (event) ->
@@ -25,14 +25,15 @@ class RequestManager
25
25
  dataType: "html"
26
26
  ).done(
27
27
  (data, status, xhr) ->
28
- url = xhr.getResponseHeader('X-Wiselinks-Url')
28
+ url = self._normalize(xhr.getResponseHeader('X-Wiselinks-Url'))
29
29
  assets_digest = xhr.getResponseHeader('X-Wiselinks-Assets-Digest')
30
30
 
31
31
  if self._assets_changed(assets_digest)
32
32
  window.location.reload(true)
33
33
  else
34
34
  state = History.getState()
35
- if url? && url != encodeURI(state.url)
35
+
36
+ if url? && (url != encodeURI(self._normalize(state.url)))
36
37
  self._redirect_to(url, $target, state, xhr)
37
38
 
38
39
  $target.html(data)
@@ -47,6 +48,12 @@ class RequestManager
47
48
  self._always($target, status, state.url)
48
49
  )
49
50
 
51
+ _normalize: (url) ->
52
+ return unless url?
53
+
54
+ url = url.replace /\/+$/, ''
55
+ url
56
+
50
57
  _assets_changed: (assets_digest) ->
51
58
  @options.assets_digest? && @options.assets_digest != assets_digest
52
59
 
@@ -20,7 +20,8 @@ module Wiselinks
20
20
  end
21
21
 
22
22
  def set_wiselinks_url
23
- self.response.headers['X-Wiselinks-Url'] = request.env['REQUEST_URI'] if self.request.wiselinks?
23
+ # self.response.headers['X-Wiselinks-Url'] = request.env['REQUEST_URI'] if self.request.wiselinks?
24
+ self.response.headers['X-Wiselinks-Url'] = request.url if self.request.wiselinks?
24
25
  end
25
26
  end
26
27
  end
@@ -4,7 +4,7 @@ module Wiselinks
4
4
  module Version
5
5
  MAJOR = 0
6
6
  MINOR = 7
7
- PATCH = 0
7
+ PATCH = 1
8
8
  BUILD = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wiselinks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-06-27 00:00:00.000000000 Z
15
+ date: 2013-07-02 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rspec
@@ -302,9 +302,9 @@ files:
302
302
  - README.md
303
303
  - Rakefile
304
304
  - app/views/layouts/wiselinks.html.erb
305
- - build/wiselinks-0.7.0.js
306
- - build/wiselinks-0.7.0.min.js
307
- - build/wiselinks-0.7.0.min.js.gz
305
+ - build/wiselinks-0.7.1.js
306
+ - build/wiselinks-0.7.1.min.js
307
+ - build/wiselinks-0.7.1.min.js.gz
308
308
  - compiler.jar
309
309
  - lib/assets/javascripts/_form.js.coffee
310
310
  - lib/assets/javascripts/_link.js.coffee
@@ -406,7 +406,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
406
406
  version: '0'
407
407
  segments:
408
408
  - 0
409
- hash: 2776055283966944450
409
+ hash: -3962912072684640095
410
410
  required_rubygems_version: !ruby/object:Gem::Requirement
411
411
  none: false
412
412
  requirements:
@@ -415,7 +415,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
415
415
  version: '0'
416
416
  segments:
417
417
  - 0
418
- hash: 2776055283966944450
418
+ hash: -3962912072684640095
419
419
  requirements: []
420
420
  rubyforge_project:
421
421
  rubygems_version: 1.8.24
Binary file