rack-denyie 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +51 -19
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/lib/html/default.erb +116 -0
- data/lib/rack-denyie.rb +38 -8
- data/rack-denyie.gemspec +59 -0
- data/test/test_rack-denyie.rb +53 -24
- metadata +7 -6
- data/lib/html/default.html +0 -17
data/README.rdoc
CHANGED
@@ -1,35 +1,67 @@
|
|
1
1
|
== IE Filter on Rack
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
=== What?
|
4
|
+
===
|
5
|
+
|
6
|
+
* Rack middleware that denies specified versions of IE.
|
7
|
+
* Use the default template, a custom template or redirect users to another location.
|
8
|
+
|
9
|
+
=== Why?
|
10
|
+
===
|
5
11
|
|
6
|
-
Because
|
7
|
-
Because you can support what you want (if you're lucky).
|
12
|
+
* Because progressive enhancement only goes so far.
|
8
13
|
|
9
14
|
=== How?
|
15
|
+
===
|
16
|
+
|
17
|
+
Install:
|
18
|
+
|
19
|
+
[sudo] gem install rack-denyie
|
20
|
+
|
21
|
+
Use:
|
22
|
+
|
23
|
+
require 'rack-denyie'
|
24
|
+
|
25
|
+
With default options: (Allows IE 7 or higher and displays the default template)
|
10
26
|
|
11
|
-
|
12
|
-
use Rack::NoIE
|
27
|
+
use Rack::DenyIE
|
13
28
|
|
14
|
-
|
15
|
-
|
16
|
-
|
29
|
+
With custom template and modified minimum version:
|
30
|
+
|
31
|
+
use Rack::DenyIE, {
|
32
|
+
:min_version => 8, # Allow IE 8 and higher
|
33
|
+
:template => "/full/path/to/your/template.html" # Custom HTML template
|
17
34
|
}
|
18
35
|
|
19
|
-
|
36
|
+
With redirection set (not well tested):
|
37
|
+
|
38
|
+
use Rack::DenyIE, {
|
39
|
+
:redirect_url => "http://browsehappy.com/"
|
40
|
+
}
|
41
|
+
|
42
|
+
With all options:
|
43
|
+
|
44
|
+
use Rack::DenyIE, {
|
45
|
+
:min_version => 6, # Minimum Version :: Allows IE 6 and higher
|
46
|
+
:template => '/full/path/to/your/template.erb', # Custom template :: ERB or HTML
|
47
|
+
:headline => 'Sorry, old browser alert!', # Replaces "Your version of Internet Explorer is not supported."
|
48
|
+
:site_name => "My Website" # Site Name :: Replaces the default "this site" with your site name.
|
49
|
+
}
|
50
|
+
|
51
|
+
Any key/value you pass in will be available to your ERB template.
|
52
|
+
|
53
|
+
use Rack::DenyIE, {
|
54
|
+
:my_key => "my value"
|
55
|
+
}
|
20
56
|
|
21
|
-
|
22
|
-
2. Developing for IE 6 costs extra time + money.
|
23
|
-
3. Because they're releasing the alpha version of IE 9 next year.
|
57
|
+
<%= @my_key %> #=> "my value"
|
24
58
|
|
25
|
-
===
|
59
|
+
=== Todo
|
26
60
|
===
|
27
61
|
|
28
|
-
*
|
29
|
-
*
|
30
|
-
*
|
31
|
-
* IE 6 = 2001 <= Should be unsupported
|
32
|
-
* IE 5 = 1999 <= Should be unsupported
|
62
|
+
* Allow HAML templates
|
63
|
+
* Write tests for url redirection
|
64
|
+
* Tests need improvement
|
33
65
|
|
34
66
|
== Copyright
|
35
67
|
|
data/Rakefile
CHANGED
@@ -5,10 +5,10 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "rack-denyie"
|
8
|
-
gem.summary = "
|
9
|
-
gem.description = "
|
8
|
+
gem.summary = "Rack middleware that denies specified versions of IE."
|
9
|
+
gem.description = "Rack middleware that denies specified versions of IE."
|
10
10
|
gem.email = "brad@digitalstarstudios.com"
|
11
|
-
gem.homepage = "http://
|
11
|
+
gem.homepage = "http://digitalstarstudios.com/projects"
|
12
12
|
gem.authors = ["Brad Whitcomb"]
|
13
13
|
gem.add_dependency "rack", "1.0.0"
|
14
14
|
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
1.0.0
|
@@ -0,0 +1,116 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
5
|
+
<title>Please Upgrade Your Browser</title>
|
6
|
+
<style type="text/css">
|
7
|
+
|
8
|
+
/* Reset */
|
9
|
+
|
10
|
+
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, textarea, p, blockquote, th, td {
|
11
|
+
margin: 0;
|
12
|
+
padding: 0;
|
13
|
+
}
|
14
|
+
table {
|
15
|
+
border-collapse: collapse;
|
16
|
+
border-spacing: 0;
|
17
|
+
font-size: inherit;
|
18
|
+
}
|
19
|
+
fieldset, img {
|
20
|
+
border: 0;
|
21
|
+
}
|
22
|
+
address, caption, cite, code, dfn, em, strong, th, var {
|
23
|
+
font-style: normal;
|
24
|
+
font-weight: normal;
|
25
|
+
}
|
26
|
+
ol, ul {
|
27
|
+
list-style: none;
|
28
|
+
}
|
29
|
+
caption, th {
|
30
|
+
text-align: left;
|
31
|
+
}
|
32
|
+
abbr, acronym {
|
33
|
+
border: 0;
|
34
|
+
}
|
35
|
+
:focus {
|
36
|
+
outline: 0;
|
37
|
+
}
|
38
|
+
* textarea {
|
39
|
+
overflow: auto;
|
40
|
+
}
|
41
|
+
|
42
|
+
/* Default */
|
43
|
+
|
44
|
+
body {
|
45
|
+
font-family: Arial, Helvetica, Tahoma, sans-serif;
|
46
|
+
background-image: url("http://digitalstarstudios.com/images/denyie/default_bg.jpg");
|
47
|
+
background-repeat: repeat;
|
48
|
+
}
|
49
|
+
|
50
|
+
div#container {
|
51
|
+
overflow: auto;
|
52
|
+
margin: 0 auto;
|
53
|
+
margin-top: 100px;
|
54
|
+
padding: 20px 20px 15px 20px;
|
55
|
+
width: 500px;
|
56
|
+
text-align: center;
|
57
|
+
background-color: #FFFFFF;
|
58
|
+
border: 2px solid #2B445F;
|
59
|
+
}
|
60
|
+
div#container * { text-align: left }
|
61
|
+
|
62
|
+
p, li { font-size: 18px }
|
63
|
+
h1, p { margin-bottom: 10px }
|
64
|
+
h1 { font-size: 20px }
|
65
|
+
h2 { font-size: 16px; margin-bottom: 7px }
|
66
|
+
|
67
|
+
p { line-height: 26px }
|
68
|
+
span { font-weight: bold }
|
69
|
+
|
70
|
+
ul { margin-top: 20px }
|
71
|
+
ul li { float: left; width: 250px; margin-bottom: 20px }
|
72
|
+
ul li img { float: left; margin-right: 10px; border: none }
|
73
|
+
|
74
|
+
a, a:visited, a:active {
|
75
|
+
padding: 3px 8px;
|
76
|
+
font-size: 16px;
|
77
|
+
text-decoration: none;
|
78
|
+
color: #FFFFFF;
|
79
|
+
background-color: #425265;
|
80
|
+
}
|
81
|
+
a:hover { background-color: #2B445F }
|
82
|
+
|
83
|
+
|
84
|
+
</style>
|
85
|
+
</head>
|
86
|
+
<body>
|
87
|
+
<div id="container">
|
88
|
+
<h1><%= @headline %></h1>
|
89
|
+
<p>You've been redirected to this page because <%= @site_name %> only supports <span>Microsoft Internet Explorer <%= @min_version %></span> or higher.</p>
|
90
|
+
<p>Please upgrade to the latest version of Internet Explorer or try using another browser when visiting this site.</p>
|
91
|
+
<p>We recommend any of the fine browsers below:</p>
|
92
|
+
<ul>
|
93
|
+
<li>
|
94
|
+
<img src="http://digitalstarstudios.com/images/denyie/ie.jpg" title="Microsoft Internet Explorer" width="50" height="50" alt="Internet Explorer Logo" />
|
95
|
+
<h2>Internet Explorer 8</h2>
|
96
|
+
<a href="http://www.microsoft.com/windows/Internet-explorer/default.aspx" title="Download latest Internet Explorer">Download</a>
|
97
|
+
</li>
|
98
|
+
<li>
|
99
|
+
<img src="http://digitalstarstudios.com/images/denyie/firefox.jpg" title="Mozilla Firefox" width="50" height="50" alt="Firefox Logo" />
|
100
|
+
<h2>Mozilla Firefox 3+</h2>
|
101
|
+
<a href="http://firefox.com" title="Download Firefox">Download</a>
|
102
|
+
</li>
|
103
|
+
<li>
|
104
|
+
<img src="http://digitalstarstudios.com/images/denyie/safari.jpg" title="Apple Safari" width="50" height="49" alt="Safari Logo" />
|
105
|
+
<h2>Apple Safari 4+</h2>
|
106
|
+
<a href="http://apple.com/safari" title="Download Safari">Download</a>
|
107
|
+
</li>
|
108
|
+
<li>
|
109
|
+
<img src="http://digitalstarstudios.com/images/denyie/opera.jpg" title="Opera" width="50" height="50" alt="Opera Logo" />
|
110
|
+
<h2>Opera 10+</h2>
|
111
|
+
<a href="http://opera.com" title="Download Opera">Download</a>
|
112
|
+
</li>
|
113
|
+
</ul>
|
114
|
+
</div>
|
115
|
+
</body>
|
116
|
+
</html>
|
data/lib/rack-denyie.rb
CHANGED
@@ -1,24 +1,32 @@
|
|
1
1
|
require 'rack'
|
2
|
+
require 'erb'
|
2
3
|
|
3
4
|
module Rack
|
4
5
|
class DenyIE
|
5
6
|
|
6
|
-
DEFAULT_TEMPLATE_PATH = ::File.join(::File.dirname(__FILE__), 'html', 'default.
|
7
|
+
DEFAULT_TEMPLATE_PATH = ::File.join(::File.dirname(__FILE__), 'html', 'default.erb')
|
8
|
+
URL_REGEX = %r{\b(([\w-]+://?|[\w\d]+[.])[^\s()<>]+(?:(?:\([\w\d)]+\)[^\s()<>]*)+|([^[:punct:]\s]|/)))} # http://alanstorm.com/url_regex_explained
|
7
9
|
|
8
10
|
def initialize(app, options = {})
|
9
|
-
@app = app
|
10
|
-
@options = {
|
11
|
+
@app = app # Passed App
|
12
|
+
@options = {
|
13
|
+
:min_version => 7,
|
14
|
+
:headline => "Your version of Internet Explorer is not supported.",
|
15
|
+
:site_name => "this site",
|
16
|
+
:template => DEFAULT_TEMPLATE_PATH,
|
17
|
+
:redirect_url => nil }.merge options # Middleware Options
|
11
18
|
end
|
12
19
|
|
13
20
|
def call(env)
|
14
21
|
status, @headers, content = @app.call(env)
|
15
|
-
|
22
|
+
is_unsupported?(env) && is_content_html? ? act_on_ie : @app.call(env)
|
16
23
|
end
|
17
24
|
|
18
25
|
private
|
19
26
|
|
20
|
-
def
|
21
|
-
|
27
|
+
def is_unsupported?(env)
|
28
|
+
minimum_version = (@options[:min_version].to_i - 1)
|
29
|
+
env["HTTP_USER_AGENT"].match(/MSIE [0-#{minimum_version}]/) # \.[0-9][0-9]?
|
22
30
|
end
|
23
31
|
|
24
32
|
def is_content_html?
|
@@ -30,7 +38,7 @@ module Rack
|
|
30
38
|
end
|
31
39
|
|
32
40
|
def should_redirect?
|
33
|
-
!@options[:redirect_url].nil? && @options[:redirect_url].match(
|
41
|
+
!@options[:redirect_url].nil? && @options[:redirect_url].match(URL_REGEX)
|
34
42
|
end
|
35
43
|
|
36
44
|
def redirect_browser
|
@@ -38,10 +46,32 @@ module Rack
|
|
38
46
|
end
|
39
47
|
|
40
48
|
def display_template
|
41
|
-
response = ::File.read(@options[:
|
49
|
+
response = (::File.extname(@options[:template]) == ".erb") ? process_erb : ::File.read(@options[:template]) # TODO: Add check to see if template points to an actual file
|
42
50
|
@headers['Content-Length'] = Rack::Utils.bytesize(response.to_s).to_s
|
43
51
|
[200, @headers, response]
|
44
52
|
end
|
45
53
|
|
54
|
+
def process_erb
|
55
|
+
raw = ::File.read(@options[:template])
|
56
|
+
erb = ERB.new(raw, nil, "%<>")
|
57
|
+
binding = TemplateVars.new(@options).get_binding # Variables passed to ERB template
|
58
|
+
template = erb.result(binding)
|
59
|
+
template.gsub(/\n$/,'')
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
class TemplateVars
|
65
|
+
|
66
|
+
def initialize(vars = {})
|
67
|
+
vars.each_pair do |key, value|
|
68
|
+
self.instance_variable_set("@#{key}", value)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def get_binding
|
73
|
+
binding
|
74
|
+
end
|
75
|
+
|
46
76
|
end
|
47
77
|
end
|
data/rack-denyie.gemspec
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{rack-denyie}
|
8
|
+
s.version = "1.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Brad Whitcomb"]
|
12
|
+
s.date = %q{2009-11-30}
|
13
|
+
s.description = %q{Rack middleware that denies specified versions of IE.}
|
14
|
+
s.email = %q{brad@digitalstarstudios.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/html/default.erb",
|
27
|
+
"lib/rack-denyie.rb",
|
28
|
+
"rack-denyie.gemspec",
|
29
|
+
"test/html/custom_template.html",
|
30
|
+
"test/test_helper.rb",
|
31
|
+
"test/test_rack-denyie.rb"
|
32
|
+
]
|
33
|
+
s.homepage = %q{http://digitalstarstudios.com/projects}
|
34
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
s.rubygems_version = %q{1.3.5}
|
37
|
+
s.summary = %q{Rack middleware that denies specified versions of IE.}
|
38
|
+
s.test_files = [
|
39
|
+
"test/test_helper.rb",
|
40
|
+
"test/test_rack-denyie.rb"
|
41
|
+
]
|
42
|
+
|
43
|
+
if s.respond_to? :specification_version then
|
44
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
45
|
+
s.specification_version = 3
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_runtime_dependency(%q<rack>, ["= 1.0.0"])
|
49
|
+
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<rack>, ["= 1.0.0"])
|
52
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
53
|
+
end
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<rack>, ["= 1.0.0"])
|
56
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
data/test/test_rack-denyie.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
|
+
require 'erb'
|
2
3
|
|
3
4
|
class TestRackDenyIE < Test::Unit::TestCase
|
4
5
|
|
5
6
|
BODY = "OK"
|
6
|
-
|
7
7
|
CUSTOM_TEMPLATE_PATH = File.expand_path(File.join(File.dirname(__FILE__), 'html', 'custom_template.html'))
|
8
8
|
|
9
9
|
def get_response(user_agent, body, content_type = 'text/html', options = {})
|
@@ -13,6 +13,21 @@ class TestRackDenyIE < Test::Unit::TestCase
|
|
13
13
|
end
|
14
14
|
Rack::MockRequest.new(app).get('/')
|
15
15
|
end
|
16
|
+
|
17
|
+
def read_erb(ver)
|
18
|
+
@defaults = {
|
19
|
+
:min_version => ver || 7,
|
20
|
+
:headline => "Your version of Internet Explorer is not supported.",
|
21
|
+
:site_name => "this site",
|
22
|
+
:template => Rack::DenyIE::DEFAULT_TEMPLATE_PATH,
|
23
|
+
:redirect_url => nil
|
24
|
+
}
|
25
|
+
raw = File.read(@defaults[:template])
|
26
|
+
erb = ERB.new(raw, nil, "%<>")
|
27
|
+
binding = Rack::TemplateVars.new(@defaults).get_binding
|
28
|
+
template = erb.result(binding)
|
29
|
+
template.gsub(/\n$/,'')
|
30
|
+
end
|
16
31
|
|
17
32
|
context "When Rack::DenyIE" do
|
18
33
|
|
@@ -34,45 +49,35 @@ class TestRackDenyIE < Test::Unit::TestCase
|
|
34
49
|
end
|
35
50
|
end
|
36
51
|
|
37
|
-
context "encounters supported IE 7" do
|
38
|
-
setup do
|
39
|
-
user_agent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.5.21022)"
|
40
|
-
@response = get_response(user_agent, BODY, "text/html", { :version => 6 })
|
41
|
-
end
|
42
|
-
should "return original response" do
|
43
|
-
assert_equal BODY, @response.body
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
52
|
context "encounters supported IE 8" do
|
48
53
|
setup do
|
49
54
|
user_agent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729)"
|
50
|
-
@response = get_response(user_agent, BODY, "text/html", { :
|
55
|
+
@response = get_response(user_agent, BODY, "text/html", { :min_version => 8 })
|
51
56
|
end
|
52
57
|
should "return original response" do
|
53
58
|
assert_equal BODY, @response.body
|
54
59
|
end
|
55
60
|
end
|
56
61
|
|
57
|
-
|
62
|
+
# IE 6 Tests
|
63
|
+
|
64
|
+
context "encounters supported IE 6" do
|
58
65
|
setup do
|
59
66
|
user_agent = "Mozilla/4.0 (Compatible; Windows NT 5.1; MSIE 6.0) (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
|
60
67
|
@response = get_response(user_agent, BODY, "text/html", { :min_version => 6 })
|
61
68
|
end
|
62
|
-
should "return
|
63
|
-
|
64
|
-
|
65
|
-
assert_equal default_template, @response.body
|
69
|
+
should "return original response" do
|
70
|
+
assert_equal BODY, @response.body
|
66
71
|
end
|
67
72
|
end
|
68
73
|
|
69
|
-
context "encounters unsupported IE
|
74
|
+
context "encounters unsupported IE 6" do
|
70
75
|
setup do
|
71
|
-
user_agent = "Mozilla/4.0 (
|
76
|
+
user_agent = "Mozilla/4.0 (Compatible; Windows NT 5.1; MSIE 6.0) (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
|
72
77
|
@response = get_response(user_agent, BODY, "text/html", { :min_version => 7 })
|
73
78
|
end
|
74
79
|
should "return default IE template" do
|
75
|
-
default_template =
|
80
|
+
default_template = read_erb(7)
|
76
81
|
|
77
82
|
assert_equal default_template, @response.body
|
78
83
|
end
|
@@ -81,10 +86,10 @@ class TestRackDenyIE < Test::Unit::TestCase
|
|
81
86
|
context "encounters unsupported IE 6 and custom template" do
|
82
87
|
setup do
|
83
88
|
user_agent = "Mozilla/4.0 (Compatible; Windows NT 5.1; MSIE 6.0) (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
|
84
|
-
@response = get_response(user_agent, BODY, "text/html", { :min_version =>
|
89
|
+
@response = get_response(user_agent, BODY, "text/html", { :min_version => 7, :template => CUSTOM_TEMPLATE_PATH })
|
85
90
|
end
|
86
91
|
should "return custom IE template" do
|
87
|
-
default_template =
|
92
|
+
default_template = read_erb(7)
|
88
93
|
custom_template = File.read(CUSTOM_TEMPLATE_PATH)
|
89
94
|
|
90
95
|
assert_not_equal default_template, @response.body
|
@@ -92,13 +97,37 @@ class TestRackDenyIE < Test::Unit::TestCase
|
|
92
97
|
end
|
93
98
|
end
|
94
99
|
|
100
|
+
# IE 7 Tests
|
101
|
+
|
102
|
+
context "encounters supported IE 7" do
|
103
|
+
setup do
|
104
|
+
user_agent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.5.21022)"
|
105
|
+
@response = get_response(user_agent, BODY, "text/html", { :min_version => 7 })
|
106
|
+
end
|
107
|
+
should "return original response" do
|
108
|
+
assert_equal BODY, @response.body
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context "encounters unsupported IE 7" do
|
113
|
+
setup do
|
114
|
+
user_agent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.5.21022)"
|
115
|
+
@response = get_response(user_agent, BODY, "text/html", { :min_version => 8 })
|
116
|
+
end
|
117
|
+
should "return default IE template" do
|
118
|
+
default_template = read_erb(8)
|
119
|
+
|
120
|
+
assert_equal default_template, @response.body
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
95
124
|
context "encounters unsupported IE 7 and custom template" do
|
96
125
|
setup do
|
97
126
|
user_agent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.5.21022)"
|
98
|
-
@response = get_response(user_agent, BODY, "text/html", { :min_version =>
|
127
|
+
@response = get_response(user_agent, BODY, "text/html", { :min_version => 8, :template => CUSTOM_TEMPLATE_PATH })
|
99
128
|
end
|
100
129
|
should "return custom IE template" do
|
101
|
-
default_template =
|
130
|
+
default_template = read_erb(8)
|
102
131
|
custom_template = File.read(CUSTOM_TEMPLATE_PATH)
|
103
132
|
|
104
133
|
assert_not_equal default_template, @response.body
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-denyie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Whitcomb
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-30 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: "0"
|
34
34
|
version:
|
35
|
-
description:
|
35
|
+
description: Rack middleware that denies specified versions of IE.
|
36
36
|
email: brad@digitalstarstudios.com
|
37
37
|
executables: []
|
38
38
|
|
@@ -48,13 +48,14 @@ files:
|
|
48
48
|
- README.rdoc
|
49
49
|
- Rakefile
|
50
50
|
- VERSION
|
51
|
-
- lib/html/default.
|
51
|
+
- lib/html/default.erb
|
52
52
|
- lib/rack-denyie.rb
|
53
|
+
- rack-denyie.gemspec
|
53
54
|
- test/html/custom_template.html
|
54
55
|
- test/test_helper.rb
|
55
56
|
- test/test_rack-denyie.rb
|
56
57
|
has_rdoc: true
|
57
|
-
homepage: http://
|
58
|
+
homepage: http://digitalstarstudios.com/projects
|
58
59
|
licenses: []
|
59
60
|
|
60
61
|
post_install_message:
|
@@ -80,7 +81,7 @@ rubyforge_project:
|
|
80
81
|
rubygems_version: 1.3.5
|
81
82
|
signing_key:
|
82
83
|
specification_version: 3
|
83
|
-
summary:
|
84
|
+
summary: Rack middleware that denies specified versions of IE.
|
84
85
|
test_files:
|
85
86
|
- test/test_helper.rb
|
86
87
|
- test/test_rack-denyie.rb
|
data/lib/html/default.html
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
-
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
5
|
-
<title>Please Upgrade</title>
|
6
|
-
<style type="text/css">
|
7
|
-
h1 {
|
8
|
-
color: red;
|
9
|
-
font-size: 22px;
|
10
|
-
}
|
11
|
-
</style>
|
12
|
-
</head>
|
13
|
-
<body>
|
14
|
-
<h1>Your browser is unsupported.</h1>
|
15
|
-
<p>Please upgrade to the latest version of <a href="http://www.microsoft.com/windows/Internet-explorer/default.aspx" title="Download Internet Explorer">Internet Explorer</a></p>
|
16
|
-
</body>
|
17
|
-
</html>
|