sinatra-pretty-flash 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +19 -12
- data/example/example_app.rb +10 -2
- data/lib/sinatra/pretty-flash.rb +37 -41
- data/sinatra-pretty-flash.gemspec +7 -7
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 98a93346e78885c0dec3403adb71f4b44649c552e8a784c3a43dffc68971c380
|
4
|
+
data.tar.gz: 002b6f5f62e23eb3835cbb2cf9cab9cf867763297e41e7042ec41429f5b7af2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6627265067d3e8aaea8c600a7a9caba566a58ecf553e9aa41d412acb35d7d329cfb6ef283dadbf0f60ef79d273d03f46579cec37ecccda065d3e0e6b35e3c77
|
7
|
+
data.tar.gz: 785e705a2c1eaf24f5973b52fe8699acca51b5324f54d0edb83965b7de88f602c03da13fa61e19f386fb41da76cd350bc7bee45bc85f463e468808d84c7981ef
|
data/Gemfile.lock
CHANGED
@@ -1,26 +1,33 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sinatra-pretty-flash (0.0.
|
5
|
-
rack-flash3
|
4
|
+
sinatra-pretty-flash (0.0.3)
|
6
5
|
sinatra
|
6
|
+
sinatra-flash
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
|
12
|
-
|
11
|
+
mustermann (3.0.0)
|
12
|
+
ruby2_keywords (~> 0.0.1)
|
13
|
+
rack (2.2.6.4)
|
14
|
+
rack-protection (3.0.6)
|
13
15
|
rack
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
rack (~>
|
18
|
-
rack-protection (
|
19
|
-
tilt (~>
|
20
|
-
|
16
|
+
ruby2_keywords (0.0.5)
|
17
|
+
sinatra (3.0.6)
|
18
|
+
mustermann (~> 3.0)
|
19
|
+
rack (~> 2.2, >= 2.2.4)
|
20
|
+
rack-protection (= 3.0.6)
|
21
|
+
tilt (~> 2.0)
|
22
|
+
sinatra-flash (0.3.0)
|
23
|
+
sinatra (>= 1.0.0)
|
24
|
+
tilt (2.1.0)
|
21
25
|
|
22
26
|
PLATFORMS
|
23
|
-
|
27
|
+
x86_64-linux
|
24
28
|
|
25
29
|
DEPENDENCIES
|
26
30
|
sinatra-pretty-flash!
|
31
|
+
|
32
|
+
BUNDLED WITH
|
33
|
+
2.4.12
|
data/example/example_app.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'sinatra/base'
|
2
|
-
|
2
|
+
require_relative '../lib/sinatra/pretty-flash'
|
3
3
|
|
4
4
|
class ExampleApp < Sinatra::Base
|
5
5
|
register Sinatra::PrettyFlash
|
6
6
|
|
7
|
+
enable :sessions
|
7
8
|
enable :inline_templates
|
8
9
|
|
9
10
|
get '/' do
|
@@ -23,7 +24,14 @@ __END__
|
|
23
24
|
<%= pretty_flash_css %>
|
24
25
|
</head>
|
25
26
|
<body>
|
26
|
-
|
27
|
+
<% if flash[:notice] %>
|
28
|
+
<p class="flash notice"><%= flash[:notice] %></p>
|
29
|
+
<% end %>
|
30
|
+
|
31
|
+
<% if flash[:error] %>
|
32
|
+
<p class="flash error"><%= flash[:error] %></p>
|
33
|
+
<% end %>
|
34
|
+
|
27
35
|
<%= yield %>
|
28
36
|
</body>
|
29
37
|
<%= pretty_flash_js %>
|
data/lib/sinatra/pretty-flash.rb
CHANGED
@@ -1,59 +1,55 @@
|
|
1
1
|
require 'sinatra/base'
|
2
|
-
require '
|
2
|
+
require 'sinatra/flash'
|
3
3
|
|
4
4
|
module Sinatra
|
5
5
|
module PrettyFlash
|
6
6
|
def self.registered(app)
|
7
|
+
app.register Sinatra::Flash
|
7
8
|
app.helpers FlashHelper
|
8
|
-
app.enable :sessions
|
9
|
-
app.use Rack::Flash, :sweep => true
|
10
9
|
end
|
11
10
|
end
|
12
11
|
|
13
12
|
module FlashHelper
|
14
13
|
def pretty_flash_css
|
15
|
-
output =
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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 %>'
|
14
|
+
output = <<-HTML
|
15
|
+
<style>
|
16
|
+
.flash {
|
17
|
+
position: fixed;
|
18
|
+
padding: 0;
|
19
|
+
margin: 0;
|
20
|
+
bottom: 0;
|
21
|
+
left: 0;
|
22
|
+
width: 100%;
|
23
|
+
height: 60px;
|
24
|
+
line-height: 60px;
|
25
|
+
background: rgba(0, 0, 0, 0.85);
|
26
|
+
color: rgba(255, 255, 255, 1.0);
|
27
|
+
text-align: center;
|
28
|
+
font-size: 24px;
|
29
|
+
}
|
30
|
+
</style>
|
31
|
+
HTML
|
44
32
|
output
|
45
33
|
end
|
46
34
|
|
47
35
|
def pretty_flash_js
|
48
|
-
output =
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
36
|
+
output = <<-HTML
|
37
|
+
<script>
|
38
|
+
window.onload = function() {
|
39
|
+
const flash = document.querySelector(".flash");
|
40
|
+
if (flash) {
|
41
|
+
flash.style.opacity = 0;
|
42
|
+
setTimeout(function() {
|
43
|
+
flash.style.transition = "opacity 1s";
|
44
|
+
flash.style.opacity = 1;
|
45
|
+
}, 500);
|
46
|
+
setTimeout(function() {
|
47
|
+
flash.style.opacity = 0;
|
48
|
+
}, 2000);
|
49
|
+
}
|
50
|
+
};
|
51
|
+
</script>
|
52
|
+
HTML
|
57
53
|
output
|
58
54
|
end
|
59
55
|
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'sinatra-pretty-flash'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.3'
|
4
4
|
|
5
|
-
s.summary =
|
6
|
-
s.description =
|
5
|
+
s.summary = 'Simple decent looking flash messages'
|
6
|
+
s.description = 'A Sinatra extension that adds simple decent looking flash messages'
|
7
7
|
|
8
|
-
s.authors = [
|
9
|
-
s.email =
|
10
|
-
s.homepage =
|
8
|
+
s.authors = ['Kevin Hughes']
|
9
|
+
s.email = 'kevinhughes27@gmail.com'
|
10
|
+
s.homepage = 'https://github.com/kevinhughes27/sinatra-pretty-flash/'
|
11
11
|
s.license = 'MIT'
|
12
12
|
|
13
13
|
s.files = `git ls-files`.split("\n")
|
14
14
|
|
15
15
|
s.add_runtime_dependency 'sinatra'
|
16
|
-
s.add_runtime_dependency '
|
16
|
+
s.add_runtime_dependency 'sinatra-flash'
|
17
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-pretty-flash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Hughes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: sinatra-flash
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: A Sinatra extension that adds simple decent looking flash messages
|
42
|
-
email:
|
42
|
+
email: kevinhughes27@gmail.com
|
43
43
|
executables: []
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
@@ -52,7 +52,7 @@ files:
|
|
52
52
|
- example/example_app.rb
|
53
53
|
- lib/sinatra/pretty-flash.rb
|
54
54
|
- sinatra-pretty-flash.gemspec
|
55
|
-
homepage: https://github.com/
|
55
|
+
homepage: https://github.com/kevinhughes27/sinatra-pretty-flash/
|
56
56
|
licenses:
|
57
57
|
- MIT
|
58
58
|
metadata: {}
|
@@ -71,8 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '0'
|
73
73
|
requirements: []
|
74
|
-
|
75
|
-
rubygems_version: 2.2.2
|
74
|
+
rubygems_version: 3.1.6
|
76
75
|
signing_key:
|
77
76
|
specification_version: 4
|
78
77
|
summary: Simple decent looking flash messages
|