rack-showme 0.0.3 → 0.0.4
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/Gemfile.lock +1 -1
- data/lib/rack/showme/breakpoints_box.rb +13 -0
- data/lib/rack/showme/message_box.rb +0 -1
- data/lib/rack/showme/options.rb +9 -0
- data/lib/rack/showme/public/showme.breakpoints.css +29 -0
- data/lib/rack/showme/public/showme.css +25 -11
- data/lib/rack/showme/version.rb +1 -1
- data/lib/rack/showme.rb +17 -4
- metadata +4 -2
data/Gemfile.lock
CHANGED
data/lib/rack/showme/options.rb
CHANGED
@@ -3,6 +3,7 @@ module Rack
|
|
3
3
|
module Options
|
4
4
|
@@message = "[Add a Message]"
|
5
5
|
@@colorscheme = "yellow"
|
6
|
+
@@show_breakpoints = nil
|
6
7
|
|
7
8
|
class << self
|
8
9
|
def message
|
@@ -20,6 +21,14 @@ module Rack
|
|
20
21
|
def colorscheme=(value)
|
21
22
|
@@colorscheme= value
|
22
23
|
end
|
24
|
+
|
25
|
+
def show_breakpoints=(value)
|
26
|
+
@show_breakpoints = value
|
27
|
+
end
|
28
|
+
|
29
|
+
def show_breakpoints
|
30
|
+
@show_breakpoints
|
31
|
+
end
|
23
32
|
end
|
24
33
|
end
|
25
34
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
/* Default breakpoints
|
2
|
+
* aka jonathandean's breakpoints
|
3
|
+
* http://jonathandean.com/2013/01/showing-the-current-breakpoint-name-when-testing-responsive-designs-using-only-css/
|
4
|
+
*/
|
5
|
+
|
6
|
+
@media screen and (min-width: 960px){
|
7
|
+
#rack-show-me-breakpoints:before{
|
8
|
+
content: ' at desktop';
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
@media screen and (min-width: 768px) and (max-width:959px){
|
13
|
+
#rack-show-me-breakpoints:before{
|
14
|
+
content: ' at tablet';
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
@media screen and (max-width: 767px){
|
19
|
+
#rack-show-me-breakpoints:before{
|
20
|
+
content: ' at mobile-portrait';
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
@media screen and (min-width: 480px) and (max-width:767px){
|
25
|
+
#rack-show-me-breakpoints:before{
|
26
|
+
content: ' at mobile-landscape';
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
@@ -1,26 +1,40 @@
|
|
1
1
|
/* ribbon */
|
2
2
|
#rack-show-me-message-box {
|
3
|
-
|
4
|
-
|
3
|
+
color: #333333;
|
4
|
+
border-bottom: 1px solid #999;
|
5
|
+
border-right: 1px solid #999;
|
5
6
|
position: fixed;
|
6
7
|
top: 0;
|
7
8
|
left: 0;
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
padding: 4px 7px;
|
10
|
+
cursor: pointer;
|
11
|
+
z-index: 2147483640;
|
12
|
+
}
|
13
|
+
|
14
|
+
#rack-show-me-breakpoints {
|
15
|
+
color: #333333;
|
16
|
+
border-bottom: 1px solid #999;
|
17
|
+
border-right: 1px solid #999;
|
18
|
+
position: fixed;
|
19
|
+
top: 29px;
|
20
|
+
left: 0;
|
21
|
+
padding: 4px 7px;
|
22
|
+
cursor: pointer;
|
23
|
+
z-index: 2147483640;
|
11
24
|
}
|
12
25
|
|
13
26
|
.rack-show-me-colorscheme-yellow {
|
14
|
-
|
15
|
-
|
27
|
+
background-color: #FFF8C6;
|
28
|
+
color: #333333;
|
16
29
|
}
|
17
30
|
|
18
31
|
.rack-show-me-colorscheme-red {
|
19
|
-
|
20
|
-
|
32
|
+
background-color: #FD0006;
|
33
|
+
color: #000000;
|
21
34
|
}
|
22
35
|
|
23
36
|
.rack-show-me-colorscheme-green {
|
24
|
-
|
25
|
-
|
37
|
+
background-color: #42e73A;
|
38
|
+
color: #333333;
|
26
39
|
}
|
40
|
+
|
data/lib/rack/showme/version.rb
CHANGED
data/lib/rack/showme.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "rack/showme/options"
|
2
2
|
require "rack/showme/message_box"
|
3
|
+
require "rack/showme/breakpoints_box"
|
3
4
|
|
4
5
|
module Rack
|
5
6
|
class Showme
|
@@ -33,18 +34,30 @@ module Rack
|
|
33
34
|
@headers && @headers["Content-Type"] && @headers["Content-Type"].include?("text/html")
|
34
35
|
end
|
35
36
|
|
36
|
-
def
|
37
|
-
|
38
|
-
|
37
|
+
def display_breakpoints?
|
38
|
+
@display_breakpoints ||= Options.show_breakpoints
|
39
|
+
end
|
39
40
|
|
41
|
+
def inject_html
|
40
42
|
body = @response.body
|
41
43
|
body.gsub!("</body>", "#{css_line}</body>")
|
42
|
-
body.gsub!("<body>", "<body>#{
|
44
|
+
body.gsub!("<body>", "<body>#{show_boxes}")
|
43
45
|
@response.body = body
|
44
46
|
|
45
47
|
@headers["Content-Length"] = @response.body.bytesize.to_s
|
46
48
|
end
|
47
49
|
|
50
|
+
def css_line
|
51
|
+
files = ["showme.css"]
|
52
|
+
files << "showme.breakpoints.css" if display_breakpoints?
|
53
|
+
%Q{<style type="text/css">#{files.map{|file| read_public_file(file) }.join()}</style>\n}
|
54
|
+
end
|
55
|
+
|
56
|
+
def show_boxes
|
57
|
+
html_string = MessageBox.new(Options).html
|
58
|
+
html_string + BreakpointsBox.new(Options).html if display_breakpoints?
|
59
|
+
end
|
60
|
+
|
48
61
|
def read_public_file(filename)
|
49
62
|
output = ::File.open(::File.join(::File.dirname(__FILE__), "showme", "public", filename), "r:UTF-8") do |f|
|
50
63
|
f.read
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-showme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-24 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Rack middleware that injects a message into HTML responses.
|
15
15
|
email:
|
@@ -33,8 +33,10 @@ files:
|
|
33
33
|
- doc/images/staging_red.png
|
34
34
|
- doc/images/staging_yellow.png
|
35
35
|
- lib/rack/showme.rb
|
36
|
+
- lib/rack/showme/breakpoints_box.rb
|
36
37
|
- lib/rack/showme/message_box.rb
|
37
38
|
- lib/rack/showme/options.rb
|
39
|
+
- lib/rack/showme/public/showme.breakpoints.css
|
38
40
|
- lib/rack/showme/public/showme.css
|
39
41
|
- lib/rack/showme/version.rb
|
40
42
|
- rack-showme.gemspec
|