ajaxify_rails 0.7.1 → 0.7.5

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Ajaxify Rails [![Build Status](https://travis-ci.org/ncri/ajaxify_rails.png)](https://travis-ci.org/ncri/ajaxify_rails)
1
+ # Ajaxify Rails
2
2
 
3
3
  No more full page reloads for your Rails app! Yay!
4
4
 
@@ -1,20 +1,25 @@
1
+ require 'active_support/core_ext/module/qualified_const'
2
+
1
3
  # Makes Ajaxify work properly with action cached actions.
2
- module ActionController
3
- module Caching
4
- module Actions
4
+ if ActionController.qualified_const_defined?("Caching::Actions::ActionCacheFilter")
5
+ module ActionController
6
+ module Caching
7
+ module Actions
5
8
 
6
- protected
9
+ protected
7
10
 
8
- class ActionCacheFilter #:nodoc:
11
+ class ActionCacheFilter #:nodoc:
9
12
 
10
- alias_method :original_filter, :filter
13
+ alias_method :original_filter, :filter
11
14
 
12
- def filter(controller)
13
- original_filter controller
14
- controller.ajaxify_add_meta_tags
15
- end
16
- end
15
+ def filter(controller)
16
+ original_filter controller
17
+ controller.ajaxify_add_meta_tags unless controller.request.xhr?
18
+ controller.ajaxify_set_asset_digest_header if controller.ajaxified?
19
+ end
20
+ end
17
21
 
18
- end
19
- end
22
+ end
23
+ end
24
+ end
20
25
  end
@@ -3,6 +3,8 @@ module ActionControllerAdditions
3
3
  def self.included(controller)
4
4
  controller.class_eval do
5
5
 
6
+ hide_action :page_title, :ajaxify_extra_content, :ajaxify_add_meta_tags, :ajaxify_set_asset_digest_header, :ajaxified?
7
+
6
8
  # override in your controller
7
9
  def page_title
8
10
  nil
@@ -15,21 +17,26 @@ module ActionControllerAdditions
15
17
 
16
18
 
17
19
  def ajaxify_add_meta_tags
18
- ajaxify_add_meta_tag( ajaxify_assets_digest_meta_tag ) if !request.xhr?
20
+ ajaxify_add_meta_tag( ajaxify_assets_digest_meta_tag )
19
21
 
20
22
  # 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
23
  # 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?
24
+ ajaxify_add_meta_tag( view_context.tag(:meta, name: 'ajaxify:dont_correct_url', content: 'true') ) if request.post?
23
25
  end
24
26
 
25
27
 
26
- private
28
+ def ajaxify_set_asset_digest_header
29
+ response.headers['Ajaxify-Assets-Digest'] = ajaxify_assets_digest
30
+ end
31
+
27
32
 
28
33
  def ajaxified?
29
34
  request.xhr? and params[:ajaxified]
30
35
  end
31
36
 
32
37
 
38
+ private
39
+
33
40
  def render *args, &block
34
41
  if ajaxified?
35
42
  args = _normalize_args(*args, &block)
@@ -58,14 +65,14 @@ module ActionControllerAdditions
58
65
  data: { page_title: page_title,
59
66
  flashes: flashes.to_json } )
60
67
  response.body = response_body[0]
61
- response.headers['Ajaxify-Assets-Digest'] = ajaxify_assets_digest
68
+ ajaxify_set_asset_digest_header
62
69
 
63
70
  return
64
71
  end
65
72
 
66
73
  super
67
74
 
68
- ajaxify_add_meta_tags # doesn't work for action cached pages right now
75
+ ajaxify_add_meta_tags unless request.xhr?
69
76
 
70
77
  return
71
78
  end
@@ -1,3 +1,3 @@
1
1
  module AjaxifyRails
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.5"
3
3
  end
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.1
4
+ version: 0.7.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-13 00:00:00.000000000 Z
12
+ date: 2013-03-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails