cacheable_flash 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +3 -0
- data/Gemfile +12 -11
- data/Gemfile.lock +14 -6
- data/MIT-LICENSE +21 -0
- data/README.rdoc +6 -8
- data/Rakefile +27 -4
- data/VERSION +1 -1
- data/app/assets/images/cacheable_flash/.gitkeep +0 -0
- data/app/assets/javascripts/cacheable_flash/application.js +15 -0
- data/app/assets/stylesheets/cacheable_flash/application.css +13 -0
- data/app/controllers/cacheable-flash/application_controller.rb +5 -0
- data/app/helpers/cacheable_flash/application_helper.rb +4 -0
- data/app/views/layouts/cacheable-flash/application.html.erb +14 -0
- data/cacheable_flash.gemspec +62 -13
- data/config/routes.rb +2 -0
- data/lib/cacheable_flash.rb +13 -8
- data/lib/cacheable_flash/engine.rb +7 -0
- data/lib/cacheable_flash/railtie.rb +10 -0
- data/lib/cacheable_flash/version.rb +3 -0
- data/lib/tasks/cacheable-flash_tasks.rake +4 -0
- data/script/rails +8 -0
- data/spec/cacheable_flash/cacheable_flash_spec.rb +12 -11
- data/spec/cacheable_flash/test_helpers_spec.rb +0 -1
- data/spec/controllers/dummy_controller_spec.rb +19 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/dummy_controller.rb +10 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/views/dummy/index.html.erb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +62 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +39 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/spec_helper.rb +16 -9
- data/spec/support/test_helpers.rb +3 -1
- metadata +86 -29
- data/lib/cacheable_flash/rails/engine.rb +0 -8
- data/lib/cacheable_flash/rails/railtie.rb +0 -14
data/CHANGES
CHANGED
data/Gemfile
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
gem "rails", "> 3.0"
|
4
|
-
#We don't really need all of rails... so:
|
5
|
-
# Actually we do now that we have rails engine and rails railtie
|
6
|
-
# TODO: Investigate making a rails free version
|
7
|
-
#gem "activesupport"
|
8
|
-
#gem "activemodel"
|
9
|
-
#gem "actionpack"
|
10
3
|
gem "json"
|
11
4
|
|
12
|
-
#
|
13
|
-
group :development do
|
14
|
-
gem "
|
15
|
-
|
5
|
+
# Development dependencies (everything needed to run rake, tests, features, etc.)
|
6
|
+
group :development, :test do
|
7
|
+
gem "rails", "~> 3.1.3"
|
8
|
+
|
9
|
+
# jquery-rails is used by the dummy application
|
10
|
+
gem "jquery-rails"
|
11
|
+
|
12
|
+
# To use debugger
|
13
|
+
# gem 'ruby-debug19', :require => 'ruby-debug'
|
14
|
+
|
15
|
+
gem "rspec-rails", "~> 2.8.0"
|
16
|
+
gem "rdoc", "~> 3.12"
|
16
17
|
gem "bundler", "~> 1.0.21"
|
17
18
|
gem "jeweler", "~> 1.6.4"
|
18
19
|
gem "reek", "~> 1.2.8"
|
data/Gemfile.lock
CHANGED
@@ -40,13 +40,16 @@ GEM
|
|
40
40
|
bundler (~> 1.0)
|
41
41
|
git (>= 1.2.5)
|
42
42
|
rake
|
43
|
-
|
43
|
+
jquery-rails (1.0.19)
|
44
|
+
railties (~> 3.0)
|
45
|
+
thor (~> 0.14)
|
46
|
+
json (1.6.5)
|
44
47
|
mail (2.3.0)
|
45
48
|
i18n (>= 0.4.0)
|
46
49
|
mime-types (~> 1.16)
|
47
50
|
treetop (~> 1.4.8)
|
48
51
|
mime-types (1.17.2)
|
49
|
-
multi_json (1.0
|
52
|
+
multi_json (1.1.0)
|
50
53
|
polyglot (0.3.3)
|
51
54
|
rack (1.3.6)
|
52
55
|
rack-cache (1.1)
|
@@ -89,6 +92,11 @@ GEM
|
|
89
92
|
rspec-expectations (2.8.0)
|
90
93
|
diff-lcs (~> 1.1.2)
|
91
94
|
rspec-mocks (2.8.0)
|
95
|
+
rspec-rails (2.8.1)
|
96
|
+
actionpack (>= 3.0)
|
97
|
+
activesupport (>= 3.0)
|
98
|
+
railties (>= 3.0)
|
99
|
+
rspec (~> 2.8.0)
|
92
100
|
ruby2ruby (1.3.1)
|
93
101
|
ruby_parser (~> 2.0)
|
94
102
|
sexp_processor (~> 3.0)
|
@@ -105,7 +113,6 @@ GEM
|
|
105
113
|
polyglot
|
106
114
|
polyglot (>= 0.3.1)
|
107
115
|
tzinfo (0.3.31)
|
108
|
-
yard (0.7.4)
|
109
116
|
|
110
117
|
PLATFORMS
|
111
118
|
ruby
|
@@ -113,9 +120,10 @@ PLATFORMS
|
|
113
120
|
DEPENDENCIES
|
114
121
|
bundler (~> 1.0.21)
|
115
122
|
jeweler (~> 1.6.4)
|
123
|
+
jquery-rails
|
116
124
|
json
|
117
|
-
rails (
|
125
|
+
rails (~> 3.1.3)
|
126
|
+
rdoc (~> 3.12)
|
118
127
|
reek (~> 1.2.8)
|
119
128
|
roodi (~> 2.1.0)
|
120
|
-
rspec (~> 2.8.0)
|
121
|
-
yard (~> 0.7.4)
|
129
|
+
rspec-rails (~> 2.8.0)
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2007-2010 Pivotal Labs
|
2
|
+
Copyright (c) 2011-2012 Peter H. Boling (http://peterboling.com)
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
CacheableFlash
|
2
|
-
==============
|
1
|
+
= CacheableFlash
|
3
2
|
|
4
|
-
cacheable-flash
|
5
|
-
|
6
|
-
|
7
|
-
It has also been made compatible with Rails 3, hooked into the asset pipeline for rails 3.1, and turned into a gem.
|
3
|
+
Note: This fork, http://github.com/pboling/cacheable-flash, of
|
4
|
+
cacheable-flash is where I play with new features & refactoring. I, pboling,
|
5
|
+
am a maintainer of the the official repository here https://github.com/pivotal/cacheable-flash.
|
8
6
|
|
9
7
|
== Installation as plugin
|
10
8
|
|
@@ -151,8 +149,8 @@ Cacheable Flash provides test helpers which includes the flash_cookie method.
|
|
151
149
|
|
152
150
|
Licensed under the MIT License.
|
153
151
|
|
154
|
-
Copyright (c) 2011-2012 Peter H. Boling (http://peterboling.com). See LICENSE.txt
|
155
|
-
Copyright (c) 2007-2010 Pivotal Labs
|
152
|
+
- Copyright (c) 2011-2012 Peter H. Boling (http://peterboling.com). See LICENSE.txt for further details.
|
153
|
+
- Copyright (c) 2007-2010 Pivotal Labs
|
156
154
|
|
157
155
|
|
158
156
|
|
data/Rakefile
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
2
|
+
#!/usr/bin/env rake
|
3
3
|
require 'rubygems'
|
4
|
-
|
4
|
+
begin
|
5
|
+
require 'bundler/setup'
|
6
|
+
rescue LoadError
|
7
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
8
|
+
end
|
5
9
|
begin
|
6
10
|
Bundler.setup(:default, :development)
|
7
11
|
rescue Bundler::BundlerError => e
|
@@ -50,5 +54,24 @@ end
|
|
50
54
|
|
51
55
|
task :default => :spec
|
52
56
|
|
53
|
-
|
54
|
-
|
57
|
+
begin
|
58
|
+
require 'rdoc/task'
|
59
|
+
rescue LoadError
|
60
|
+
require 'rdoc/rdoc'
|
61
|
+
require 'rake/rdoctask'
|
62
|
+
RDoc::Task = Rake::RDocTask
|
63
|
+
end
|
64
|
+
|
65
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
66
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
67
|
+
rdoc.rdoc_dir = 'rdoc'
|
68
|
+
rdoc.title = "CacheableFlash #{version}"
|
69
|
+
rdoc.options << '--line-numbers'
|
70
|
+
rdoc.rdoc_files.include('README*')
|
71
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
72
|
+
end
|
73
|
+
|
74
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
75
|
+
load 'rails/tasks/engine.rake'
|
76
|
+
|
77
|
+
Bundler::GemHelper.install_tasks
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>CacheableFlash</title>
|
5
|
+
<%= stylesheet_link_tag "cacheable_flash/application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "cacheable_flash/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/cacheable_flash.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "cacheable_flash"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Peter H. Boling", "Brian Takita"]
|
12
|
-
s.date = "2012-01
|
12
|
+
s.date = "2012-03-01"
|
13
13
|
s.description = "This plugin enables greater levels of page caching by rendering flash\nmessages from a cookie using JavaScript, instead of in your Rails\nview template. Flash contents are converted to JSON and placed in\na cookie by an after_filter in a controller."
|
14
14
|
s.email = "peter.boling@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -22,19 +22,65 @@ Gem::Specification.new do |s|
|
|
22
22
|
"Gemfile",
|
23
23
|
"Gemfile.lock",
|
24
24
|
"LICENSE.txt",
|
25
|
+
"MIT-LICENSE",
|
25
26
|
"README.rdoc",
|
26
27
|
"Rakefile",
|
27
28
|
"VERSION",
|
29
|
+
"app/assets/images/cacheable_flash/.gitkeep",
|
30
|
+
"app/assets/javascripts/cacheable_flash/application.js",
|
31
|
+
"app/assets/stylesheets/cacheable_flash/application.css",
|
32
|
+
"app/controllers/cacheable-flash/application_controller.rb",
|
33
|
+
"app/helpers/cacheable_flash/application_helper.rb",
|
34
|
+
"app/views/layouts/cacheable-flash/application.html.erb",
|
28
35
|
"cacheable_flash.gemspec",
|
36
|
+
"config/routes.rb",
|
29
37
|
"init.rb",
|
30
38
|
"install.rb",
|
31
39
|
"lib/cacheable_flash.rb",
|
32
|
-
"lib/cacheable_flash/
|
33
|
-
"lib/cacheable_flash/
|
40
|
+
"lib/cacheable_flash/engine.rb",
|
41
|
+
"lib/cacheable_flash/railtie.rb",
|
42
|
+
"lib/cacheable_flash/version.rb",
|
34
43
|
"lib/generators/cacheable_flash/install/install_generator.rb",
|
44
|
+
"lib/tasks/cacheable-flash_tasks.rake",
|
45
|
+
"script/rails",
|
35
46
|
"spec/cacheable_flash/cacheable_flash_spec.rb",
|
36
47
|
"spec/cacheable_flash/install_spec.rb",
|
37
48
|
"spec/cacheable_flash/test_helpers_spec.rb",
|
49
|
+
"spec/controllers/dummy_controller_spec.rb",
|
50
|
+
"spec/dummy/README.rdoc",
|
51
|
+
"spec/dummy/Rakefile",
|
52
|
+
"spec/dummy/app/assets/javascripts/application.js",
|
53
|
+
"spec/dummy/app/assets/stylesheets/application.css",
|
54
|
+
"spec/dummy/app/controllers/application_controller.rb",
|
55
|
+
"spec/dummy/app/controllers/dummy_controller.rb",
|
56
|
+
"spec/dummy/app/helpers/application_helper.rb",
|
57
|
+
"spec/dummy/app/mailers/.gitkeep",
|
58
|
+
"spec/dummy/app/models/.gitkeep",
|
59
|
+
"spec/dummy/app/views/dummy/index.html.erb",
|
60
|
+
"spec/dummy/app/views/layouts/application.html.erb",
|
61
|
+
"spec/dummy/config.ru",
|
62
|
+
"spec/dummy/config/application.rb",
|
63
|
+
"spec/dummy/config/boot.rb",
|
64
|
+
"spec/dummy/config/database.yml",
|
65
|
+
"spec/dummy/config/environment.rb",
|
66
|
+
"spec/dummy/config/environments/development.rb",
|
67
|
+
"spec/dummy/config/environments/production.rb",
|
68
|
+
"spec/dummy/config/environments/test.rb",
|
69
|
+
"spec/dummy/config/initializers/backtrace_silencers.rb",
|
70
|
+
"spec/dummy/config/initializers/inflections.rb",
|
71
|
+
"spec/dummy/config/initializers/mime_types.rb",
|
72
|
+
"spec/dummy/config/initializers/secret_token.rb",
|
73
|
+
"spec/dummy/config/initializers/session_store.rb",
|
74
|
+
"spec/dummy/config/initializers/wrap_parameters.rb",
|
75
|
+
"spec/dummy/config/locales/en.yml",
|
76
|
+
"spec/dummy/config/routes.rb",
|
77
|
+
"spec/dummy/lib/assets/.gitkeep",
|
78
|
+
"spec/dummy/log/.gitkeep",
|
79
|
+
"spec/dummy/public/404.html",
|
80
|
+
"spec/dummy/public/422.html",
|
81
|
+
"spec/dummy/public/500.html",
|
82
|
+
"spec/dummy/public/favicon.ico",
|
83
|
+
"spec/dummy/script/rails",
|
38
84
|
"spec/js_unit/cookie_test.html",
|
39
85
|
"spec/js_unit/flash_test.html",
|
40
86
|
"spec/spec_helper.rb",
|
@@ -53,29 +99,32 @@ Gem::Specification.new do |s|
|
|
53
99
|
s.specification_version = 3
|
54
100
|
|
55
101
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
56
|
-
s.add_runtime_dependency(%q<rails>, ["> 3.0"])
|
57
102
|
s.add_runtime_dependency(%q<json>, [">= 0"])
|
58
|
-
s.add_development_dependency(%q<
|
59
|
-
s.add_development_dependency(%q<
|
103
|
+
s.add_development_dependency(%q<rails>, ["~> 3.1.3"])
|
104
|
+
s.add_development_dependency(%q<jquery-rails>, [">= 0"])
|
105
|
+
s.add_development_dependency(%q<rspec-rails>, ["~> 2.8.0"])
|
106
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
60
107
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.21"])
|
61
108
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
62
109
|
s.add_development_dependency(%q<reek>, ["~> 1.2.8"])
|
63
110
|
s.add_development_dependency(%q<roodi>, ["~> 2.1.0"])
|
64
111
|
else
|
65
|
-
s.add_dependency(%q<rails>, ["> 3.0"])
|
66
112
|
s.add_dependency(%q<json>, [">= 0"])
|
67
|
-
s.add_dependency(%q<
|
68
|
-
s.add_dependency(%q<
|
113
|
+
s.add_dependency(%q<rails>, ["~> 3.1.3"])
|
114
|
+
s.add_dependency(%q<jquery-rails>, [">= 0"])
|
115
|
+
s.add_dependency(%q<rspec-rails>, ["~> 2.8.0"])
|
116
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
69
117
|
s.add_dependency(%q<bundler>, ["~> 1.0.21"])
|
70
118
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
71
119
|
s.add_dependency(%q<reek>, ["~> 1.2.8"])
|
72
120
|
s.add_dependency(%q<roodi>, ["~> 2.1.0"])
|
73
121
|
end
|
74
122
|
else
|
75
|
-
s.add_dependency(%q<rails>, ["> 3.0"])
|
76
123
|
s.add_dependency(%q<json>, [">= 0"])
|
77
|
-
s.add_dependency(%q<
|
78
|
-
s.add_dependency(%q<
|
124
|
+
s.add_dependency(%q<rails>, ["~> 3.1.3"])
|
125
|
+
s.add_dependency(%q<jquery-rails>, [">= 0"])
|
126
|
+
s.add_dependency(%q<rspec-rails>, ["~> 2.8.0"])
|
127
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
79
128
|
s.add_dependency(%q<bundler>, ["~> 1.0.21"])
|
80
129
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
81
130
|
s.add_dependency(%q<reek>, ["~> 1.2.8"])
|
data/config/routes.rb
ADDED
data/lib/cacheable_flash.rb
CHANGED
@@ -1,15 +1,19 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
module CacheableFlash
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
if defined?(Rails) && ::Rails::VERSION::MAJOR == 3
|
5
|
+
if ::Rails::VERSION::MINOR >= 1
|
6
|
+
require "cacheable_flash/engine"
|
7
|
+
require 'cacheable_flash/railtie'
|
8
|
+
elsif ::Rails::VERSION::MINOR == 0
|
9
|
+
require 'cacheable_flash/railtie'
|
10
|
+
end
|
8
11
|
else
|
9
12
|
# For older rails use generator
|
10
13
|
end
|
11
14
|
|
12
15
|
def self.included(base)
|
16
|
+
#base must define around_filter, as in Rails
|
13
17
|
base.around_filter :write_flash_to_cookie
|
14
18
|
end
|
15
19
|
|
@@ -17,7 +21,7 @@ module CacheableFlash
|
|
17
21
|
yield if block_given?
|
18
22
|
cookie_flash = if cookies['flash']
|
19
23
|
begin
|
20
|
-
|
24
|
+
JSON(cookies['flash'])
|
21
25
|
rescue
|
22
26
|
{}
|
23
27
|
end
|
@@ -32,8 +36,9 @@ module CacheableFlash
|
|
32
36
|
cookie_flash[key.to_s] << "<br/>#{value}"
|
33
37
|
end
|
34
38
|
end
|
35
|
-
|
39
|
+
# Base must define cookies, as in Rails
|
36
40
|
cookies['flash'] = cookie_flash.to_json.gsub("+", "%2B")
|
41
|
+
# Base must define flash, as in Rails
|
37
42
|
flash.clear
|
38
43
|
end
|
39
44
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Add cacheable flash JS to defaults for Rails < 3.1 (not needed with asset pipeline)
|
2
|
+
module CacheableFlash
|
3
|
+
class Railtie < ::Rails::Railtie
|
4
|
+
if ::Rails::VERSION::MAJOR == 3
|
5
|
+
config.before_configuration do
|
6
|
+
config.action_view.javascript_expansions[:cacheable_flash] = %w(flash jquery.cookie)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|