ajax 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
@@ -91,7 +91,7 @@ module Ajax
91
91
  end
92
92
  end
93
93
 
94
- if !Ajax.is_hashed_url?(url)
94
+ if !Ajax.is_hashed_url?(url) and !Ajax.is_robot?(request.user_agent)
95
95
  url = Ajax.hashed_url_from_traditional(url)
96
96
  end
97
97
  end
@@ -106,7 +106,7 @@ module Ajax
106
106
  render :partial => '/ajax/redirect_with_fragment', :locals => { :url => url }
107
107
  else
108
108
  session[:redirected_to] = url
109
- if request.xhr?
109
+ if request.xhr? && Ajax.is_hashed_url?(url)
110
110
  Ajax.logger.info("[ajax] detecting we are xhr. soft redirect")
111
111
  redirect_path = URI.parse(url).select(:fragment).first
112
112
  Ajax.logger.info("[ajax] redirect path is #{redirect_path}")
@@ -14,6 +14,7 @@ module Ajax
14
14
  {:name => 'WordPress', :user_agent_regex => /\bWordPress\b/i, :sample_agent_string => 'WordPress'},
15
15
  {:name => 'ZIBB', :user_agent_regex => /\bZIBB\b/i, :sample_agent_string => 'ZIBB'},
16
16
  {:name => 'ZyBorg', :user_agent_regex => /\bZyBorg\b/i, :sample_agent_string => 'ZyBorg'},
17
+ {:name => 'Facebook', :user_agent_regex => /\bfacebookexternalhit\b/i, :sample_agent_string => 'facebookexternalhit'}
17
18
  ]
18
19
 
19
20
  def robot_for(user_agent)
@@ -43,11 +43,11 @@ module Ajax
43
43
  end
44
44
  res
45
45
  end
46
-
46
+
47
47
  def already_encoded?(url)
48
48
  URI.decode(url) != url rescue true
49
49
  end
50
-
50
+
51
51
  def url_host(url)
52
52
  if url.match(/^(\w+\:\/\/[^\/]+)\/?/)
53
53
  $1
@@ -56,4 +56,4 @@ module Rack
56
56
  end
57
57
  end
58
58
  end
59
- end
59
+ end
@@ -518,6 +518,13 @@ var Ajax = function(options) {
518
518
  *
519
519
  */
520
520
  self.responseHandler = function(responseText, textStatus, XMLHttpRequest) {
521
+
522
+ self.last_request_object = XMLHttpRequest;
523
+ console.log("[AJAX] in response handler! status: " + self.last_request_object.status);
524
+ if(self.last_request_object.status == 0) {
525
+ console.log("[AJAX] aborting response handler! ");
526
+ return;
527
+ }
521
528
  var data = self.processResponseHeaders(XMLHttpRequest);
522
529
 
523
530
  if (data.soft_redirect !== undefined) {
@@ -553,6 +560,8 @@ var Ajax = function(options) {
553
560
  // callback - execute a callback
554
561
  if (data.title !== undefined) {
555
562
  console.log('Using page title '+data.title);
563
+ // commenting this out until we fix ' char bug, removing % chars from page titles for now
564
+ // $.address.title(encodeURIComponent(data.title));
556
565
  $.address.title(data.title);
557
566
  }
558
567
 
@@ -653,6 +662,11 @@ var Ajax = function(options) {
653
662
  * Stop watching the mouse position.
654
663
  */
655
664
  self.hideLoadingImage = function() {
665
+ // check if a new request has already started
666
+ if (self.current_request.status == 0) {
667
+ console.log("[AJAX] aborting hideLoadingImage.. ")
668
+ return
669
+ }
656
670
  if (!self.show_loading_image) { return; }
657
671
  $(document).unbind('mousemove', self.updateImagePosition);
658
672
  $(self.loading_image).hide();
@@ -77,15 +77,13 @@ context 'Ajax::UrlHelpers' do
77
77
  it "should return false for fragments that don't start with /" do
78
78
  Ajax.is_hashed_url?('/Beyonce#Akon').should be(false)
79
79
  Ajax.is_hashed_url?('/Beyonce?query#Akon/').should be(false)
80
- end
81
-
82
- it "should return false for no fragment" do
83
- Ajax.is_hashed_url?('/Beyonce?query%23/').should be(false)
80
+ Ajax.is_hashed_url?('/Beyonce?query%23').should be(false)
84
81
  end
85
82
 
86
83
  it "should return true if the fragment starts with /" do
87
84
  Ajax.is_hashed_url?('/Beyonce#/Akon').should be(true)
88
85
  Ajax.is_hashed_url?('/#/Akon').should be(true)
86
+ Ajax.is_hashed_url?('/Beyonce?query%23/').should be(true) # KJV technically I don't think this behaviour is correct
89
87
  end
90
88
 
91
89
  DOMAINS.each do |domain|
File without changes
@@ -0,0 +1,7 @@
1
+ module ResponseHelpers
2
+ def should_redirect_to(location, code=302)
3
+ should_be_a_valid_response
4
+ response_code.should == code
5
+ response_headers['Location'].should == location
6
+ end
7
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ajax
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 0
8
- - 1
9
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
10
11
  platform: ruby
11
12
  authors:
12
13
  - Karl Varga
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-07-15 00:00:00 -07:00
18
+ date: 2010-10-25 00:00:00 -07:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rspec
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  version: "0"
@@ -84,6 +87,8 @@ files:
84
87
  - spec/spec.opts
85
88
  - spec/spec_helper.rb
86
89
  - spec/support/file_macros.rb
90
+ - spec/support/query_count.rb
91
+ - spec/support/response_helpers.rb
87
92
  - tasks/ajax_tasks.rake
88
93
  has_rdoc: true
89
94
  homepage: http://github.com/kjvarga/ajax
@@ -95,23 +100,27 @@ rdoc_options:
95
100
  require_paths:
96
101
  - lib
97
102
  required_ruby_version: !ruby/object:Gem::Requirement
103
+ none: false
98
104
  requirements:
99
105
  - - ">="
100
106
  - !ruby/object:Gem::Version
107
+ hash: 3
101
108
  segments:
102
109
  - 0
103
110
  version: "0"
104
111
  required_rubygems_version: !ruby/object:Gem::Requirement
112
+ none: false
105
113
  requirements:
106
114
  - - ">="
107
115
  - !ruby/object:Gem::Version
116
+ hash: 3
108
117
  segments:
109
118
  - 0
110
119
  version: "0"
111
120
  requirements: []
112
121
 
113
122
  rubyforge_project:
114
- rubygems_version: 1.3.6
123
+ rubygems_version: 1.3.7
115
124
  signing_key:
116
125
  specification_version: 3
117
126
  summary: A framework to augment a traditional Rails application with a completely AJAX frontend.