rack-environmental 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/Rakefile +1 -1
- data/lib/rack-environmental.rb +10 -9
- metadata +2 -2
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
data/lib/rack-environmental.rb
CHANGED
@@ -2,8 +2,9 @@ require 'rack-plastic'
|
|
2
2
|
|
3
3
|
module Rack
|
4
4
|
class Environmental < Plastic
|
5
|
-
|
5
|
+
|
6
6
|
def change_nokogiri_doc(doc)
|
7
|
+
return doc if request.xhr?
|
7
8
|
initialize_environment_options
|
8
9
|
add_to_top_of_web_page(doc, create_sticker(doc))
|
9
10
|
add_to_top_of_web_page(doc, create_print_suppression_node(doc))
|
@@ -20,7 +21,7 @@ module Rack
|
|
20
21
|
end
|
21
22
|
|
22
23
|
private
|
23
|
-
|
24
|
+
|
24
25
|
def initialize_environment_options
|
25
26
|
@environment_name = environment(request.url)
|
26
27
|
if @environment_name
|
@@ -29,7 +30,7 @@ module Rack
|
|
29
30
|
@environment_options = {}
|
30
31
|
end
|
31
32
|
end
|
32
|
-
|
33
|
+
|
33
34
|
def environment(url)
|
34
35
|
url = url.split('//').last # remove http://
|
35
36
|
options.each do |environment_name, options|
|
@@ -39,13 +40,13 @@ module Rack
|
|
39
40
|
end
|
40
41
|
return nil
|
41
42
|
end
|
42
|
-
|
43
|
+
|
43
44
|
def add_to_top_of_web_page(doc, node)
|
44
45
|
if node
|
45
46
|
add_first_child(doc.at_css("body"), node)
|
46
47
|
end
|
47
48
|
end
|
48
|
-
|
49
|
+
|
49
50
|
def create_sticker(doc)
|
50
51
|
return nil if @environment_name.nil?
|
51
52
|
return nil if @environment_options[:style] == :none
|
@@ -54,7 +55,7 @@ module Rack
|
|
54
55
|
div['style'] = style(@environment_options)
|
55
56
|
div
|
56
57
|
end
|
57
|
-
|
58
|
+
|
58
59
|
def create_print_suppression_node(doc)
|
59
60
|
return nil if @environment_name.nil?
|
60
61
|
return nil if @environment_options[:style] == :none
|
@@ -62,7 +63,7 @@ module Rack
|
|
62
63
|
style['type'] = 'text/css'
|
63
64
|
style
|
64
65
|
end
|
65
|
-
|
66
|
+
|
66
67
|
def style(options)
|
67
68
|
style = ""
|
68
69
|
style << "font-family: Verdana, Arial, sans-serif;"
|
@@ -94,10 +95,10 @@ module Rack
|
|
94
95
|
style << "margin: 0px;"
|
95
96
|
end
|
96
97
|
end
|
97
|
-
|
98
|
+
|
98
99
|
def default_color
|
99
100
|
"blue"
|
100
101
|
end
|
101
|
-
|
102
|
+
|
102
103
|
end
|
103
104
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-environmental
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
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-10-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack-plastic
|