sinatra-ie6nomore 0.1.1 → 0.1.2
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/README.rdoc +149 -55
- data/Rakefile +12 -10
- data/VERSION +1 -1
- data/files/ie6nomore-chrome.jpg +0 -0
- data/files/ie6nomore-cornerx.jpg +0 -0
- data/files/ie6nomore-firefox.jpg +0 -0
- data/files/ie6nomore-ie8.jpg +0 -0
- data/files/ie6nomore-safari.jpg +0 -0
- data/files/ie6nomore-warning.jpg +0 -0
- data/lib/sinatra/ie6nomore/rake.rb +16 -0
- data/lib/sinatra/ie6nomore.rb +210 -96
- data/sinatra-ie6nomore.gemspec +15 -6
- data/spec/sinatra/ie6nomore_spec.rb +47 -37
- data/spec/spec_helper.rb +40 -33
- metadata +45 -19
data/README.rdoc
CHANGED
@@ -1,77 +1,119 @@
|
|
1
|
-
= Sinatra::IE6NoMore
|
1
|
+
= Sinatra::IE6NoMore
|
2
2
|
|
3
3
|
A simple extension in support of the {"IE6 No More"}[www.ie6nomore.com] campaign to rid the world of
|
4
4
|
the nasty bug ridden monstrosity called IE6.
|
5
5
|
|
6
6
|
Check the {"IE6 No More"}[www.ie6nomore.com] site for more information.
|
7
7
|
|
8
|
-
==
|
8
|
+
== Installation
|
9
|
+
|
10
|
+
# Add RubyGems.org (former Gemcutter) to your RubyGems sources
|
11
|
+
$ gem sources -a http://rubygems.org
|
9
12
|
|
13
|
+
$ (sudo)? gem install sinatra-ie6nomore
|
10
14
|
|
11
|
-
|
15
|
+
== Dependencies
|
12
16
|
|
13
|
-
|
17
|
+
This Gem depends upon the following:
|
14
18
|
|
15
|
-
|
19
|
+
=== Runtime:
|
16
20
|
|
17
|
-
|
21
|
+
* sinatra ( >= 1.0.a )
|
18
22
|
|
19
|
-
Require the Sinatra::IE6NoMore gem
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
require 'sinatra/ie6nomore'
|
24
|
+
=== Development & Tests:
|
24
25
|
|
25
|
-
|
26
|
+
* sinatra-tests (>= 0.1.6)
|
27
|
+
* rspec (>= 1.3.0 )
|
28
|
+
* rack-test (>= 0.5.3)
|
29
|
+
* rspec_hpricot_matchers (>= 0.1.0)
|
26
30
|
|
27
|
-
Include in your app.
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
+
== Getting Started
|
33
|
+
|
34
|
+
To use this extension in your App just follow these two simple steps:
|
35
|
+
|
36
|
+
=== Step 1
|
37
|
+
|
38
|
+
require 'sinatra/ie6nomore'
|
39
|
+
|
40
|
+
class YourApp < Sinatra::Base
|
41
|
+
helpers Sinatra::IE6NoMore::Helpers
|
42
|
+
# or
|
43
|
+
register(Sinatra::IE6NoMore)
|
32
44
|
|
33
45
|
<snip...>
|
34
|
-
|
35
46
|
end
|
36
47
|
|
48
|
+
=== Step 2
|
37
49
|
|
38
|
-
|
39
|
-
|
40
|
-
Add this to your <tt>/views/layout.erb</tt> file.
|
50
|
+
Add this to your <tt>../views/layout.erb</tt> file.
|
41
51
|
|
42
52
|
<html>
|
43
53
|
<body>
|
44
54
|
|
45
55
|
<%= ie6_no_more %>
|
46
56
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
And in your HTML you'll see
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
<
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
<snip...>
|
58
|
+
|
59
|
+
|
60
|
+
And in your HTML you'll see some output like this:
|
61
|
+
|
62
|
+
<!--[if lt IE 7]>
|
63
|
+
<div style="border: 1px solid #F7941D; background: #FEEFDA; text-align: center; clear: both; height: 75px; position: relative;">
|
64
|
+
<div style="position: absolute; right: 3px; top: 3px; font-family: courier new; font-weight: bold;">
|
65
|
+
<a href="#" onclick="javascript:this.parentNode.parentNode.style.display="none"; return false;">
|
66
|
+
<img src="/images/ie6nomore/ie6nomore-cornerx.jpg" style="border: none;" alt="Close this notice"/>
|
67
|
+
</a>
|
68
|
+
</div>
|
69
|
+
<div style="width: 640px; margin: 0 auto; text-align: left; padding: 0; overflow: hidden; color: black;">
|
70
|
+
<div style="width: 75px; float: left;">
|
71
|
+
<img src="/images/ie6nomore/ie6nomore-warning.jpg" alt="Warning!"/>
|
72
|
+
</div>
|
73
|
+
<div style="width: 275px; float: left; font-family: Arial, sans-serif;">
|
74
|
+
<div style="font-size: 14px; font-weight: bold; margin-top: 12px;">
|
75
|
+
You are using an outdated browser
|
76
|
+
</div>
|
77
|
+
<div style="font-size: 12px; margin-top: 6px; line-height: 12px;">
|
78
|
+
For a better experience using this site, please upgrade to a modern web browser.</div>
|
79
|
+
</div>
|
80
|
+
<div style="width: 75px; float: left;">
|
81
|
+
<a href="http://getfirefox.com/" target="_blank">
|
82
|
+
<img src="/images/ie6nomore/ie6nomore-firefox.jpg" style="border: none;" alt="Get Firefox 3.5"/>
|
83
|
+
</a>
|
84
|
+
</div>
|
85
|
+
<div style="width: 75px; float: left;">
|
86
|
+
<a href="http://www.browserforthebetter.com/download.html" target="_blank">
|
87
|
+
<img src="/images/ie6nomore/ie6nomore-ie8.jpg" style="border: none;" alt="Get Internet Explorer 8"/>
|
88
|
+
</a>
|
89
|
+
</div>
|
90
|
+
<div style="width: 73px; float: left;">
|
91
|
+
<a href="http://www.apple.com/safari/download/" target="_blank">
|
92
|
+
<img src="/images/ie6nomore/ie6nomore-safari.jpg" style="border: none;" alt="Get Safari 4"/>
|
93
|
+
</a>
|
94
|
+
</div>
|
95
|
+
<div style="float: left;">
|
96
|
+
<a href="http://www.google.com/chrome" target="_blank">
|
97
|
+
<img src="/images/ie6nomore/ie6nomore-chrome.jpg" style="border: none;" alt="Get Google Chrome"/>
|
98
|
+
</a>
|
99
|
+
</div>
|
60
100
|
</div>
|
61
|
-
<div style="width: 75px; float: left;"><a href="http://getfirefox.com/" target="_blank"><img src="http://www.ie6nomore.com/files/theme/ie6nomore-firefox.jpg" style="border: none;" alt="Get Firefox 3.5"/></a></div>
|
62
|
-
<div style="width: 75px; float: left;"><a href="http://www.browserforthebetter.com/download.html" target="_blank"><img src="http://www.ie6nomore.com/files/theme/ie6nomore-ie8.jpg" style="border: none;" alt="Get Internet Explorer 8"/></a></div>
|
63
|
-
<div style="width: 73px; float: left;"><a href="http://www.apple.com/safari/download/" target="_blank"><img src="http://www.ie6nomore.com/files/theme/ie6nomore-safari.jpg" style="border: none;" alt="Get Safari 4"/></a></div>
|
64
|
-
<div style="float: left;"><a href="http://www.google.com/chrome" target="_blank"><img src="http://www.ie6nomore.com/files/theme/ie6nomore-chrome.jpg" style="border: none;" alt="Get Google Chrome"/></a></div>
|
65
|
-
</div>
|
66
101
|
</div>
|
67
|
-
|
102
|
+
</div>
|
103
|
+
<![endif]-->
|
68
104
|
|
69
105
|
|
70
|
-
|
106
|
+
That's what it does in a nutshell.
|
71
107
|
|
72
|
-
|
108
|
+
=== Customizing options
|
73
109
|
|
74
|
-
|
110
|
+
You can easily customize the output through the following parameters passed to the method call:
|
111
|
+
|
112
|
+
|
113
|
+
* <tt>:locale</tt> => Sets the locale for the output. (Default = :en => English)
|
114
|
+
|
115
|
+
* <tt>:img_host</tt> => The URL to the ie6nomore images (Default = /images/ie6nomore/).
|
116
|
+
<b>NB!</b> with trailing slash
|
75
117
|
|
76
118
|
* <tt>:border</tt> => The div border color. (Default = "1px solid #F7941D")
|
77
119
|
|
@@ -79,11 +121,25 @@ And in your HTML you'll see an output like this:
|
|
79
121
|
|
80
122
|
* <tt>:text_color</tt> => The div text color. (Default = "black")
|
81
123
|
|
82
|
-
* <tt>:debug</tt> => Whether to encapsulate the code with IE Comments or not.
|
124
|
+
* <tt>:debug</tt> => Whether to encapsulate the code with IE Comments or not.
|
125
|
+
So you can see how it looks like when developing on NON-IE 6 browsers. (Default = false)
|
126
|
+
|
127
|
+
<b>Examples:</b>
|
128
|
+
|
129
|
+
# to change the image host
|
130
|
+
<%= ie6_no_more(:img_host => "http://assets.example.com/images/ie6nomore/" ) %>
|
131
|
+
|
132
|
+
# to change the background colour
|
133
|
+
<%= ie6_no_more(:background => "#369" ) %>
|
134
|
+
|
135
|
+
# to check how the site looks like with the IE6NoMore banner displayed during development
|
136
|
+
<%= ie6_no_more(:debug => true) %>
|
137
|
+
|
138
|
+
|
83
139
|
|
84
140
|
== Localizations
|
85
141
|
|
86
|
-
|
142
|
+
You can also localize the output text with these currently available localizations:
|
87
143
|
|
88
144
|
* English (en)
|
89
145
|
* Spanish (es)
|
@@ -93,27 +149,65 @@ Currently supported localizations are:
|
|
93
149
|
* Japanese (jp)
|
94
150
|
* Swedish (se)
|
95
151
|
|
152
|
+
Awaiting further translations from IE6NoMore website or through your fork.
|
96
153
|
|
97
|
-
== Development Use
|
98
154
|
|
99
|
-
|
100
|
-
banner.
|
155
|
+
== GOTCHAs
|
101
156
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
157
|
+
By default the image host for the images displayed in the banner is your server
|
158
|
+
[ <tt>/images/ie6nomore/</tt> ]. However upon initial inclusion of the solution,
|
159
|
+
you do not have the required images on your server.
|
160
|
+
|
161
|
+
You can remedie this by adding the following to your app's Rakefile.
|
162
|
+
|
163
|
+
# in ../Rakefile
|
164
|
+
|
165
|
+
require 'sinatra/ie6nomore/rake
|
166
|
+
|
167
|
+
|
168
|
+
Then you can fire up your CLI and use this rake task:
|
169
|
+
|
170
|
+
rake ie6nomore:copy_images
|
171
|
+
|
172
|
+
You should now have all the images locally stored on your server.
|
173
|
+
|
174
|
+
<b>NB!</b> assumes that the <tt>'../public/'</tt> directory is at the root of your app,
|
175
|
+
and that it contains an <tt>'images/'</tt> directory.
|
176
|
+
|
177
|
+
|
178
|
+
== RTFM
|
179
|
+
|
180
|
+
If the above is not clear enough, please check the Specs for a better understanding.
|
181
|
+
|
182
|
+
|
183
|
+
== Errors / Bugs
|
184
|
+
|
185
|
+
If something is not behaving intuitively, it is a bug, and should be reported.
|
186
|
+
Report it here: http://github.com/kematzy/sinatra-outputbuffer/issues
|
109
187
|
|
110
188
|
|
111
189
|
== TODOs
|
112
190
|
|
113
|
-
* Rake task to harvest all IE6NoMore images and store them on local server.
|
114
191
|
* Further localizations
|
115
192
|
|
193
|
+
* Keep it up to date with any changes in Sinatra or IE6 No More site.
|
194
|
+
|
195
|
+
* Any other improvements you can think of.
|
196
|
+
|
197
|
+
|
198
|
+
== Note on Patches/Pull Requests
|
199
|
+
|
200
|
+
* Fork the project.
|
201
|
+
* Make your feature addition or bug fix.
|
202
|
+
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
203
|
+
* Commit, do not mess with rakefile, version, or history.
|
204
|
+
* (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
205
|
+
* Send me a pull request. Bonus points for topic branches.
|
116
206
|
|
117
207
|
== Copyright
|
118
208
|
|
119
|
-
Copyright (c)
|
209
|
+
Copyright (c) 2010 Kematzy and the guys behind {"IE6 No More"}[www.ie6nomore.com] site.
|
210
|
+
|
211
|
+
Released under the MIT License.
|
212
|
+
|
213
|
+
See LICENSE for further details.
|
data/Rakefile
CHANGED
@@ -5,7 +5,8 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "sinatra-ie6nomore"
|
8
|
-
gem.summary = %Q{'IE6 No More'
|
8
|
+
gem.summary = %Q{A Sinatra Extension that shows an 'IE6 No More' div on the page for IE6 browsers, making the eradication of IE6 easier.}
|
9
|
+
gem.description = %Q{A Sinatra Extension that shows an 'IE6 No More' div on the page for IE6 browsers, making the eradication of IE6 easier.}
|
9
10
|
gem.email = "kematzy@gmail.com"
|
10
11
|
gem.homepage = "http://github.com/kematzy/sinatra-ie6nomore"
|
11
12
|
gem.authors = ["kematzy"]
|
@@ -15,30 +16,32 @@ begin
|
|
15
16
|
|
16
17
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
18
|
end
|
18
|
-
|
19
|
+
Jeweler::GemcutterTasks.new
|
19
20
|
rescue LoadError
|
20
|
-
puts "Jeweler (or a dependency) not available. Install it with:
|
21
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
22
|
end
|
22
23
|
|
23
24
|
require 'spec/rake/spectask'
|
24
25
|
Spec::Rake::SpecTask.new(:spec) do |spec|
|
25
26
|
spec.libs << 'lib' << 'spec'
|
27
|
+
spec.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
|
26
28
|
spec.spec_files = FileList['spec/**/*_spec.rb']
|
27
29
|
end
|
28
30
|
|
29
31
|
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
30
32
|
spec.libs << 'lib' << 'spec'
|
33
|
+
spec.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
|
31
34
|
spec.pattern = 'spec/**/*_spec.rb'
|
32
35
|
spec.rcov = true
|
33
36
|
end
|
34
37
|
|
35
38
|
|
36
39
|
namespace :spec do
|
37
|
-
|
38
|
-
desc "Run all specifications
|
39
|
-
Spec::Rake::SpecTask.new(:
|
40
|
+
|
41
|
+
desc "Run all specifications quietly"
|
42
|
+
Spec::Rake::SpecTask.new(:quiet) do |t|
|
40
43
|
t.libs << "lib"
|
41
|
-
t.spec_opts = ["--color", "--
|
44
|
+
t.spec_opts = ["--color", "--require", "spec/spec_helper.rb"]
|
42
45
|
end
|
43
46
|
|
44
47
|
desc "Run specific spec verbosely (SPEC=/path/2/file)"
|
@@ -50,6 +53,8 @@ namespace :spec do
|
|
50
53
|
|
51
54
|
end
|
52
55
|
|
56
|
+
task :spec => :check_dependencies
|
57
|
+
|
53
58
|
task :default => :spec
|
54
59
|
|
55
60
|
require 'rake/rdoctask'
|
@@ -85,6 +90,3 @@ namespace :docs do
|
|
85
90
|
end
|
86
91
|
|
87
92
|
end
|
88
|
-
|
89
|
-
|
90
|
-
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'sinatra/ie6nomore'
|
3
|
+
|
4
|
+
namespace :ie6nomore do
|
5
|
+
|
6
|
+
desc "Copy images from gem to ../public/images/ie6nomore dir"
|
7
|
+
task :copy_images do
|
8
|
+
src_dir = "#{Sinatra::IE6NoMore.gem_root_path}/files/"
|
9
|
+
dest_dir = "#{Dir.pwd}/public/images/ie6nomore"
|
10
|
+
|
11
|
+
puts "\n Copying images from #{src_dir} to #{dest_dir}"
|
12
|
+
sh "mkdir -p #{dest_dir}" unless test(?e, dest_dir)
|
13
|
+
sh "cp -r #{src_dir} #{dest_dir}"
|
14
|
+
end
|
15
|
+
|
16
|
+
end #/ namespace ie6nomore
|
data/lib/sinatra/ie6nomore.rb
CHANGED
@@ -3,161 +3,275 @@ require 'yaml'
|
|
3
3
|
|
4
4
|
module Sinatra
|
5
5
|
|
6
|
-
|
6
|
+
##
|
7
|
+
# = Sinatra::IE6NoMore
|
7
8
|
#
|
8
|
-
# A simple extension in support of the IE6 No More[www.ie6nomore.com] campaign to rid the world of
|
9
|
+
# A simple extension in support of the {"IE6 No More"}[www.ie6nomore.com] campaign to rid the world of
|
9
10
|
# the nasty bug ridden monstrosity called IE6.
|
10
11
|
#
|
11
|
-
# Check the IE6 No More[www.ie6nomore.com] site for more information.
|
12
|
+
# Check the {"IE6 No More"}[www.ie6nomore.com] site for more information.
|
12
13
|
#
|
13
|
-
#
|
14
|
+
# == Installation
|
14
15
|
#
|
16
|
+
# # Add RubyGems.org (former Gemcutter) to your RubyGems sources
|
17
|
+
# $ gem sources -a http://rubygems.org
|
15
18
|
#
|
16
|
-
# sudo gem install
|
19
|
+
# $ (sudo)? gem install sinatra-ie6nomore
|
17
20
|
#
|
18
|
-
#
|
21
|
+
# == Dependencies
|
19
22
|
#
|
20
|
-
#
|
23
|
+
# This Gem depends upon the following:
|
21
24
|
#
|
22
|
-
#
|
25
|
+
# === Runtime:
|
23
26
|
#
|
24
|
-
#
|
27
|
+
# * sinatra ( >= 1.0.a )
|
28
|
+
#
|
29
|
+
#
|
30
|
+
# === Development & Tests:
|
31
|
+
#
|
32
|
+
# * sinatra-tests (>= 0.1.6)
|
33
|
+
# * rspec (>= 1.3.0 )
|
34
|
+
# * rack-test (>= 0.5.3)
|
35
|
+
# * rspec_hpricot_matchers (>= 0.1.0)
|
36
|
+
#
|
37
|
+
#
|
38
|
+
# == Getting Started
|
39
|
+
#
|
40
|
+
# To use this extension in your App just follow these two simple steps:
|
41
|
+
#
|
42
|
+
# === Step 1
|
25
43
|
#
|
26
|
-
# require 'sinatra/base'
|
27
|
-
#
|
28
44
|
# require 'sinatra/ie6nomore'
|
29
|
-
#
|
30
|
-
# ==== Step 2
|
31
45
|
#
|
32
|
-
#
|
46
|
+
# class YourApp < Sinatra::Base
|
47
|
+
#
|
48
|
+
# helpers Sinatra::IE6NoMore::Helpers
|
49
|
+
#
|
50
|
+
# # or
|
51
|
+
#
|
52
|
+
# register(Sinatra::IE6NoMore)
|
33
53
|
#
|
34
|
-
# class MyApp < Sinatra::Application
|
35
|
-
#
|
36
|
-
# helpers Sinatra::IE6NoMore
|
37
|
-
#
|
38
54
|
# <snip...>
|
39
|
-
#
|
40
|
-
# end
|
41
55
|
#
|
56
|
+
# end
|
42
57
|
#
|
43
|
-
#
|
58
|
+
# === Step 2
|
44
59
|
#
|
45
|
-
# Add this to your <tt
|
60
|
+
# Add this to your <tt>../views/layout.erb</tt> file.
|
46
61
|
#
|
47
62
|
# <html>
|
48
63
|
# <body>
|
49
|
-
#
|
64
|
+
#
|
50
65
|
# <%= ie6_no_more %>
|
51
|
-
#
|
66
|
+
#
|
52
67
|
# </body>
|
53
68
|
# </html>
|
54
69
|
#
|
55
|
-
# And in your HTML you'll see
|
70
|
+
# And in your HTML you'll see some output like this:
|
56
71
|
#
|
57
72
|
# <!--[if lt IE 7]>
|
58
73
|
# <div style="border: 1px solid #F7941D; background: #FEEFDA; text-align: center; clear: both; height: 75px; position: relative;">
|
59
|
-
# <div style="position: absolute; right: 3px; top: 3px; font-family: courier new; font-weight: bold;"><a href="#" onclick="javascript:this.parentNode.parentNode.style.display="none"; return false;"><img src="
|
74
|
+
# <div style="position: absolute; right: 3px; top: 3px; font-family: courier new; font-weight: bold;"><a href="#" onclick="javascript:this.parentNode.parentNode.style.display="none"; return false;"><img src="/images/ie6nomore/ie6nomore-cornerx.jpg" style="border: none;" alt="Close this notice"/></a></div>
|
60
75
|
# <div style="width: 640px; margin: 0 auto; text-align: left; padding: 0; overflow: hidden; color: black;">
|
61
|
-
# <div style="width: 75px; float: left;"><img src="
|
76
|
+
# <div style="width: 75px; float: left;"><img src="/images/ie6nomore/ie6nomore-warning.jpg" alt="Warning!"/></div>
|
62
77
|
# <div style="width: 275px; float: left; font-family: Arial, sans-serif;">
|
63
78
|
# <div style="font-size: 14px; font-weight: bold; margin-top: 12px;">You are using an outdated browser</div>
|
64
79
|
# <div style="font-size: 12px; margin-top: 6px; line-height: 12px;">For a better experience using this site, please upgrade to a modern web browser.</div>
|
65
80
|
# </div>
|
66
|
-
# <div style="width: 75px; float: left;"><a href="http://getfirefox.com/" target="_blank"><img src="
|
67
|
-
# <div style="width: 75px; float: left;"><a href="http://www.browserforthebetter.com/download.html" target="_blank"><img src="
|
68
|
-
# <div style="width: 73px; float: left;"><a href="http://www.apple.com/safari/download/" target="_blank"><img src="
|
69
|
-
# <div style="float: left;"><a href="http://www.google.com/chrome" target="_blank"><img src="
|
81
|
+
# <div style="width: 75px; float: left;"><a href="http://getfirefox.com/" target="_blank"><img src="/images/ie6nomore/ie6nomore-firefox.jpg" style="border: none;" alt="Get Firefox 3.5"/></a></div>
|
82
|
+
# <div style="width: 75px; float: left;"><a href="http://www.browserforthebetter.com/download.html" target="_blank"><img src="/images/ie6nomore/ie6nomore-ie8.jpg" style="border: none;" alt="Get Internet Explorer 8"/></a></div>
|
83
|
+
# <div style="width: 73px; float: left;"><a href="http://www.apple.com/safari/download/" target="_blank"><img src="/images/ie6nomore/ie6nomore-safari.jpg" style="border: none;" alt="Get Safari 4"/></a></div>
|
84
|
+
# <div style="float: left;"><a href="http://www.google.com/chrome" target="_blank"><img src="/images/ie6nomore/ie6nomore-chrome.jpg" style="border: none;" alt="Get Google Chrome"/></a></div>
|
70
85
|
# </div>
|
71
86
|
# </div>
|
72
87
|
# <![endif]-->
|
73
88
|
#
|
74
89
|
#
|
75
|
-
#
|
90
|
+
# That's what it does in a nutshell.
|
91
|
+
#
|
92
|
+
# === Customizing options
|
93
|
+
#
|
94
|
+
# You can easily customize the output through the following parameters passed to the method call:
|
95
|
+
#
|
96
|
+
#
|
97
|
+
# * <tt>:locale</tt> => Sets the locale for the output. (Default = :en => English)
|
98
|
+
#
|
99
|
+
# * <tt>:img_host</tt> => The URL to the ie6nomore images (Default = /images/ie6nomore).
|
100
|
+
# <b>NB!</b> No trailing slash
|
101
|
+
#
|
102
|
+
# * <tt>:border</tt> => The div border color. (Default = "1px solid #F7941D")
|
103
|
+
#
|
104
|
+
# * <tt>:background</tt> => The div background color. (Default = "#FEEFDA")
|
105
|
+
#
|
106
|
+
# * <tt>:text_color</tt> => The div text color. (Default = "black")
|
107
|
+
#
|
108
|
+
# * <tt>:debug</tt> => Whether to encapsulate the code with IE Comments or not.
|
109
|
+
# So you can see how it looks like when developing on NON-IE 6 browsers. (Default = false)
|
110
|
+
#
|
111
|
+
# <b>Examples:</b>
|
112
|
+
#
|
113
|
+
# # to change the image host
|
114
|
+
# <%= ie6_no_more(:img_host => "http://assets.example.com/images/ie6nomore/" ) %>
|
115
|
+
#
|
116
|
+
# # to change the background colour
|
117
|
+
# <%= ie6_no_more(:background => "#369" ) %>
|
118
|
+
#
|
119
|
+
# # to check how the site looks like with the IE6NoMore banner displayed during development
|
120
|
+
# <%= ie6_no_more(:debug => true) %>
|
121
|
+
#
|
122
|
+
#
|
123
|
+
#
|
124
|
+
# == Localizations
|
125
|
+
#
|
126
|
+
# You can also localize the output text with these currently available localizations:
|
127
|
+
#
|
128
|
+
# * English (en)
|
129
|
+
# * Spanish (es)
|
130
|
+
# * French (fr)
|
131
|
+
# * Portugese (br)
|
132
|
+
# * Italian (it)
|
133
|
+
# * Japanese (jp)
|
134
|
+
# * Swedish (se)
|
135
|
+
#
|
136
|
+
# Awaiting further translations from IE6NoMore website or through your fork.
|
76
137
|
#
|
77
138
|
#
|
139
|
+
# == GOTCHAs
|
140
|
+
#
|
141
|
+
# By default the image host for the images displayed in the banner is your server
|
142
|
+
# [ <tt>/images/ie6nomore/</tt> ]. However upon initial inclusion of the solution,
|
143
|
+
# you do not have the required images on your server.
|
144
|
+
#
|
145
|
+
# You can remedie this by adding the following to your app's Rakefile.
|
146
|
+
#
|
147
|
+
# # in ../Rakefile
|
148
|
+
#
|
149
|
+
# require 'sinatra/ie6nomore/rake
|
150
|
+
#
|
151
|
+
#
|
152
|
+
# Then you can fire up your CLI and use this rake task:
|
153
|
+
#
|
154
|
+
# rake ie6nomore:copy_images
|
155
|
+
#
|
156
|
+
# You should now have all the images locally stored on your server.
|
157
|
+
#
|
158
|
+
# <b>NB!</b> assumes that the <tt>'../public/'</tt> directory is at the root of your app,
|
159
|
+
# and that it contains an <tt>'images/'</tt> directory.
|
160
|
+
#
|
161
|
+
#
|
162
|
+
# == Copyright
|
163
|
+
#
|
164
|
+
# Copyright (c) 2010 Kematzy and the guys behind {"IE6 No More"}[www.ie6nomore.com] site.
|
165
|
+
#
|
166
|
+
# Released under the MIT License.
|
167
|
+
#
|
168
|
+
# See LICENSE for further details.
|
169
|
+
#
|
78
170
|
module IE6NoMore
|
79
171
|
|
80
|
-
VERSION = '0.1.
|
172
|
+
VERSION = '0.1.2' unless const_defined?(:VERSION)
|
81
173
|
def self.version; "Sinatra::IE6NoMore v#{VERSION}"; end
|
82
|
-
|
174
|
+
|
83
175
|
##
|
84
|
-
#
|
176
|
+
# Sets the full path to the gem_installation, used by the Rake tasks
|
177
|
+
# included in the Gem.
|
85
178
|
#
|
86
|
-
# ==== Params
|
87
|
-
#
|
88
|
-
# * options [Hash] => Optional configurations options
|
89
|
-
# * <tt>:locale</tt> => Locale (Default = :en)
|
90
|
-
# * <tt>:img_host</tt> => The URL to the ie6nomore images (Default = http://www.ie6nomore.com/files/theme). <b>NB!</b> No trailing slash
|
91
|
-
# * <tt>:border</tt> => The div border color. (Default = "1px solid #F7941D")
|
92
|
-
# * <tt>:background</tt> => The div background color. (Default = "#FEEFDA")
|
93
|
-
# * <tt>:text_color</tt> => The div text color. (Default = "black")
|
94
|
-
# * <tt>:debug</tt> => Whether to encapsulate the code with the IE Comments or not. (Default = false)
|
95
|
-
#
|
96
179
|
# ==== Examples
|
97
180
|
#
|
98
|
-
#
|
99
|
-
#
|
100
|
-
# ie6_no_more(:img_host => "http://www.example.com/images/ie6") => different image host
|
101
|
-
#
|
102
|
-
# ie6_no_more(:border => "2px dashed green", :background => 'black', :text_color => 'white' )
|
103
|
-
# => different color scheme for text, border & background colors
|
104
|
-
#
|
105
|
-
# To see how it looks like when developing on a NON-IE 6 browsers.
|
181
|
+
# Sinatra::IE6NoMore.gem_root_path => /path/2/gems/sinatra-ie6nomore-X.X.X
|
106
182
|
#
|
107
|
-
#
|
108
|
-
|
109
|
-
|
110
|
-
def ie6_no_more(options = {})
|
111
|
-
o = {
|
112
|
-
:locale => :en,
|
113
|
-
:img_host => "http://www.ie6nomore.com/files/theme",
|
114
|
-
:border => "1px solid #F7941D",
|
115
|
-
:background => "#FEEFDA",
|
116
|
-
:text_color => "black",
|
117
|
-
:debug => false
|
118
|
-
}.merge(options)
|
119
|
-
|
120
|
-
localizations = load_i18n
|
121
|
-
# set the localisation
|
122
|
-
i18n = localizations[o[:locale].to_s]
|
123
|
-
|
124
|
-
html = ''
|
125
|
-
html << %Q[<!--[if lt IE 7]>\n] unless o[:debug] # == true
|
126
|
-
html << %Q[<div style="border: #{o[:border]}; background: #{o[:background]}; text-align: center; clear: both; height: 75px; position: relative;">\n]
|
127
|
-
html << %Q[ <div style="position: absolute; right: 3px; top: 3px; font-family: courier new; font-weight: bold;"><a href="#" onclick="javascript:this.parentNode.parentNode.style.display="none"; return false;"><img src="#{o[:img_host]}/ie6nomore-cornerx.jpg" style="border: none;" alt="#{i18n['close']}"/></a></div>\n]
|
128
|
-
html << %Q[ <div style="width: 640px; margin: 0 auto; text-align: left; padding: 0; overflow: hidden; color: #{o[:text_color]};">\n]
|
129
|
-
html << %Q[ <div style="width: 75px; float: left;"><img src="#{o[:img_host]}/ie6nomore-warning.jpg" alt="Warning!"/></div>\n]
|
130
|
-
html << %Q[ <div style="width: 275px; float: left; font-family: Arial, sans-serif;">\n]
|
131
|
-
html << %Q[ <div style="font-size: 14px; font-weight: bold; margin-top: 12px;">#{i18n['header']}</div>\n]
|
132
|
-
html << %Q[ <div style="font-size: 12px; margin-top: 6px; line-height: 12px;">#{i18n['sub']}</div>\n]
|
133
|
-
html << %Q[ </div>\n]
|
134
|
-
html << %Q[ <div style="width: 75px; float: left;"><a href="#{i18n['ff_url']}" target="_blank"><img src="#{o[:img_host]}/ie6nomore-firefox.jpg" style="border: none;" alt="#{i18n['get']} Firefox 3.5"/></a></div>\n]
|
135
|
-
html << %Q[ <div style="width: 75px; float: left;"><a href="#{i18n['ie_url']}" target="_blank"><img src="#{o[:img_host]}/ie6nomore-ie8.jpg" style="border: none;" alt="#{i18n['get']} Internet Explorer 8"/></a></div>\n]
|
136
|
-
html << %Q[ <div style="width: 73px; float: left;"><a href="#{i18n['safari_url']}" target="_blank"><img src="#{o[:img_host]}/ie6nomore-safari.jpg" style="border: none;" alt="#{i18n['get']} Safari 4"/></a></div>\n]
|
137
|
-
html << %Q[ <div style="float: left;"><a href="#{i18n['chrome_url']}" target="_blank"><img src="#{o[:img_host]}/ie6nomore-chrome.jpg" style="border: none;" alt="#{i18n['get']} Google Chrome"/></a></div>\n]
|
138
|
-
html << %Q[ </div>\n]
|
139
|
-
html << %Q[</div>\n]
|
140
|
-
html << %Q[<![endif]-->\n] unless o[:debug] # == true
|
141
|
-
html
|
183
|
+
# @api private
|
184
|
+
def self.gem_root_path
|
185
|
+
File.expand_path(File.join(File.dirname(__FILE__), '..', '..') )
|
142
186
|
end
|
143
187
|
|
144
|
-
|
188
|
+
module Helpers
|
145
189
|
|
146
190
|
##
|
147
|
-
#
|
191
|
+
# Outputs the "IE6 No More" banner.
|
192
|
+
#
|
193
|
+
# ==== Params
|
194
|
+
#
|
195
|
+
# * options [Hash] => Optional configurations options
|
196
|
+
# * <tt>:locale</tt> => Locale (Default = :en)
|
197
|
+
# * <tt>:img_host</tt> => The URL to the ie6nomore images (Default = /images/ie6nomore/). <b>NB!</b> The trailing slash
|
198
|
+
# * <tt>:border</tt> => The div border color. (Default = "1px solid #F7941D")
|
199
|
+
# * <tt>:background</tt> => The div background color. (Default = "#FEEFDA")
|
200
|
+
# * <tt>:text_color</tt> => The div text color. (Default = "black")
|
201
|
+
# * <tt>:debug</tt> => Whether to encapsulate the code with the IE Comments or not. (Default = false)
|
148
202
|
#
|
149
203
|
# ==== Examples
|
150
204
|
#
|
151
|
-
#
|
205
|
+
# ie6_no_more(:locale => :es ) => Spanish version
|
206
|
+
#
|
207
|
+
# ie6_no_more(:img_host => "http://www.example.com/images/ie6/") => different image host
|
208
|
+
#
|
209
|
+
# ie6_no_more(:border => "2px dashed green", :background => 'black', :text_color => 'white' )
|
210
|
+
# => different color scheme for text, border & background colors
|
211
|
+
#
|
212
|
+
# To see how it looks like when developing on a NON-IE 6 browsers.
|
152
213
|
#
|
153
|
-
#
|
154
|
-
|
155
|
-
|
214
|
+
# ie6_no_more(:debug => true) => removes the encapsulating IE comments.
|
215
|
+
#
|
216
|
+
# @api public
|
217
|
+
def ie6_no_more(options = {})
|
218
|
+
o = {
|
219
|
+
:locale => :en,
|
220
|
+
# :img_host => "http://www.ie6nomore.com/files/theme/",
|
221
|
+
:img_host => "/images/ie6nomore/", # NB! trailing slash
|
222
|
+
:border => "1px solid #F7941D",
|
223
|
+
:background => "#FEEFDA",
|
224
|
+
:text_color => "black",
|
225
|
+
:debug => false
|
226
|
+
}.merge(options)
|
227
|
+
|
228
|
+
localizations = load_i18n
|
229
|
+
# set the localisation
|
230
|
+
i18n = localizations[o[:locale].to_s]
|
231
|
+
|
232
|
+
html = ''
|
233
|
+
html << %Q[<!--[if lt IE 7]>\n] unless o[:debug] # == true
|
234
|
+
html << %Q[<div style="border: #{o[:border]}; background: #{o[:background]}; text-align: center; clear: both; height: 75px; position: relative;">\n]
|
235
|
+
html << %Q[ <div style="position: absolute; right: 3px; top: 3px; font-family: courier new; font-weight: bold;"><a href="#" onclick="javascript:this.parentNode.parentNode.style.display='none'; return false;"><img src="#{o[:img_host]}ie6nomore-cornerx.jpg" style="border: none;" alt="#{i18n['close']}"/></a></div>\n]
|
236
|
+
html << %Q[ <div style="width: 640px; margin: 0 auto; text-align: left; padding: 0; overflow: hidden; color: #{o[:text_color]};">\n]
|
237
|
+
html << %Q[ <div style="width: 75px; float: left;"><img src="#{o[:img_host]}ie6nomore-warning.jpg" alt="Warning!"/></div>\n]
|
238
|
+
html << %Q[ <div style="width: 275px; float: left; font-family: Arial, sans-serif;">\n]
|
239
|
+
html << %Q[ <div style="font-size: 14px; font-weight: bold; margin-top: 12px;">#{i18n['header']}</div>\n]
|
240
|
+
html << %Q[ <div style="font-size: 12px; margin-top: 6px; line-height: 12px;">#{i18n['sub']}</div>\n]
|
241
|
+
html << %Q[ </div>\n]
|
242
|
+
html << %Q[ <div style="width: 75px; float: left;"><a href="#{i18n['ff_url']}" target="_blank"><img src="#{o[:img_host]}ie6nomore-firefox.jpg" style="border: none;" alt="#{i18n['get']} Firefox 3.5"/></a></div>\n]
|
243
|
+
html << %Q[ <div style="width: 75px; float: left;"><a href="#{i18n['ie_url']}" target="_blank"><img src="#{o[:img_host]}ie6nomore-ie8.jpg" style="border: none;" alt="#{i18n['get']} Internet Explorer 8"/></a></div>\n]
|
244
|
+
html << %Q[ <div style="width: 73px; float: left;"><a href="#{i18n['safari_url']}" target="_blank"><img src="#{o[:img_host]}ie6nomore-safari.jpg" style="border: none;" alt="#{i18n['get']} Safari 4"/></a></div>\n]
|
245
|
+
html << %Q[ <div style="float: left;"><a href="#{i18n['chrome_url']}" target="_blank"><img src="#{o[:img_host]}ie6nomore-chrome.jpg" style="border: none;" alt="#{i18n['get']} Google Chrome"/></a></div>\n]
|
246
|
+
html << %Q[ </div>\n]
|
247
|
+
html << %Q[</div>\n]
|
248
|
+
html << %Q[<![endif]-->\n] unless o[:debug] # == true
|
249
|
+
html
|
156
250
|
end
|
157
251
|
|
158
252
|
|
253
|
+
private
|
254
|
+
|
255
|
+
##
|
256
|
+
# Loads the i18n.yml localizations file and returns a Hash
|
257
|
+
#
|
258
|
+
# ==== Examples
|
259
|
+
#
|
260
|
+
# localizations = load_i18n
|
261
|
+
#
|
262
|
+
# @api private
|
263
|
+
def load_i18n
|
264
|
+
res = YAML.load_file(File.join(File.dirname(__FILE__), 'ie6nomore.i18n.yml'))
|
265
|
+
end
|
266
|
+
|
267
|
+
end #/ Helpers
|
268
|
+
|
269
|
+
def self.registered(app)
|
270
|
+
app.helpers Sinatra::IE6NoMore::Helpers
|
271
|
+
end
|
272
|
+
|
159
273
|
end #/ IE6NoMore
|
160
274
|
|
161
|
-
helpers IE6NoMore
|
275
|
+
helpers Sinatra::IE6NoMore::Helpers
|
162
276
|
|
163
|
-
end #/ Sinatra
|
277
|
+
end #/ Sinatra
|
data/sinatra-ie6nomore.gemspec
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sinatra-ie6nomore}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["kematzy"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2010-03-01}
|
13
|
+
s.description = %q{A Sinatra Extension that shows an 'IE6 No More' div on the page for IE6 browsers, making the eradication of IE6 easier.}
|
13
14
|
s.email = %q{kematzy@gmail.com}
|
14
15
|
s.extra_rdoc_files = [
|
15
16
|
"LICENSE",
|
@@ -22,8 +23,15 @@ Gem::Specification.new do |s|
|
|
22
23
|
"README.rdoc",
|
23
24
|
"Rakefile",
|
24
25
|
"VERSION",
|
26
|
+
"files/ie6nomore-chrome.jpg",
|
27
|
+
"files/ie6nomore-cornerx.jpg",
|
28
|
+
"files/ie6nomore-firefox.jpg",
|
29
|
+
"files/ie6nomore-ie8.jpg",
|
30
|
+
"files/ie6nomore-safari.jpg",
|
31
|
+
"files/ie6nomore-warning.jpg",
|
25
32
|
"lib/sinatra/ie6nomore.i18n.yml",
|
26
33
|
"lib/sinatra/ie6nomore.rb",
|
34
|
+
"lib/sinatra/ie6nomore/rake.rb",
|
27
35
|
"sinatra-ie6nomore.gemspec",
|
28
36
|
"spec/sinatra/ie6nomore_spec.rb",
|
29
37
|
"spec/spec_helper.rb"
|
@@ -31,8 +39,8 @@ Gem::Specification.new do |s|
|
|
31
39
|
s.homepage = %q{http://github.com/kematzy/sinatra-ie6nomore}
|
32
40
|
s.rdoc_options = ["--charset=UTF-8"]
|
33
41
|
s.require_paths = ["lib"]
|
34
|
-
s.rubygems_version = %q{1.3.
|
35
|
-
s.summary = %q{'IE6 No More'
|
42
|
+
s.rubygems_version = %q{1.3.6}
|
43
|
+
s.summary = %q{A Sinatra Extension that shows an 'IE6 No More' div on the page for IE6 browsers, making the eradication of IE6 easier.}
|
36
44
|
s.test_files = [
|
37
45
|
"spec/sinatra/ie6nomore_spec.rb",
|
38
46
|
"spec/spec_helper.rb"
|
@@ -57,3 +65,4 @@ Gem::Specification.new do |s|
|
|
57
65
|
s.add_dependency(%q<rspec_hpricot_matchers>, [">= 1.0.0"])
|
58
66
|
end
|
59
67
|
end
|
68
|
+
|
@@ -2,61 +2,69 @@ require "#{File.dirname(File.dirname(File.expand_path(__FILE__)))}/spec_helper"
|
|
2
2
|
|
3
3
|
describe "Sinatra" do
|
4
4
|
|
5
|
+
def remove_enclosing_html_comments(markup)
|
6
|
+
return markup.sub('<!--[if lt IE 7]>', '').sub('<![endif]-->','')
|
7
|
+
end
|
8
|
+
|
5
9
|
describe "IE6NoMore" do
|
6
10
|
|
7
|
-
|
8
|
-
|
11
|
+
class MyTestApp
|
12
|
+
register(Sinatra::IE6NoMore)
|
9
13
|
end
|
10
14
|
|
11
|
-
|
15
|
+
# convenience shared spec that sets up MyTestApp and tests it's OK,
|
16
|
+
# without it you will get "stack level too deep" errors
|
17
|
+
it_should_behave_like "MyTestApp"
|
18
|
+
|
19
|
+
describe "#self.gem_root_path" do
|
20
|
+
|
21
|
+
it "should return the full path to the gem" do
|
22
|
+
Sinatra::IE6NoMore.gem_root_path.should == File.expand_path(File.join(File.dirname(__FILE__), '..','..'))
|
23
|
+
end
|
24
|
+
|
25
|
+
end #/ #self.gem_root_path
|
26
|
+
|
27
|
+
describe "#ie6_no_more" do
|
12
28
|
|
13
29
|
describe "with defaults" do
|
14
30
|
|
15
31
|
it "should return the expected HTML" do
|
16
32
|
erb_app %Q[<%= ie6_no_more %>]
|
17
|
-
|
18
|
-
# markup.should have_tag('debug')
|
33
|
+
|
19
34
|
# test the comments first before removing
|
20
|
-
|
21
|
-
|
35
|
+
body.should match(/<!--\[if lt IE 7\]/)
|
36
|
+
body.should match(/<!\[endif\]-->$/)
|
22
37
|
|
23
38
|
# remove the comments so we can test the code output
|
24
|
-
markup = remove_enclosing_html_comments(
|
25
|
-
# markup.should have_tag('debug')
|
26
|
-
|
39
|
+
markup = remove_enclosing_html_comments(body)
|
27
40
|
# we get the border and background through OK
|
28
41
|
markup.should match(/<div style="border: 1px solid #F7941D; background: #FEEFDA;/)
|
29
|
-
|
30
42
|
# we have a warning image
|
31
43
|
markup.should have_tag('div[@style=width: 75px; float: left;] > img') do |img|
|
32
|
-
img.attributes['src'].should == '
|
44
|
+
img.attributes['src'].should == '/images/ie6nomore/ie6nomore-warning.jpg'
|
33
45
|
end
|
34
|
-
|
35
|
-
markup.should have_tag('img[@src=http://www.ie6nomore.com/files/theme/ie6nomore-cornerx.jpg]')
|
36
|
-
|
46
|
+
markup.should have_tag('img[@src=/images/ie6nomore/ie6nomore-cornerx.jpg]')
|
37
47
|
# text
|
38
48
|
markup.should have_tag('img[@alt=Close this notice]')
|
39
49
|
markup.should have_tag('div[@style=font-size: 14px; font-weight: bold; margin-top: 12px;]','You are using an outdated browser')
|
40
50
|
markup.should have_tag('div[@style=font-size: 12px; margin-top: 6px; line-height: 12px;]','For a better experience using this site, please upgrade to a modern web browser.')
|
41
|
-
|
42
51
|
# browsers
|
43
52
|
markup.should have_tag('div > a[@href=http://getfirefox.com/] > img') do |img|
|
44
|
-
img.attributes['src'].should == '
|
53
|
+
img.attributes['src'].should == '/images/ie6nomore/ie6nomore-firefox.jpg'
|
45
54
|
img.attributes['alt'].should == 'Get Firefox 3.5'
|
46
55
|
end
|
47
56
|
markup.should have_tag('div > a[@href=http://www.browserforthebetter.com/download.html] > img') do |img|
|
48
|
-
img.attributes['src'].should == '
|
57
|
+
img.attributes['src'].should == '/images/ie6nomore/ie6nomore-ie8.jpg'
|
49
58
|
img.attributes['alt'].should == 'Get Internet Explorer 8'
|
50
59
|
end
|
51
60
|
markup.should have_tag('div > a[@href=http://www.apple.com/safari/download/] > img') do |img|
|
52
|
-
img.attributes['src'].should == '
|
61
|
+
img.attributes['src'].should == '/images/ie6nomore/ie6nomore-safari.jpg'
|
53
62
|
img.attributes['alt'].should == 'Get Safari 4'
|
54
63
|
end
|
55
64
|
markup.should have_tag('div > a[@href=http://www.google.com/chrome] > img') do |img|
|
56
|
-
img.attributes['src'].should == '
|
65
|
+
img.attributes['src'].should == '/images/ie6nomore/ie6nomore-chrome.jpg'
|
57
66
|
img.attributes['alt'].should == 'Get Google Chrome'
|
58
67
|
end
|
59
|
-
|
60
68
|
end
|
61
69
|
|
62
70
|
end #/ with defaults
|
@@ -64,10 +72,9 @@ describe "Sinatra" do
|
|
64
72
|
describe "with options" do
|
65
73
|
|
66
74
|
before(:each) do
|
67
|
-
erb_app %Q[<%= ie6_no_more(:img_host => "http://example.com/images", :background => 'yellow', :border => '10px dashed #fff', :text_color => 'red' ) %>]
|
75
|
+
erb_app %Q[<%= ie6_no_more(:img_host => "http://example.com/images/", :background => 'yellow', :border => '10px dashed #fff', :text_color => 'red' ) %>]
|
68
76
|
# remove the comments so we can test the code output
|
69
77
|
@markup = remove_enclosing_html_comments(last_response.body)
|
70
|
-
# @markup.should have_tag('debug')
|
71
78
|
end
|
72
79
|
|
73
80
|
it "should set the border style attribute" do
|
@@ -86,25 +93,21 @@ describe "Sinatra" do
|
|
86
93
|
@markup.should have_tag('img[@src=http://example.com/images/ie6nomore-cornerx.jpg]')
|
87
94
|
end
|
88
95
|
|
89
|
-
it "should show the HTML without IE comments when :debug => true " do
|
96
|
+
it "should show the HTML without IE comments when :debug => true " do
|
90
97
|
erb_app %Q[<%= ie6_no_more(:debug => true ) %>]
|
91
98
|
markup = last_response.body
|
92
|
-
|
93
|
-
|
94
|
-
markup.should_not match(/<!\[endif\]-->$/)
|
95
|
-
|
99
|
+
body.should_not match(/<!--\[if lt IE 7\]/)
|
100
|
+
body.should_not match(/<!\[endif\]-->$/)
|
96
101
|
end
|
97
102
|
|
98
103
|
end #/ with options
|
99
104
|
|
100
|
-
|
101
105
|
describe "with localizations" do
|
102
106
|
|
103
107
|
it "should have Spanish version" do
|
104
108
|
erb_app %Q[<%= ie6_no_more(:locale => :es ) %>]
|
105
109
|
# remove the comments so we can test the code output
|
106
110
|
markup = remove_enclosing_html_comments(last_response.body)
|
107
|
-
# markup.should have_tag('debug')
|
108
111
|
|
109
112
|
# text
|
110
113
|
markup.should have_tag('img[@alt=Cierra este aviso]')
|
@@ -113,19 +116,15 @@ describe "Sinatra" do
|
|
113
116
|
|
114
117
|
# browsers
|
115
118
|
markup.should have_tag('div > a[@href=http://www.mozilla-europe.org/es/firefox/] > img') do |img|
|
116
|
-
img.attributes['src'].should == 'http://www.ie6nomore.com/files/theme/ie6nomore-firefox.jpg'
|
117
119
|
img.attributes['alt'].should == 'Consiga Firefox 3.5'
|
118
120
|
end
|
119
121
|
markup.should have_tag('div > a[@href=http://www.microsoft.com/downloads/details.aspx?FamilyID=341c2ad5-8c3d-4347-8c03-08cdecd8852b&DisplayLang=es] > img') do |img|
|
120
|
-
img.attributes['src'].should == 'http://www.ie6nomore.com/files/theme/ie6nomore-ie8.jpg'
|
121
122
|
img.attributes['alt'].should == 'Consiga Internet Explorer 8'
|
122
123
|
end
|
123
124
|
markup.should have_tag('div > a[@href=http://www.apple.com/es/safari/download/] > img') do |img|
|
124
|
-
img.attributes['src'].should == 'http://www.ie6nomore.com/files/theme/ie6nomore-safari.jpg'
|
125
125
|
img.attributes['alt'].should == 'Consiga Safari 4'
|
126
126
|
end
|
127
127
|
markup.should have_tag('div > a[@href=http://www.google.com/chrome?hl=es] > img') do |img|
|
128
|
-
img.attributes['src'].should == 'http://www.ie6nomore.com/files/theme/ie6nomore-chrome.jpg'
|
129
128
|
img.attributes['alt'].should == 'Consiga Google Chrome'
|
130
129
|
end
|
131
130
|
end
|
@@ -134,7 +133,6 @@ describe "Sinatra" do
|
|
134
133
|
erb_app %Q[<%= ie6_no_more(:locale => :fr ) %>]
|
135
134
|
# remove the comments so we can test the code output
|
136
135
|
markup = remove_enclosing_html_comments(last_response.body)
|
137
|
-
# markup.should have_tag('debug')
|
138
136
|
|
139
137
|
# text
|
140
138
|
markup.should have_tag('img[@alt=Fermez cette notification]')
|
@@ -270,7 +268,7 @@ describe "Sinatra" do
|
|
270
268
|
|
271
269
|
describe "#load_i18n" do
|
272
270
|
|
273
|
-
module Sinatra::IE6NoMore
|
271
|
+
module Sinatra::IE6NoMore::Helpers
|
274
272
|
public :load_i18n
|
275
273
|
end
|
276
274
|
|
@@ -278,12 +276,24 @@ describe "Sinatra" do
|
|
278
276
|
app.load_i18n.should be_a_kind_of(Hash)
|
279
277
|
end
|
280
278
|
|
281
|
-
it "should have further tests" do
|
279
|
+
it "should have further tests" do
|
282
280
|
pending "energy and time to fix this...."
|
283
281
|
end
|
284
282
|
|
285
283
|
end #/ #load_i18n
|
286
284
|
|
285
|
+
describe "Rake Tasks" do
|
286
|
+
|
287
|
+
describe "rake ie6nomore:copy_images" do
|
288
|
+
|
289
|
+
it "should copy the images from the gem root to the app/public/images/ie6nomore directory" do
|
290
|
+
pending "TODO: need to work out how to test this functionality"
|
291
|
+
end
|
292
|
+
|
293
|
+
end #/ rake ie6nomore:copy_images
|
294
|
+
|
295
|
+
end #/ Rake Tasks
|
296
|
+
|
287
297
|
end #/ IE6NoMore
|
288
298
|
|
289
299
|
end #/ Sinatra
|
data/spec/spec_helper.rb
CHANGED
@@ -1,50 +1,57 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'spec/interop/test'
|
4
|
-
require 'rack/test'
|
5
|
-
require 'rspec_hpricot_matchers'
|
1
|
+
|
2
|
+
::APP_ROOT = "#{File.dirname(File.expand_path(__FILE__))}/fixtures"
|
6
3
|
|
7
4
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
8
5
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
9
|
-
|
6
|
+
|
7
|
+
ENV['RACK_ENV'] = 'test'
|
8
|
+
|
9
|
+
#--
|
10
|
+
# DEPENDENCIES
|
11
|
+
#++
|
12
|
+
%w(
|
13
|
+
sinatra/base
|
14
|
+
).each {|lib| require lib }
|
15
|
+
|
16
|
+
#--
|
17
|
+
## SINATRA EXTENSIONS
|
18
|
+
#++
|
19
|
+
%w(
|
20
|
+
sinatra/tests
|
21
|
+
sinatra/ie6nomore
|
22
|
+
).each {|ext| require ext }
|
23
|
+
|
10
24
|
|
11
25
|
Spec::Runner.configure do |config|
|
12
26
|
config.include RspecHpricotMatchers
|
27
|
+
config.include Sinatra::Tests::TestCase
|
28
|
+
config.include Sinatra::Tests::RSpec::SharedSpecs
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
# quick convenience methods..
|
33
|
+
|
34
|
+
def fixtures_path
|
35
|
+
"#{File.dirname(File.expand_path(__FILE__))}/fixtures"
|
36
|
+
end
|
37
|
+
|
38
|
+
def public_fixtures_path
|
39
|
+
"#{fixtures_path}/public"
|
13
40
|
end
|
14
41
|
|
15
42
|
class MyTestApp < Sinatra::Base
|
16
43
|
|
17
|
-
|
44
|
+
set :app_dir, "#{APP_ROOT}/app"
|
45
|
+
set :public, "#{fixtures_path}/public"
|
46
|
+
set :views, "#{app_dir}/views"
|
18
47
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
erb(params[:view], :layout => params[:layout] )
|
23
|
-
when 'haml'
|
24
|
-
haml(params[:view], :layout => params[:layout] )
|
25
|
-
else
|
26
|
-
params.inspect
|
27
|
-
end
|
28
|
-
end
|
48
|
+
register(Sinatra::Tests)
|
49
|
+
|
50
|
+
enable :raise_errors
|
29
51
|
|
30
52
|
end #/class MyTestApp
|
31
53
|
|
32
54
|
|
33
|
-
|
34
55
|
class Test::Unit::TestCase
|
35
|
-
|
36
|
-
|
37
|
-
def setup
|
38
|
-
Sinatra::Base.set :environment, :test
|
39
|
-
end
|
40
|
-
|
41
|
-
def app
|
42
|
-
MyTestApp.new
|
43
|
-
end
|
44
|
-
|
45
|
-
def erb_app(view, options = {})
|
46
|
-
options = {:layout => '<%= yield %>', :url => '/tests' }.merge(options)
|
47
|
-
get options[:url], :view => view, :layout => options[:layout], :engine => :erb
|
48
|
-
end
|
49
|
-
|
56
|
+
Sinatra::Base.set :environment, :test
|
50
57
|
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-ie6nomore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- kematzy
|
@@ -9,40 +14,52 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-03-01 00:00:00 +08:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: sinatra
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 9
|
30
|
+
- 4
|
23
31
|
version: 0.9.4
|
24
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
25
34
|
- !ruby/object:Gem::Dependency
|
26
35
|
name: spec
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
38
|
requirements:
|
31
39
|
- - ">="
|
32
40
|
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 1
|
43
|
+
- 2
|
44
|
+
- 7
|
33
45
|
version: 1.2.7
|
34
|
-
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id002
|
35
48
|
- !ruby/object:Gem::Dependency
|
36
49
|
name: rspec_hpricot_matchers
|
37
|
-
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
52
|
requirements:
|
41
53
|
- - ">="
|
42
54
|
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 1
|
57
|
+
- 0
|
58
|
+
- 0
|
43
59
|
version: 1.0.0
|
44
|
-
|
45
|
-
|
60
|
+
type: :development
|
61
|
+
version_requirements: *id003
|
62
|
+
description: A Sinatra Extension that shows an 'IE6 No More' div on the page for IE6 browsers, making the eradication of IE6 easier.
|
46
63
|
email: kematzy@gmail.com
|
47
64
|
executables: []
|
48
65
|
|
@@ -58,8 +75,15 @@ files:
|
|
58
75
|
- README.rdoc
|
59
76
|
- Rakefile
|
60
77
|
- VERSION
|
78
|
+
- files/ie6nomore-chrome.jpg
|
79
|
+
- files/ie6nomore-cornerx.jpg
|
80
|
+
- files/ie6nomore-firefox.jpg
|
81
|
+
- files/ie6nomore-ie8.jpg
|
82
|
+
- files/ie6nomore-safari.jpg
|
83
|
+
- files/ie6nomore-warning.jpg
|
61
84
|
- lib/sinatra/ie6nomore.i18n.yml
|
62
85
|
- lib/sinatra/ie6nomore.rb
|
86
|
+
- lib/sinatra/ie6nomore/rake.rb
|
63
87
|
- sinatra-ie6nomore.gemspec
|
64
88
|
- spec/sinatra/ie6nomore_spec.rb
|
65
89
|
- spec/spec_helper.rb
|
@@ -76,21 +100,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
100
|
requirements:
|
77
101
|
- - ">="
|
78
102
|
- !ruby/object:Gem::Version
|
103
|
+
segments:
|
104
|
+
- 0
|
79
105
|
version: "0"
|
80
|
-
version:
|
81
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
107
|
requirements:
|
83
108
|
- - ">="
|
84
109
|
- !ruby/object:Gem::Version
|
110
|
+
segments:
|
111
|
+
- 0
|
85
112
|
version: "0"
|
86
|
-
version:
|
87
113
|
requirements: []
|
88
114
|
|
89
115
|
rubyforge_project:
|
90
|
-
rubygems_version: 1.3.
|
116
|
+
rubygems_version: 1.3.6
|
91
117
|
signing_key:
|
92
118
|
specification_version: 3
|
93
|
-
summary:
|
119
|
+
summary: A Sinatra Extension that shows an 'IE6 No More' div on the page for IE6 browsers, making the eradication of IE6 easier.
|
94
120
|
test_files:
|
95
121
|
- spec/sinatra/ie6nomore_spec.rb
|
96
122
|
- spec/spec_helper.rb
|