ohsnap-rails 0.2.0 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6106a98633b12a09570fadefd08f27002f00e64
4
- data.tar.gz: cf6daf70d733e3699bf2fd0be836cc9c561c18ad
3
+ metadata.gz: 9a74e03400da2d89b6efd8bbaf6cc83fe13e74fe
4
+ data.tar.gz: 298d7c9277385c7bf60805e3546978203e2de0a2
5
5
  SHA512:
6
- metadata.gz: 153dc53f32d8aa533b94a885da1541a7afa7048d004397da559422258a5054f57388ac30b54fa4125242ad03f7c528fbda526b7ab069e65d1146353dc592845a
7
- data.tar.gz: 7102bd382e2f069ecd7b754a4f4e45afb8ebb6abfc111ce649fb822b2ae9470867878170342430ddceee7ef580ce9cd2ced663ca5958a2c3b9bc24e3b92601d6
6
+ metadata.gz: cc6bad1c6f3e4fbf9bf0aa5d1867978f05708cd74e9cd901907e1d447886627750c09a41c3ea2e41a53fe457451d0e6dc62e2147d0020985edc4ed54f42d2566
7
+ data.tar.gz: 65d835846ec7cf39e97f784c6a17f66bcba1cac088fdfeb88dae7807b7bc301c87e447d2dbe6f5a1e55e193a15e19c7412a33ab45646a8cc73d88af069e4f48e
data/README.md CHANGED
@@ -32,11 +32,42 @@ To your ```application.js``` file, add:
32
32
  //= require ohsnap
33
33
  ```
34
34
 
35
- In your html content add a div:
35
+ In your application helper app/helpers/application_helper.rb add:
36
+
37
+ ```Ruby
38
+ module ApplicationHelper
39
+ ALERT_TYPES = [:blue, :green, :orange, :red] unless const_defined?(:ALERT_TYPES)
40
+ def snap_flash(options = {})
41
+ flash_messages = []
42
+ flash.each do |type, message|
43
+ next if message.blank?
44
+
45
+ type = type.to_sym
46
+ type = :blue if type == :info
47
+ type = :green if type == :notice
48
+ type = :orange if type == :alert
49
+ type = :red if type == :error
50
+
51
+ next unless ALERT_TYPES.include?(type)
52
+ Array(message).each do |msg|
53
+ flash_messages << "ohSnap('#{msg}', {color: '#{type.to_s}', duration: '7000'});" if msg
54
+ end
55
+ end
56
+ javascript_tag flash_messages.join("\n").html_safe
57
+ end
58
+ end
59
+ ```
60
+
61
+ In your application.html file here app/views/layout/application.html.erb add:
62
+
36
63
  ```HTML
37
64
  <div id="ohsnap"></div>
65
+ <%= snap_flash %>
38
66
  ```
39
67
 
68
+ Credits to [Dmytro Koval](https://github.com/dawidof) for making pointing out a typo and for the application_helper.
69
+
70
+
40
71
  Ohsnap created div with classes .alert .alert-color .So you would need to have:
41
72
 
42
73
  ```CSS
@@ -1,5 +1,5 @@
1
1
  module Ohsnap
2
2
  module Rails
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohsnap-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rahul Lakhaney
@@ -59,7 +59,7 @@ files:
59
59
  - lib/ohsnap/rails/version.rb
60
60
  - ohsnap-rails.gemspec
61
61
  - ohsnap.png
62
- - vendor/assets/javasccripts/ohsnap.js
62
+ - vendor/assets/javascripts/ohsnap.js
63
63
  homepage: https://github.com/rahullakhaney/ohsnap-rails
64
64
  licenses:
65
65
  - MIT