growlyflash 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +0 -1
- data/LICENSE.txt +21 -0
- data/README.md +5 -11
- data/growlyflash.gemspec +12 -10
- data/lib/growlyflash.rb +5 -1
- data/lib/growlyflash/controller_additions.rb +24 -23
- data/lib/growlyflash/engine.rb +2 -0
- data/lib/growlyflash/version.rb +3 -0
- metadata +39 -14
- data/test/integration/action_controller/growlyflash_test.rb +0 -40
- data/test/test_helper.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b15ba027b5bb449f0ab3a2d18a0a8273d73867e
|
4
|
+
data.tar.gz: 5acfd64725e4a5faa2614800696d0b2d818f841f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0554c4b4fdca37baa13ec0fa115884c39ceaef8dd72fce7631070c7d1aab35fb8cc3bc71fdb6ad5c3db2500841748684152a8b60cc9d04d1be4bbcf0880eb41
|
7
|
+
data.tar.gz: a647b4016db94cbeff98a44ec18b91af0b5800b8bfe430fdd0459726403c992e47bd9e612ad36d0c34e0d332b924a0d7b34c24e80e3e6c41a8ddab37c82defc4
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Tõnis Simo
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@ Warning! Current version breaks integration from older releases, so, if you want
|
|
15
15
|
Add this line to your application's Gemfile:
|
16
16
|
|
17
17
|
```ruby
|
18
|
-
gem 'growlyflash', '~> 0.
|
18
|
+
gem 'growlyflash', '~> 0.6.0'
|
19
19
|
```
|
20
20
|
|
21
21
|
Require one of the following Growlyflash javascripts depending on your Bootstrap version in `app/assets/javascripts/application.js`:
|
@@ -34,7 +34,7 @@ Import Growlyflash style in `app/assets/stylesheets/application.css.scss` after
|
|
34
34
|
@import "growlyflash";
|
35
35
|
```
|
36
36
|
|
37
|
-
To use text flash messages as growl notifications with XHR request, add `use_growlyflash` to your controllers (usually `application_controller.rb`). This is a shorthand for `append_after_filter :flash_to_header, if:
|
37
|
+
To use text flash messages as growl notifications with XHR request, add `use_growlyflash` to your controllers (usually `application_controller.rb`). This is a shorthand for `append_after_filter :flash_to_header, if: "request.xhr?"` and takes callback parameters like `only`, `except`, `if` or `unless`:
|
38
38
|
|
39
39
|
```ruby
|
40
40
|
use_growlyflash # except: %i[actions without growlyflash]
|
@@ -76,23 +76,17 @@ $growlyflash-zindex: 9999 !default;
|
|
76
76
|
@import "growlyflash";
|
77
77
|
```
|
78
78
|
|
79
|
-
Insert the following if you want to close alert boxes by clicking on themselves.
|
79
|
+
Insert the following if you want to close alert boxes by clicking on themselves.
|
80
80
|
Also it doesn't steel focus from toggled elements like dropdowns and works fine with touch devices, so I advise to use it:
|
81
81
|
|
82
82
|
```coffee
|
83
83
|
jQuery ->
|
84
|
-
$(document).on
|
84
|
+
$(document).on "touchstart.alert click.alert", ".growlyflash", (e) ->
|
85
85
|
e.stopPropagation()
|
86
|
-
|
87
|
-
|
88
|
-
$(document).on 'touchstart click', ".bootstrap-growl", (e) ->
|
89
|
-
e.stopPropagation()
|
90
|
-
$('[data-dismiss="alert"]', @).click()
|
86
|
+
($ @).alert 'close'
|
91
87
|
off
|
92
88
|
```
|
93
89
|
|
94
|
-
Also
|
95
|
-
|
96
90
|
## Contributing
|
97
91
|
|
98
92
|
1. Fork it
|
data/growlyflash.gemspec
CHANGED
@@ -2,23 +2,25 @@
|
|
2
2
|
|
3
3
|
lib = File.expand_path('../lib', __FILE__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "growlyflash/version"
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
8
|
spec.name = 'growlyflash'
|
8
|
-
spec.version =
|
9
|
+
spec.version = Growlyflash::VERSION
|
9
10
|
spec.authors = ['Tõnis Simo']
|
10
11
|
spec.email = ['anton.estum@gmail.com']
|
12
|
+
spec.summary = %q{Growl-styled flash messages for Ruby on Rails with Bootstrap.}
|
13
|
+
spec.description = %q{Growl-styled flash messages for Ruby on Rails with Bootstrap. For XHR requests flash messages are transfering in 'X-Messages' headers, otherwise they are storing in js variables.}
|
11
14
|
spec.homepage = 'https://github.com/estum/growlyflash'
|
12
|
-
spec.
|
13
|
-
|
14
|
-
spec.
|
15
|
-
|
16
|
-
|
17
|
-
spec.require_paths = %w[app lib]
|
18
|
-
spec.test_files = Dir['test/**/*']
|
19
|
-
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
20
|
spec.required_ruby_version = ">= 1.9.3"
|
21
|
-
|
21
|
+
|
22
22
|
spec.add_dependency 'railties', '>= 3.2', '< 5.0'
|
23
23
|
spec.add_dependency 'coffee-rails', '>= 3.2.1'
|
24
|
+
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "rake"
|
24
26
|
end
|
data/lib/growlyflash.rb
CHANGED
@@ -1,44 +1,45 @@
|
|
1
|
-
require 'active_support/concern'
|
2
|
-
|
3
1
|
module Growlyflash
|
4
2
|
module ControllerAdditions
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
def self.included(base)
|
4
|
+
base.module_eval do
|
5
|
+
extend ClassMethods
|
6
|
+
helper_method :growlyflash_static_notices, :growlyhash
|
7
|
+
end
|
9
8
|
end
|
10
|
-
|
9
|
+
|
11
10
|
module ClassMethods
|
12
11
|
private
|
12
|
+
|
13
13
|
def use_growlyflash(options = {})
|
14
|
-
append_after_filter :flash_to_headers, options.reverse_merge(if:
|
14
|
+
append_after_filter :flash_to_headers, options.reverse_merge(if: "request.xhr?")
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def skip_growlyflash(options = {})
|
18
18
|
skip_after_filter :flash_to_headers, options
|
19
19
|
end
|
20
20
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
# Dumps available messages to headers and discards them to prevent appear
|
25
|
+
# it again after refreshing a page
|
27
26
|
def flash_to_headers
|
28
27
|
response.headers['X-Message'] = URI.escape(growlyhash(true).to_json)
|
29
|
-
|
30
|
-
# discard flash to prevent it appear again after refreshing page
|
31
|
-
growlyhash.each_key {|k| flash.discard(k) }
|
28
|
+
growlyhash.each_key { |k| flash.discard(k) }
|
32
29
|
end
|
33
|
-
|
30
|
+
|
31
|
+
# View helper method which renders flash messages to js variable if they
|
32
|
+
# weren't dumped to headers with XHR request
|
34
33
|
def growlyflash_static_notices(js_var = 'window.flashes')
|
35
|
-
return
|
36
|
-
|
34
|
+
return if flash.empty?
|
35
|
+
script = "#{js_var} = #{growlyhash.to_json.html_safe};".freeze
|
36
|
+
view_context.javascript_tag(script, defer: 'defer')
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
|
+
# Hash with available growl flash messages which contains a string object.
|
39
40
|
def growlyhash(force = false)
|
40
41
|
@growlyhash = nil if force
|
41
|
-
@growlyhash ||= flash.to_hash.select {|k, v| v.is_a? String }
|
42
|
+
@growlyhash ||= flash.to_hash.select { |k, v| v.is_a? String }
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
data/lib/growlyflash/engine.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: growlyflash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tõnis Simo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -44,9 +44,37 @@ dependencies:
|
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 3.2.1
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rake
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
description: Growl-styled flash messages for Ruby on Rails with Bootstrap. For XHR
|
76
|
+
requests flash messages are transfering in 'X-Messages' headers, otherwise they
|
77
|
+
are storing in js variables.
|
50
78
|
email:
|
51
79
|
- anton.estum@gmail.com
|
52
80
|
executables: []
|
@@ -54,7 +82,9 @@ extensions: []
|
|
54
82
|
extra_rdoc_files: []
|
55
83
|
files:
|
56
84
|
- ".gitignore"
|
85
|
+
- CODE_OF_CONDUCT.md
|
57
86
|
- Gemfile
|
87
|
+
- LICENSE.txt
|
58
88
|
- README.md
|
59
89
|
- Rakefile
|
60
90
|
- app/assets/javascripts/growlyflash.bs2.js.coffee
|
@@ -66,8 +96,7 @@ files:
|
|
66
96
|
- lib/growlyflash.rb
|
67
97
|
- lib/growlyflash/controller_additions.rb
|
68
98
|
- lib/growlyflash/engine.rb
|
69
|
-
-
|
70
|
-
- test/test_helper.rb
|
99
|
+
- lib/growlyflash/version.rb
|
71
100
|
homepage: https://github.com/estum/growlyflash
|
72
101
|
licenses:
|
73
102
|
- MIT
|
@@ -75,7 +104,6 @@ metadata: {}
|
|
75
104
|
post_install_message:
|
76
105
|
rdoc_options: []
|
77
106
|
require_paths:
|
78
|
-
- app
|
79
107
|
- lib
|
80
108
|
required_ruby_version: !ruby/object:Gem::Requirement
|
81
109
|
requirements:
|
@@ -89,11 +117,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
117
|
version: '0'
|
90
118
|
requirements: []
|
91
119
|
rubyforge_project:
|
92
|
-
rubygems_version: 2.4.
|
120
|
+
rubygems_version: 2.4.7
|
93
121
|
signing_key:
|
94
122
|
specification_version: 4
|
95
|
-
summary:
|
96
|
-
|
97
|
-
test_files:
|
98
|
-
- test/integration/action_controller/growlyflash_test.rb
|
99
|
-
- test/test_helper.rb
|
123
|
+
summary: Growl-styled flash messages for Ruby on Rails with Bootstrap.
|
124
|
+
test_files: []
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module ActionController
|
4
|
-
module Growlyflash
|
5
|
-
class IntegrationTest < ActionController::TestCase
|
6
|
-
class MyController < ActionController::Base
|
7
|
-
use_growlyflash
|
8
|
-
skip_growlyflash only: [:xhr_skip_growlyflash]
|
9
|
-
|
10
|
-
def xhr_use_growlyflash
|
11
|
-
flash.notice = "Growlyflash!"
|
12
|
-
flash[:timedout] = true
|
13
|
-
render json: '{}'
|
14
|
-
end
|
15
|
-
|
16
|
-
def xhr_skip_growlyflash
|
17
|
-
flash.notice = "Growlyflash!"
|
18
|
-
render json: '{}'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
tests MyController
|
23
|
-
|
24
|
-
def test_xhr_use_growlyflash
|
25
|
-
xhr :get, :xhr_use_growlyflash
|
26
|
-
|
27
|
-
assert_response 200
|
28
|
-
refute_nil @response.headers['X-Message']
|
29
|
-
assert_equal '{"notice":"Growlyflash!"}', URI.decode_www_form_component(@response.headers['X-Message'])
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_xhr_skip_growlyflash
|
33
|
-
xhr :get, :xhr_skip_growlyflash
|
34
|
-
|
35
|
-
assert_response 200
|
36
|
-
assert_nil @response.headers['X-Message']
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'bundler/setup'
|
2
|
-
require 'minitest/autorun'
|
3
|
-
require 'growlyflash'
|
4
|
-
require 'action_controller'
|
5
|
-
|
6
|
-
# Ensure backward compatibility with Minitest 4
|
7
|
-
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
|
8
|
-
|
9
|
-
require "minitest/reporters"
|
10
|
-
Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new(:color => true)
|
11
|
-
|
12
|
-
module TestHelper
|
13
|
-
Routes = ActionDispatch::Routing::RouteSet.new
|
14
|
-
Routes.draw do
|
15
|
-
get ':controller(/:action(/:id))'
|
16
|
-
get ':controller(/:action)'
|
17
|
-
end
|
18
|
-
|
19
|
-
ActionController::Base.send :include, Routes.url_helpers
|
20
|
-
end
|
21
|
-
|
22
|
-
ActionController::TestCase.class_eval do
|
23
|
-
def setup
|
24
|
-
@routes = TestHelper::Routes
|
25
|
-
end
|
26
|
-
end
|