flash-message-conductor 1.0.0
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/MIT-LICENSE +20 -0
- data/README +42 -0
- data/VERSION.yml +4 -0
- data/lib/flash_message_conductor.rb +48 -0
- data/rails/init.rb +4 -0
- metadata +60 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Planet Argon
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
Flash Message Conductor
|
2
|
+
============
|
3
|
+
|
4
|
+
A simple pattern for managing flash messages in your Ruby on Rails application.
|
5
|
+
|
6
|
+
|
7
|
+
Example
|
8
|
+
=======
|
9
|
+
|
10
|
+
# Controller helpers
|
11
|
+
|
12
|
+
add_message( 'foo' )
|
13
|
+
|
14
|
+
is the equivalent of
|
15
|
+
|
16
|
+
flash[:message] = 'foo'
|
17
|
+
|
18
|
+
Controller helpers included:
|
19
|
+
|
20
|
+
add_message( message )
|
21
|
+
add_notice( message )
|
22
|
+
add_error( message )
|
23
|
+
|
24
|
+
# View helpers
|
25
|
+
|
26
|
+
<%= render_flash_messages %>
|
27
|
+
|
28
|
+
produces:
|
29
|
+
|
30
|
+
<div id="flash_messages">
|
31
|
+
<p class="message">You have successfully done XYZ...</p>
|
32
|
+
</div>
|
33
|
+
|
34
|
+
# or... if you set an error
|
35
|
+
|
36
|
+
<div id="flash_messages">
|
37
|
+
<p class="error">Oops! Something went bonkers!</p>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
Copyright (c) 2008 Planet Argon, released under the MIT license
|
data/VERSION.yml
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# ArgonHelpers
|
2
|
+
|
3
|
+
module PlanetArgon
|
4
|
+
module FlashMessageConductor
|
5
|
+
FLASH_MESSAGE_TYPES = [ :error, :notice, :message ]
|
6
|
+
|
7
|
+
module ControllerHelpers
|
8
|
+
def add_error(msg)
|
9
|
+
flash[:error] = msg
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_notice(msg)
|
13
|
+
flash[:notice] = msg
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_message(msg)
|
17
|
+
flash[:message] = msg
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
module ViewHelpers
|
22
|
+
def render_flash_message( css_class, message = "" )
|
23
|
+
return "" if message.nil? or message.blank?
|
24
|
+
content_tag( "p", message, :class => "#{css_class}" )
|
25
|
+
end
|
26
|
+
|
27
|
+
def render_flash_messages( div_id = "flash_messages", div_class = "" )
|
28
|
+
div_content = ''
|
29
|
+
FLASH_MESSAGE_TYPES.each do |key|
|
30
|
+
div_content << render_flash_message( key.to_s, flash[key] ) unless flash[key].blank?
|
31
|
+
end
|
32
|
+
if div_content.blank?
|
33
|
+
return ""
|
34
|
+
else
|
35
|
+
return content_tag( 'div', div_content, :id => div_id, :class => div_class )
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def flash_message_set?
|
40
|
+
flash_set = false
|
41
|
+
FLASH_MESSAGE_TYPES.each do |key|
|
42
|
+
flash_set = true unless flash[key].blank?
|
43
|
+
end
|
44
|
+
return flash_set
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/rails/init.rb
ADDED
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flash-message-conductor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robby Russell
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-12 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: A simple pattern for managing flash messages in your Ruby on Rails application
|
17
|
+
email: robby@planetargon.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- VERSION.yml
|
26
|
+
- lib/flash_message_conductor.rb
|
27
|
+
- rails/init.rb
|
28
|
+
- README
|
29
|
+
- MIT-LICENSE
|
30
|
+
has_rdoc: true
|
31
|
+
homepage: http://github.com/planetargon/flash-message-conductor
|
32
|
+
licenses: []
|
33
|
+
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options:
|
36
|
+
- --inline-source
|
37
|
+
- --charset=UTF-8
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
45
|
+
version:
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
version:
|
52
|
+
requirements: []
|
53
|
+
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 1.3.5
|
56
|
+
signing_key:
|
57
|
+
specification_version: 3
|
58
|
+
summary: Conduct your Flash Messages in Rails
|
59
|
+
test_files: []
|
60
|
+
|