sinatra-pretty-flash 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6bc66c31278a0b80b49a28a38122f84dd172593e
4
+ data.tar.gz: 2b8db3e8d31b5150ba7debe534083fb10c9daf04
5
+ SHA512:
6
+ metadata.gz: fa4efad9bcc3ef3a44fe55d97c21987a352daeb2372b5eb1c51ca60daef0bd3990d6a9e92cba1724ce75adf1b9a57db07c9b3502d30b8874e0adebfa68ed0a79
7
+ data.tar.gz: 3bdf8b4771bb86d6aaa7ad962134f59f3c540c7b0a59fb8a2bf0644643ff9ec63fbbf312dd11b619a617b0d68f013dfdca11d526b0ac7fd51ee8b976edeabff8
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,26 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sinatra-pretty-flash (0.0.1)
5
+ rack-flash3
6
+ sinatra
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ rack (1.5.2)
12
+ rack-flash3 (1.0.5)
13
+ rack
14
+ rack-protection (1.5.3)
15
+ rack
16
+ sinatra (1.4.5)
17
+ rack (~> 1.4)
18
+ rack-protection (~> 1.4)
19
+ tilt (~> 1.3, >= 1.3.4)
20
+ tilt (1.4.1)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ sinatra-pretty-flash!
data/README.md ADDED
@@ -0,0 +1,14 @@
1
+ Sinatra-Pretty-Flash
2
+ ====================
3
+
4
+ A simple gem that adds decent styled flash messages to a Sinatra app.
5
+
6
+ Why?
7
+ ----
8
+
9
+ While prototyping some things out in Sinatra I wanted a simple but decent looking flash message. I guess I was just used to our pretty awesome eco-system at work but I was surprised at how much code I'd need to add to have a nice looking flash message. Anyways I didn't want all that code in my prototype so I made this gem.
10
+
11
+ How?
12
+ ----
13
+
14
+ For usage see the included example
@@ -0,0 +1,36 @@
1
+ require 'sinatra/base'
2
+ require 'sinatra/pretty-flash'
3
+
4
+ class ExampleApp < Sinatra::Base
5
+ register Sinatra::PrettyFlash
6
+
7
+ enable :inline_templates
8
+
9
+ get '/' do
10
+ flash[:notice] = "Flash Notice!"
11
+ erb :index
12
+ end
13
+
14
+ end
15
+
16
+ ExampleApp.run!
17
+
18
+ __END__
19
+
20
+ @@ layout
21
+ <html>
22
+ <head>
23
+ <%= pretty_flash_css %>
24
+ </head>
25
+ <body>
26
+ <%= erb pretty_flash_html %>
27
+ <%= yield %>
28
+ </body>
29
+ <%= pretty_flash_js %>
30
+ </html>
31
+
32
+ @@ index
33
+ <div>
34
+ <p>Hello world</p>
35
+ <a href='/'>refresh</a>
36
+ </div>
@@ -0,0 +1,60 @@
1
+ require 'sinatra/base'
2
+ require 'rack-flash'
3
+
4
+ module Sinatra
5
+ module PrettyFlash
6
+ def self.registered(app)
7
+ app.helpers FlashHelper
8
+ app.enable :sessions
9
+ app.use Rack::Flash, :sweep => true
10
+ end
11
+ end
12
+
13
+ module FlashHelper
14
+ def pretty_flash_css
15
+ output = ''
16
+ output += '<style>'
17
+ output += '.flash {'
18
+ output += ' position: fixed;'
19
+ output += ' padding: 0;'
20
+ output += ' margin: 0;'
21
+ output += ' bottom: 0;'
22
+ output += ' left: 0;'
23
+ output += ' width: 100%;'
24
+ output += ' height: 60px;'
25
+ output += ' line-height: 60px;'
26
+ output += ' background: rgba(0, 0, 0, 0.85);'
27
+ output += ' color: rgba(255, 255, 255, 1.0);'
28
+ output += ' text-align: center;'
29
+ output += ' font-size: 24px;'
30
+ output += '}'
31
+ output += '</style>'
32
+ output
33
+ end
34
+
35
+ def pretty_flash_html
36
+ output = ''
37
+ output += '<% if flash[:notice] %>'
38
+ output += ' <p class="flash notice"><%= flash[:notice] %></p>'
39
+ output += '<% end %>'
40
+
41
+ output += '<% if flash[:error] %>'
42
+ output += ' <p class="flash error"><%= flash[:error] %></p>'
43
+ output += '<% end %>'
44
+ output
45
+ end
46
+
47
+ def pretty_flash_js
48
+ output = ''
49
+ output += '<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>'
50
+ output += '<script>'
51
+ output += '$(function() {'
52
+ output += ' $(".flash").delay(500).fadeIn("normal", function() {'
53
+ output += ' $(this).delay(1500).fadeOut();'
54
+ output += ' });'
55
+ output += '});'
56
+ output += '</script>'
57
+ output
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,17 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'sinatra-pretty-flash'
3
+ s.version = '0.0.1'
4
+
5
+ s.summary = "Simple decent looking flash messages"
6
+ s.description = "A Sinatra extension that adds simple decent looking flash messages"
7
+
8
+ s.authors = ["Kevin Hughes"]
9
+ s.email = "kevin.hughes@shopify.com"
10
+ s.homepage = "https://github.com/pickle27/sinatra-pretty-flash/"
11
+ s.license = 'MIT'
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+
15
+ s.add_runtime_dependency 'sinatra'
16
+ s.add_runtime_dependency 'rack-flash3'
17
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sinatra-pretty-flash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kevin Hughes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sinatra
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack-flash3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A Sinatra extension that adds simple decent looking flash messages
42
+ email: kevin.hughes@shopify.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - ".gitignore"
48
+ - Gemfile
49
+ - Gemfile.lock
50
+ - README.md
51
+ - example/example_app.rb
52
+ - lib/sinatra/pretty-flash.rb
53
+ - sinatra-pretty-flash.gemspec
54
+ homepage: https://github.com/pickle27/sinatra-pretty-flash/
55
+ licenses:
56
+ - MIT
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.2.2
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Simple decent looking flash messages
78
+ test_files: []