ajaxify_rails 0.7.0 → 0.7.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.
data/lib/ajaxify_rails.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "ajaxify_rails/version"
2
2
  require "ajaxify_rails/action_controller_additions"
3
+ require "ajaxify_rails/action_caching_patch"
3
4
 
4
5
  module AjaxifyRails
5
6
 
@@ -12,4 +13,4 @@ module AjaxifyRails
12
13
  include ActionControllerAdditions
13
14
  end
14
15
 
15
- end
16
+ end
@@ -0,0 +1,20 @@
1
+ # Makes Ajaxify work properly with action cached actions.
2
+ module ActionController
3
+ module Caching
4
+ module Actions
5
+
6
+ protected
7
+
8
+ class ActionCacheFilter #:nodoc:
9
+
10
+ alias_method :original_filter, :filter
11
+
12
+ def filter(controller)
13
+ original_filter controller
14
+ controller.ajaxify_add_meta_tags
15
+ end
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -14,6 +14,15 @@ module ActionControllerAdditions
14
14
  end
15
15
 
16
16
 
17
+ def ajaxify_add_meta_tags
18
+ ajaxify_add_meta_tag( ajaxify_assets_digest_meta_tag ) if !request.xhr?
19
+
20
+ # Correcting urls for non history api browsers wont work for post requests so add a meta tag to the response body to communicate this to
21
+ # the ajaxify javascript
22
+ ajaxify_add_meta_tag( view_context.tag(:meta, name: 'ajaxify:dont_correct_url', content: 'true') ) if request.post? and not request.xhr?
23
+ end
24
+
25
+
17
26
  private
18
27
 
19
28
  def ajaxified?
@@ -50,16 +59,13 @@ module ActionControllerAdditions
50
59
  flashes: flashes.to_json } )
51
60
  response.body = response_body[0]
52
61
  response.headers['Ajaxify-Assets-Digest'] = ajaxify_assets_digest
53
-
62
+
54
63
  return
55
64
  end
56
- super
57
65
 
58
- ajaxify_add_meta_tag( ajaxify_assets_digest_meta_tag ) if !request.xhr?
66
+ super
59
67
 
60
- # Correcting urls for non history api browsers wont work for post requests so add a meta tag to the response body to communicate this to
61
- # the ajaxify javascript
62
- ajaxify_add_meta_tag( view_context.tag(:meta, name: 'ajaxify:dont_correct_url', content: 'true') ) if request.post? and not request.xhr?
68
+ ajaxify_add_meta_tags # doesn't work for action cached pages right now
63
69
 
64
70
  return
65
71
  end
@@ -99,8 +105,7 @@ module ActionControllerAdditions
99
105
  # Meta tag for asset change detection - inspired by wiselinks
100
106
  #
101
107
  def ajaxify_assets_digest_meta_tag
102
-
103
- view_context.tag(:meta, name: 'ajaxify:assets-digest', content: ajaxify_assets_digest)
108
+ view_context.tag(:meta, name: 'ajaxify:assets-digest', content: ajaxify_assets_digest)
104
109
  end
105
110
 
106
111
  def ajaxify_assets_digest
@@ -109,10 +114,11 @@ module ActionControllerAdditions
109
114
  end
110
115
 
111
116
  def ajaxify_add_meta_tag meta_tag
112
- response.body = response_body[0].sub('<head>', "<head>\n #{meta_tag}")
117
+ response.body = response_body[0].sub('<head>', "<head>\n #{meta_tag}")
113
118
  end
114
119
 
115
120
  end
116
121
 
117
122
  end
123
+
118
124
  end
@@ -1,3 +1,3 @@
1
1
  module AjaxifyRails
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
@@ -183,7 +183,7 @@ on_ajaxify_success = (data, status, jqXHR, pop_state, options) ->
183
183
  if options.url != current_url
184
184
  options.url = current_url.replace(/(&|&amp;|\?)ajaxify_redirect=true/,'')
185
185
  options.type = 'GET'
186
-
186
+
187
187
  unless original_request_type and original_request_type.toLowerCase() == 'post'
188
188
  reload_page_if_assets_stale options.url, jqXHR
189
189
 
@@ -286,7 +286,7 @@ protocol_with_host = ->
286
286
 
287
287
 
288
288
  push_state = ->
289
- push_state_enabled and window.history.pushState
289
+ push_state_enabled and window.history.pushState
290
290
 
291
291
 
292
292
  set_scroll_to_top = ($link_or_form) ->
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ajaxify_rails
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:
@@ -195,6 +195,7 @@ files:
195
195
  - Rakefile
196
196
  - ajaxify_rails.gemspec
197
197
  - lib/ajaxify_rails.rb
198
+ - lib/ajaxify_rails/action_caching_patch.rb
198
199
  - lib/ajaxify_rails/action_controller_additions.rb
199
200
  - lib/ajaxify_rails/version.rb
200
201
  - spec/ajaxify_test/Rakefile