Skip to content
This repository was archived by the owner on Nov 15, 2020. It is now read-only.

Commit cfc2fc7

Browse files
authored
No longer maintained; Alternative!
1 parent cdda4a5 commit cfc2fc7

File tree

1 file changed

+2
-174
lines changed

1 file changed

+2
-174
lines changed

README.rdoc

+2-174
Original file line numberDiff line numberDiff line change
@@ -2,181 +2,9 @@
22

33
== This gem is no longer maintained.
44

5-
=== Please consider switching to https://github.com/leonid-shevtsov/unobtrusive_flash
5+
= Please consider switching to https://github.com/leonid-shevtsov/unobtrusive_flash
66

7-
So long, and thanks for all the fish!
8-
9-
= CacheableFlash {<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/pboling/cacheable-flash] {<img src="https://secure.travis-ci.org/pboling/cacheable-flash.png?branch=master" alt="Build Status" />}[http://travis-ci.org/pboling/cacheable-flash] {<img src="https://badges.depfu.com/badges/f13068686306ad691084c5112078dd2d/count.svg" />}[https://depfu.com/github/pboling/cacheable-flash?project=Bundler]
10-
11-
== Description
12-
13-
This plugin enables greater levels of page caching by rendering flash
14-
messages from a cookie using JavaScript, instead of in your Rails
15-
view template. Flash contents are converted to JSON and placed in
16-
a cookie by an after_filter in a controller or a Rack middleware in
17-
your application.
18-
19-
== Installation as gem
20-
21-
gem 'cacheable_flash' # added to your Gemfile
22-
$ bundle install
23-
24-
== Setup
25-
26-
=== Without asset pipeline, or pre-Rails 3.1:
27-
28-
First copy the JS assets into your app:
29-
rails generate cacheable_flash:install
30-
31-
CacheableFlash adds its javascript dependencies as a Rails 3 javascript 'expansion',
32-
which are only used if you are NOT using the asset pipeline (apparently?).
33-
34-
So if you have config.assets.enabled = false in application.rb then in your layout:
35-
javascript_include_tag :cacheable_flash
36-
37-
Otherwise, in your layout, just source them like normal:
38-
javascript_include_tag 'flash', 'js.cookie'
39-
40-
=== With asset pipeline (requires Rails 3.1)
41-
42-
The asset pipeline should have access to the assets in this gem via your app/assets/javascripts/application.js:
43-
//= require flash
44-
//= require js.cookie
45-
46-
== Mailing List
47-
48-
http://groups.google.com/group/PivotalLabsOpenSource
49-
50-
== Bug/Feature Tracker
51-
52-
https://github.com/pboling/cacheable-flash/issues
53-
54-
== Wiki
55-
56-
Please help document!
57-
58-
https://github.com/pboling/cacheable-flash/wiki
59-
60-
== Usage as an around filter
61-
62-
To use as an around filter, include the CacheableFlash module
63-
in your controller.
64-
It's all or none on the actions in your controller, so you can't
65-
mix JS and HTML display of your flash message in a controller.
66-
No other modifications to the controller are needed. You will need
67-
to add divs and some javascript to your view or layout templates
68-
to render the flash in the browser.
69-
70-
Note that the cookie holding the flash messages is removed as the
71-
page is displayed, so a refresh will clear the flash message (just
72-
as happens normally).
73-
74-
=== Example Controller
75-
76-
class MyController < ActionController::Base
77-
include CacheableFlash
78-
# ...
79-
end
80-
81-
== Usage as a Rack middleware (requires Rails 3)
82-
83-
To use as a Rack Middleware, swap the Rails flash middleware with the
84-
Cacheable flash middleware.
85-
Use this method if you set flash messages inside a rescue_from block:
86-
87-
rescue_from CanCan::AccessDenied do |exception|
88-
redirect_to root_url, :alert => exception.message
89-
end
90-
91-
=== In your application.rb:
92-
93-
# Swap the ActionDispatch::Flash middleware with the CacheableFlash one
94-
config.middleware.swap ActionDispatch::Flash, CacheableFlash::Middleware
95-
96-
== Example Template Markup
97-
98-
<div id="error_div_id" class="flash flash_error"></div>
99-
<div id="notice_div_id" class="flash flash_notice"></div>
100-
<script type="text/javascript">
101-
Flash.transferFromCookies();
102-
Flash.writeDataTo('error', $('#error_div_id'));
103-
Flash.writeDataTo('notice', $('#notice_div_id'));
104-
</script>
105-
106-
== Security warning
107-
The gem is susceptible to reflected XSS attack. Make sure no non-alphanumerical
108-
user-generated content is stored inside flash messages (html or plain text).
109-
110-
== Testing
111-
You can test your flash cookies by making assertions on the json of the "flash" cookie.
112-
Cacheable Flash provides test helpers which includes the flash_cookie method.
113-
114-
=== Test::Unit Example
115-
require "cacheable_flash/test_helpers"
116-
117-
class TestController < ActionController::Base
118-
def index
119-
flash["notice"] = "In index"
120-
end
121-
end
122-
123-
class ControllerTest < Test::Unit::TestCase
124-
include CacheableFlash::TestHelpers
125-
126-
def setup
127-
@controller = TestController.new
128-
@request = ActionController::TestRequest.new
129-
@response = ActionController::TestResponse.new
130-
end
131-
132-
def test_cacheable_flash_action
133-
get :index
134-
assert_equal "In index", flash_cookie["notice"]
135-
end
136-
end
137-
138-
=== Rspec Example
139-
require "cacheable_flash/test_helpers"
140-
141-
class TestController < ActionController::Base
142-
def index
143-
flash["notice"] = "In index"
144-
end
145-
end
146-
147-
describe TestController, "#index" do
148-
include CacheableFlash::TestHelpers
149-
150-
it "writes to the flash cookie" do
151-
get :index
152-
flash_cookie["notice"].should == "In index"
153-
end
154-
end
155-
156-
== Contributing to cacheable-flash
157-
158-
1. Fork it
159-
2. Create your feature branch (`git checkout -b my-new-feature`)
160-
3. Commit your changes (`git commit -am 'Added some feature'`)
161-
4. Push to the branch (`git push origin my-new-feature`)
162-
5. Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
163-
6. Create new Pull Request
164-
165-
== Versioning
166-
167-
This library aims to adhere to {Semantic Versioning 2.0.0}[http://semver.org/].
168-
Violations of this scheme should be reported as bugs. Specifically,
169-
if a minor or patch version is released that breaks backward
170-
compatibility, a new version should be immediately released that
171-
restores compatibility. Breaking changes to the public API will
172-
only be introduced with new major versions.
173-
174-
As a result of this policy, you can (and should) specify a
175-
dependency on this gem using the {Pessimistic Version Constraint}[http://docs.rubygems.org/read/chapter/16#page74] with two digits of precision.
176-
177-
For example:
178-
179-
spec.add_dependency 'cacheable_flash', '~> 4.0'
7+
== So long, and thanks for all the fish!
1808

1819
== Copyright
18210

0 commit comments

Comments
 (0)