unobtrusive_flash 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +9 -9
- data/CHANGELOG.md +4 -0
- data/README.markdown +5 -2
- data/{vendor → lib}/assets/javascripts/unobtrusive_flash.js +0 -0
- data/{vendor → lib}/assets/javascripts/unobtrusive_flash_bootstrap.js +0 -0
- data/{vendor → lib}/assets/javascripts/unobtrusive_flash_ui.js +0 -0
- data/{vendor → lib}/assets/stylesheets/unobtrusive_flash_ui.css +0 -0
- data/lib/unobtrusive_flash/controller_mixin.rb +12 -1
- data/lib/unobtrusive_flash/version.rb +1 -1
- data/spec/sanitize_flash_spec.rb +13 -0
- data/spec/spec_helper.rb +3 -0
- data/unobtrusive_flash.gemspec +1 -0
- metadata +26 -8
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTFiNGZlYTIwNDBjMDEwZTVmMGM3Mzc4YTExZDEyNTJlZmNlYjNlNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
7
|
-
|
6
|
+
NGE5MWVkZWVhODFlZGNmYWM1YzRhZWZkNDczYWQ3YWFlY2FkYmEzYw==
|
7
|
+
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzExMDQ1YjM2ODA3YjFmOGZlZWM5MWY3MjViYmYzYmRmMjc3Y2NhYjc2NGUw
|
10
|
+
ZTJlOWJlZjdjNzllMTdmOTYxMWI5OWI5YWY5ZGQ3MDRkMmVkNmNkNDg1NTdh
|
11
|
+
NTUwNmM1YTRjNWM5Y2FjNzJiOTg5YjQ2YmYwNDc4Mzk0OGJmNjE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MzU3YTc0NDI5OGI2NjY2MjEzZjI3NmNmODlmYmE4OWRmNTRjNmE5MTY5OTk4
|
14
|
+
Nzc1NDI3OWUwNzk1YjMzNWY0Njg5YmU3OWYyN2VlNDNkM2FlMzhkMWZkYjEz
|
15
|
+
NjY2NWZkOTZlMTFjNzI2NTI1NTRhYWY4MTA3NTQzMmU0OWY0NDk=
|
data/CHANGELOG.md
CHANGED
data/README.markdown
CHANGED
@@ -30,12 +30,15 @@ Tested in:
|
|
30
30
|
|
31
31
|
## Usage
|
32
32
|
|
33
|
-
1. Add the gem to your
|
33
|
+
1. Add the `unobtrusive_flash` gem to your Gemfile.
|
34
|
+
|
35
|
+
gem 'unobtrusive_flash', '~>2'
|
36
|
+
|
34
37
|
2. Add the following to the controllers that generate flash messages (or better, to the `ApplicationController`):
|
35
38
|
|
36
39
|
after_filter :prepare_unobtrusive_flash
|
37
40
|
|
38
|
-
|
41
|
+
Flash messages are HTML escaped in the same manner as regular Rails view code: if a message is not `html_safe`, it is escaped, otherwise not. This lets you use helpers such as `link_to` in your messages.
|
39
42
|
|
40
43
|
3. Include `require unobtrusive_flash` in your `application.js`.
|
41
44
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'active_support/core_ext/string/output_safety'
|
2
|
+
|
1
3
|
module UnobtrusiveFlash
|
2
4
|
module ControllerMixin
|
3
5
|
protected
|
@@ -10,10 +12,19 @@ module UnobtrusiveFlash
|
|
10
12
|
cookie_flash=[] unless cookie_flash.is_a? Array
|
11
13
|
end
|
12
14
|
|
13
|
-
cookie_flash += flash
|
15
|
+
cookie_flash += UnobtrusiveFlash::ControllerMixin.sanitize_flash(flash)
|
14
16
|
cookies[:flash] = {:value => cookie_flash.to_json, :domain => :all}
|
15
17
|
flash.discard
|
16
18
|
end
|
17
19
|
end
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def sanitize_flash(flash)
|
23
|
+
flash.to_a.map do |key, value|
|
24
|
+
html_safe_value = value.html_safe? ? value : ERB::Util.html_escape(value)
|
25
|
+
[key, html_safe_value]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
18
29
|
end
|
19
30
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe UnobtrusiveFlash::ControllerMixin do
|
4
|
+
describe '.sanitize_flash' do
|
5
|
+
it 'should escape messages that are not html safe' do
|
6
|
+
described_class.sanitize_flash({:foo => '<bar>'}).should == [[:foo, '<bar>']]
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should not escape messages that are html safe' do
|
10
|
+
described_class.sanitize_flash({:foo => '<bar>'.html_safe}).should == [[:foo, '<bar>']]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/unobtrusive_flash.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unobtrusive_flash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonid Shevtsov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: ! 'unobtrusive_flash takes your flash messages for the backend and automagically
|
56
70
|
passes them to the frontend via HTTP cookies.
|
57
71
|
|
@@ -72,15 +86,17 @@ files:
|
|
72
86
|
- Gemfile
|
73
87
|
- README.markdown
|
74
88
|
- Rakefile
|
89
|
+
- lib/assets/javascripts/unobtrusive_flash.js
|
90
|
+
- lib/assets/javascripts/unobtrusive_flash_bootstrap.js
|
91
|
+
- lib/assets/javascripts/unobtrusive_flash_ui.js
|
92
|
+
- lib/assets/stylesheets/unobtrusive_flash_ui.css
|
75
93
|
- lib/unobtrusive_flash.rb
|
76
94
|
- lib/unobtrusive_flash/controller_mixin.rb
|
77
95
|
- lib/unobtrusive_flash/engine.rb
|
78
96
|
- lib/unobtrusive_flash/version.rb
|
97
|
+
- spec/sanitize_flash_spec.rb
|
98
|
+
- spec/spec_helper.rb
|
79
99
|
- unobtrusive_flash.gemspec
|
80
|
-
- vendor/assets/javascripts/unobtrusive_flash.js
|
81
|
-
- vendor/assets/javascripts/unobtrusive_flash_bootstrap.js
|
82
|
-
- vendor/assets/javascripts/unobtrusive_flash_ui.js
|
83
|
-
- vendor/assets/stylesheets/unobtrusive_flash_ui.css
|
84
100
|
homepage: https://github.com/leonid-shevtsov/unobtrusive_flash
|
85
101
|
licenses: []
|
86
102
|
metadata: {}
|
@@ -100,8 +116,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
116
|
version: '0'
|
101
117
|
requirements: []
|
102
118
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.
|
119
|
+
rubygems_version: 2.1.11
|
104
120
|
signing_key:
|
105
121
|
specification_version: 4
|
106
122
|
summary: Unobtrusive flash messages for Rails
|
107
|
-
test_files:
|
123
|
+
test_files:
|
124
|
+
- spec/sanitize_flash_spec.rb
|
125
|
+
- spec/spec_helper.rb
|