sinatra-ie6nomore 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ ## OS STUFF
2
+ .DS_Store
3
+
4
+ ## TM SPECIFIC
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## PROJECT::GENERAL
9
+ *.sw?
10
+ coverage
11
+ rdoc
12
+ pkg
13
+ doc
14
+
15
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 kematzy
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,103 @@
1
+ = Sinatra::IE6NoMore Extension
2
+
3
+ A simple extension in support of the {"IE6 No More"}[www.ie6nomore.com] campaign to rid the world of
4
+ the nasty bug ridden monstrosity called IE6.
5
+
6
+ Check the {"IE6 No More"}[www.ie6nomore.com] site for more information.
7
+
8
+ === Install
9
+
10
+
11
+ sudo gem install kematzy-sinatra-ie6nomore
12
+
13
+ === Usage
14
+
15
+ Three steps
16
+
17
+ ==== Step 1
18
+
19
+ Require the Sinatra::IE6NoMore gem
20
+
21
+ require 'sinatra/base'
22
+
23
+ require 'sinatra/ie6nomore'
24
+
25
+ ==== Step 2
26
+
27
+ Include in your app.
28
+
29
+ class MyApp < Sinatra::Application
30
+
31
+ helpers Sinatra::IE6NoMore
32
+
33
+ <snip...>
34
+
35
+ end
36
+
37
+
38
+ ==== Step 3
39
+
40
+ Add this to your <tt>/views/layout.erb</tt> file.
41
+
42
+ <html>
43
+ <body>
44
+
45
+ <%= ie6nomore %>
46
+
47
+ </body>
48
+ </html>
49
+
50
+ And in your HTML you'll see an output like this:
51
+
52
+ <!--[if lt IE 7]>
53
+ <div style="border: 1px solid #F7941D; background: #FEEFDA; text-align: center; clear: both; height: 75px; position: relative;">
54
+ <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="http://www.ie6nomore.com/files/theme/ie6nomore-cornerx.jpg" style="border: none;" alt="Close this notice"/></a></div>
55
+ <div style="width: 640px; margin: 0 auto; text-align: left; padding: 0; overflow: hidden; color: black;">
56
+ <div style="width: 75px; float: left;"><img src="http://www.ie6nomore.com/files/theme/ie6nomore-warning.jpg" alt="Warning!"/></div>
57
+ <div style="width: 275px; float: left; font-family: Arial, sans-serif;">
58
+ <div style="font-size: 14px; font-weight: bold; margin-top: 12px;">You are using an outdated browser</div>
59
+ <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>
60
+ </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
+ </div>
67
+ <![endif]-->
68
+
69
+
70
+ === Configuration Options
71
+
72
+ * <tt>:locale</tt> => Locale (Default = :en)
73
+
74
+ * <tt>:img_host</tt> => The URL to the ie6nomore images (Default = http://www.ie6nomore.com/files/theme). <b>NB!</b> No trailing slash
75
+
76
+ * <tt>:border</tt> => The div border color. (Default = "1px solid #F7941D")
77
+
78
+ * <tt>:background</tt> => The div background color. (Default = "#FEEFDA")
79
+
80
+ * <tt>:text_color</tt> => The div text color. (Default = "black")
81
+
82
+ === Localizations
83
+
84
+ Currently supported localizations are:
85
+
86
+ * English (en)
87
+ * Spanish (es)
88
+ * French (fr)
89
+ * Portugese (br)
90
+ * Italian (it)
91
+ * Japanese (jp)
92
+ * Swedish (se)
93
+
94
+
95
+ == TODOs
96
+
97
+ * Rake task to harvest all IE6NoMore images and store them on local server.
98
+ * Further localizations
99
+
100
+
101
+ == Copyright
102
+
103
+ Copyright (c) 2009 kematzy. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,99 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "sinatra-ie6nomore"
8
+ gem.summary = %Q{'IE6 No More' Sinatra Extension to make the eradication of IE6 easier}
9
+ gem.email = "kematzy@gmail.com"
10
+ gem.homepage = "http://github.com/kematzy/sinatra-ie6nomore"
11
+ gem.authors = ["kematzy"]
12
+ gem.add_dependency('sinatra', '>= 0.9.2')
13
+ gem.add_development_dependency('spec', '>= 1.2.7')
14
+ gem.add_development_dependency('rspec_hpricot_matchers', '>= 1.0.0')
15
+
16
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
+ end
18
+
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
21
+ end
22
+
23
+ require 'spec/rake/spectask'
24
+ Spec::Rake::SpecTask.new(:spec) do |spec|
25
+ spec.libs << 'lib' << 'spec'
26
+ spec.spec_files = FileList['spec/**/*_spec.rb']
27
+ end
28
+
29
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
30
+ spec.libs << 'lib' << 'spec'
31
+ spec.pattern = 'spec/**/*_spec.rb'
32
+ spec.rcov = true
33
+ end
34
+
35
+
36
+ namespace :spec do
37
+
38
+ desc "Run all specifications verbosely"
39
+ Spec::Rake::SpecTask.new(:verbose) do |t|
40
+ t.libs << "lib"
41
+ t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
42
+ end
43
+
44
+ desc "Run specific spec verbosely (SPEC=/path/2/file)"
45
+ Spec::Rake::SpecTask.new(:select) do |t|
46
+ t.libs << "lib"
47
+ t.spec_files = [ENV["SPEC"]]
48
+ t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
49
+ end
50
+
51
+ end
52
+
53
+ task :default => :spec
54
+
55
+ require 'rake/rdoctask'
56
+ Rake::RDocTask.new do |rdoc|
57
+ if File.exist?('VERSION.yml')
58
+ config = YAML.load(File.read('VERSION.yml'))
59
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
60
+ else
61
+ version = ""
62
+ end
63
+
64
+ rdoc.rdoc_dir = 'rdoc'
65
+ rdoc.title = "sinatra-ie6nomore #{version}"
66
+ rdoc.rdoc_files.include('README*')
67
+ rdoc.rdoc_files.include('lib/**/*.rb')
68
+ end
69
+
70
+ desc 'Build the rdoc HTML Files'
71
+ task :docs do
72
+ if File.exist?('VERSION')
73
+ version = File.read('VERSION')
74
+ else
75
+ version = "undefined"
76
+ end
77
+
78
+ sh "sdoc -N --title 'Sinatra::IE6NoMore v#{version}' lib/sinatra README.rdoc"
79
+ end
80
+
81
+
82
+ namespace :docs do
83
+
84
+ desc 'Remove rdoc products'
85
+ task :remove => [:clobber_rdoc]
86
+
87
+ desc 'Force a rebuild of the RDOC files'
88
+ task :rebuild => [:rerdoc]
89
+
90
+ desc 'Build docs, and open in browser for viewing (specify BROWSER)'
91
+ task :open => [:docs] do
92
+ browser = ENV["BROWSER"] || "safari"
93
+ sh "open -a #{browser} doc/index.html"
94
+ end
95
+
96
+ end
97
+
98
+
99
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,206 @@
1
+ ## IE6 NO MORE Localizations File
2
+ ##
3
+ ##
4
+ ##
5
+
6
+ # ENGLISH
7
+ en:
8
+ header: "You are using an outdated browser"
9
+ sub: "For a better experience using this site, please upgrade to a modern web browser."
10
+ close: "Close this notice"
11
+ get: Get
12
+ ie_url: "http://www.browserforthebetter.com/download.html"
13
+ ff_url: "http://getfirefox.com/"
14
+ safari_url: "http://www.apple.com/safari/download/"
15
+ chrome_url: "http://www.google.com/chrome"
16
+
17
+ # SPANISH
18
+ es:
19
+ header: "Usted está usando un navegador obsoleto."
20
+ sub: "Para navegar mejor por este sitio, por favor, actualice su navegador."
21
+ close: "Cierra este aviso"
22
+ get: Consiga
23
+ ie_url: "http://www.microsoft.com/downloads/details.aspx?FamilyID=341c2ad5-8c3d-4347-8c03-08cdecd8852b&DisplayLang=es"
24
+ ff_url: "http://www.mozilla-europe.org/es/firefox/"
25
+ safari_url: "http://www.apple.com/es/safari/download/"
26
+ chrome_url: "http://www.google.com/chrome?hl=es"
27
+
28
+ # French
29
+ fr:
30
+ header: "Vous utilisez un navigateur dépassé depuis près de 8 ans!"
31
+ sub: "Pour une meilleure expérience web, prenez le temps de mettre votre navigateur à jour."
32
+ close: "Fermez cette notification"
33
+ get: Obtenez
34
+ ie_url: "http://www.microsoft.com/downloads/details.aspx?FamilyID=341c2ad5-8c3d-4347-8c03-08cdecd8852b&DisplayLang=fr"
35
+ ff_url: "http://fr.www.mozilla.com/fr/"
36
+ safari_url: "http://www.apple.com/fr/safari/download/"
37
+ chrome_url: "http://www.google.com/chrome?hl=fr"
38
+
39
+ # Portugese
40
+ br:
41
+ header: "Você está usando um navegador desatualizado"
42
+ sub: "Para navegar melhor neste site, por favor, atualize seu navegador."
43
+ close: "Feche esta observação"
44
+ get: Obtenha
45
+ ie_url: "http://www.microsoft.com/downloads/details.aspx?FamilyID=341c2ad5-8c3d-4347-8c03-08cdecd8852b&DisplayLang=pt-br"
46
+ ff_url: "http://pt-br.www.mozilla.com/pt-BR/"
47
+ safari_url: "http://www.apple.com/br/safari/download/"
48
+ chrome_url: "http://www.google.com/chrome?hl=pt-BR"
49
+
50
+ # Italian
51
+ it:
52
+ header: "Stai usando un browser obsoleto"
53
+ sub: "Per una migliore navigazione su questo sito, per cortesia passa ad un browser di ultima generazione."
54
+ close: "Chiuda questo avviso"
55
+ get: Ottenga
56
+ ie_url: "http://www.microsoft.com/downloads/details.aspx?FamilyID=341c2ad5-8c3d-4347-8c03-08cdecd8852b&DisplayLang=it"
57
+ ff_url: "http://www.mozilla-europe.org/it/"
58
+ safari_url: "http://www.apple.com/it/safari/download/"
59
+ chrome_url: "http://www.google.com/chrome?hl=it"
60
+
61
+ # Japanese
62
+ jp:
63
+ header: ">あなたは旧式ブラウザをご利用中です"
64
+ sub: "このウェブサイトを快適に閲覧するにはブラウザをアップグレードしてください。"
65
+ close: "この注意を閉じなさい"
66
+ get: Get
67
+ ie_url: "http://www.microsoft.com/downloads/details.aspx?FamilyID=341c2ad5-8c3d-4347-8c03-08cdecd8852b&DisplayLang=ja"
68
+ ff_url: "http://www.mozilla.jp/"
69
+ safari_url: "http://www.apple.com/jp/safari/download/"
70
+ chrome_url: "http://www.google.com/chrome?hl=ja"
71
+
72
+ # Swedish
73
+ se:
74
+ header: "Du använder en föråldrad webbläsare"
75
+ sub: "För en bättre upplevelse på denna webbplats, vänligen byt till en modern webbläsare."
76
+ close: "Stäng denna notering"
77
+ get: "Ladda ner"
78
+ ie_url: "http://www.microsoft.com/downloads/details.aspx?FamilyID=341c2ad5-8c3d-4347-8c03-08cdecd8852b&DisplayLang=sv-SE"
79
+ ff_url: "http://sv-se.www.mozilla.com/sv-SE/"
80
+ safari_url: "http://www.apple.com/se/safari/download/"
81
+ chrome_url: "http://www.google.com/chrome?hl=sv-SE"
82
+
83
+ ## AWAITING TRANSLATIONS::
84
+ #
85
+ # # Thai
86
+ # th:
87
+ # header: ""
88
+ # sub: ""
89
+ # close: ""
90
+ # get: ""
91
+ # ie_url: ""
92
+ # ff_url: ""
93
+ # safari_url: ""
94
+ # chrome_url: ""
95
+ #
96
+ # # Chinese
97
+ # ch:
98
+ # header: ""
99
+ # sub: ""
100
+ # close: ""
101
+ # get: ""
102
+ # ie_url: ""
103
+ # ff_url: ""
104
+ # safari_url: ""
105
+ # chrome_url: ""
106
+ #
107
+ # # Hungarian
108
+ # hu:
109
+ # header: ""
110
+ # sub: ""
111
+ # close: ""
112
+ # get: ""
113
+ # ie_url: ""
114
+ # ff_url: ""
115
+ # safari_url: ""
116
+ # chrome_url: ""
117
+ #
118
+ # # Dutch
119
+ # nl:
120
+ # header: ""
121
+ # sub: ""
122
+ # close: ""
123
+ # get: ""
124
+ # ie_url: ""
125
+ # ff_url: ""
126
+ # safari_url: ""
127
+ # chrome_url: ""
128
+ #
129
+ # # Polish
130
+ # po:
131
+ # header: ""
132
+ # sub: ""
133
+ # close: ""
134
+ # get: ""
135
+ # ie_url: ""
136
+ # ff_url: ""
137
+ # safari_url: ""
138
+ # chrome_url: ""
139
+ #
140
+ # # Danish
141
+ # da:
142
+ # header: ""
143
+ # sub: ""
144
+ # close: ""
145
+ # get: ""
146
+ # ie_url: ""
147
+ # ff_url: ""
148
+ # safari_url: ""
149
+ # chrome_url: ""
150
+ #
151
+ # # German
152
+ # de:
153
+ # header: ""
154
+ # sub: ""
155
+ # close: ""
156
+ # get: ""
157
+ # ie_url: ""
158
+ # ff_url: ""
159
+ # safari_url: ""
160
+ # chrome_url: ""
161
+ #
162
+ # # Russian
163
+ # ru:
164
+ # header: ""
165
+ # sub: ""
166
+ # close: ""
167
+ # get: ""
168
+ # ie_url: ""
169
+ # ff_url: ""
170
+ # safari_url: ""
171
+ # chrome_url: ""
172
+ #
173
+ # # Arabic
174
+ # arabic:
175
+ # header: ""
176
+ # sub: ""
177
+ # close: ""
178
+ # get: ""
179
+ # ie_url: ""
180
+ # ff_url: ""
181
+ # safari_url: ""
182
+ # chrome_url: ""
183
+ #
184
+ # # Farsi
185
+ # farsi:
186
+ # header: ""
187
+ # sub: ""
188
+ # close: ""
189
+ # get: ""
190
+ # ie_url: ""
191
+ # ff_url: ""
192
+ # safari_url: ""
193
+ # chrome_url: ""
194
+ #
195
+ # # Hebrew
196
+ # he:
197
+ # header: ""
198
+ # sub: ""
199
+ # close: ""
200
+ # get: ""
201
+ # ie_url: ""
202
+ # ff_url: ""
203
+ # safari_url: ""
204
+ # chrome_url: ""
205
+ #
206
+
@@ -0,0 +1,156 @@
1
+ require 'sinatra/base'
2
+ require 'yaml'
3
+
4
+ module Sinatra
5
+
6
+ # = Sinatra::IE6NoMore Extension
7
+ #
8
+ # A simple extension in support of the IE6 No More[www.ie6nomore.com] campaign to rid the world of
9
+ # the nasty bug ridden monstrosity called IE6.
10
+ #
11
+ # Check the IE6 No More[www.ie6nomore.com] site for more information.
12
+ #
13
+ # === Install
14
+ #
15
+ #
16
+ # sudo gem install kematzy-sinatra-ie6nomore
17
+ #
18
+ # === Usage
19
+ #
20
+ # Three steps
21
+ #
22
+ # ==== Step 1
23
+ #
24
+ # Require the Sinatra::IE6NoMore gem
25
+ #
26
+ # require 'sinatra/base'
27
+ #
28
+ # require 'sinatra/ie6nomore'
29
+ #
30
+ # ==== Step 2
31
+ #
32
+ # Include in your app.
33
+ #
34
+ # class MyApp < Sinatra::Application
35
+ #
36
+ # helpers Sinatra::IE6NoMore
37
+ #
38
+ # <snip...>
39
+ #
40
+ # end
41
+ #
42
+ #
43
+ # ==== Step 3
44
+ #
45
+ # Add this to your <tt>/views/layout.erb</tt> file.
46
+ #
47
+ # <html>
48
+ # <body>
49
+ #
50
+ # <%= ie6nomore %>
51
+ #
52
+ # </body>
53
+ # </html>
54
+ #
55
+ # And in your HTML you'll see an output like this:
56
+ #
57
+ # <!--[if lt IE 7]>
58
+ # <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="http://www.ie6nomore.com/files/theme/ie6nomore-cornerx.jpg" style="border: none;" alt="Close this notice"/></a></div>
60
+ # <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="http://www.ie6nomore.com/files/theme/ie6nomore-warning.jpg" alt="Warning!"/></div>
62
+ # <div style="width: 275px; float: left; font-family: Arial, sans-serif;">
63
+ # <div style="font-size: 14px; font-weight: bold; margin-top: 12px;">You are using an outdated browser</div>
64
+ # <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
+ # </div>
66
+ # <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>
67
+ # <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>
68
+ # <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>
69
+ # <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>
70
+ # </div>
71
+ # </div>
72
+ # <![endif]-->
73
+ #
74
+ #
75
+ # See documentation below for further usage examples.
76
+ #
77
+ #
78
+ module IE6NoMore
79
+
80
+ VERSION = '0.1.0' unless const_defined?(:VERSION)
81
+ def self.version; "Sinatra::IE6NoMore v#{VERSION}"; end
82
+
83
+ ##
84
+ # Outputs the "IE6 No More" banner.
85
+ #
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
+ #
95
+ # ==== Examples
96
+ #
97
+ # ie6_no_more(:locale => :es ) => Spanish version
98
+ #
99
+ # ie6_no_more(:img_host => "http://www.example.com/images/ie6") => different image host
100
+ #
101
+ # ie6_no_more(:border => "2px dashed green", :background => 'black', :text_color => 'white' )
102
+ # => different color scheme for text, border & background colors
103
+ #
104
+ # @api public
105
+ def ie6_no_more(options = {})
106
+ o = {
107
+ :locale => :en,
108
+ :img_host => "http://www.ie6nomore.com/files/theme",
109
+ :border => "1px solid #F7941D",
110
+ :background => "#FEEFDA",
111
+ :text_color => "black",
112
+ }.merge(options)
113
+
114
+ localizations = load_i18n
115
+ # set the localisation
116
+ i18n = localizations[o[:locale].to_s]
117
+
118
+ html = %Q[<!--[if lt IE 7]>\n]
119
+ html << %Q[<div style="border: #{o[:border]}; background: #{o[:background]}; text-align: center; clear: both; height: 75px; position: relative;">\n]
120
+ 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]
121
+ html << %Q[ <div style="width: 640px; margin: 0 auto; text-align: left; padding: 0; overflow: hidden; color: #{o[:text_color]};">\n]
122
+ html << %Q[ <div style="width: 75px; float: left;"><img src="#{o[:img_host]}/ie6nomore-warning.jpg" alt="Warning!"/></div>\n]
123
+ html << %Q[ <div style="width: 275px; float: left; font-family: Arial, sans-serif;">\n]
124
+ html << %Q[ <div style="font-size: 14px; font-weight: bold; margin-top: 12px;">#{i18n['header']}</div>\n]
125
+ html << %Q[ <div style="font-size: 12px; margin-top: 6px; line-height: 12px;">#{i18n['sub']}</div>\n]
126
+ html << %Q[ </div>\n]
127
+ 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]
128
+ 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]
129
+ 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]
130
+ 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]
131
+ html << %Q[ </div>\n]
132
+ html << %Q[</div>\n<![endif]-->\n]
133
+ html
134
+ end
135
+
136
+
137
+ private
138
+
139
+ ##
140
+ # Loads the i18n.yml localizations file and returns a Hash
141
+ #
142
+ # ==== Examples
143
+ #
144
+ # localizations = load_i18n
145
+ #
146
+ # @api private
147
+ def load_i18n
148
+ res = YAML.load_file(File.join(File.dirname(__FILE__), 'ie6nomore.i18n.yml'))
149
+ end
150
+
151
+
152
+ end #/ IE6NoMore
153
+
154
+ helpers IE6NoMore
155
+
156
+ end #/ Sinatra
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "SinatraIe6nomore" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,280 @@
1
+ require "#{File.dirname(File.dirname(File.expand_path(__FILE__)))}/spec_helper"
2
+
3
+ describe "Sinatra" do
4
+
5
+ describe "IE6NoMore" do
6
+
7
+ def remove_enclosing_html_comments(markup)
8
+ return markup.sub('<!--[if lt IE 7]>', '').sub('<![endif]-->','')
9
+ end
10
+
11
+ describe "ie6_no_more" do
12
+
13
+ describe "with defaults" do
14
+
15
+ it "should return the expected HTML" do
16
+ erb_app %Q[<%= ie6_no_more %>]
17
+ markup = last_response.body
18
+ # markup.should have_tag('debug')
19
+ # test the comments first before removing
20
+ markup.should match(/<!--\[if lt IE 7\]/)
21
+ markup.should match(/<!\[endif\]-->$/)
22
+
23
+ # remove the comments so we can test the code output
24
+ markup = remove_enclosing_html_comments(markup)
25
+ # markup.should have_tag('debug')
26
+
27
+ # we get the border and background through OK
28
+ markup.should match(/<div style="border: 1px solid #F7941D; background: #FEEFDA;/)
29
+
30
+ # we have a warning image
31
+ markup.should have_tag('div[@style=width: 75px; float: left;] > img') do |img|
32
+ img.attributes['src'].should == 'http://www.ie6nomore.com/files/theme/ie6nomore-warning.jpg'
33
+ end
34
+
35
+ markup.should have_tag('img[@src=http://www.ie6nomore.com/files/theme/ie6nomore-cornerx.jpg]')
36
+
37
+ # text
38
+ markup.should have_tag('img[@alt=Close this notice]')
39
+ markup.should have_tag('div[@style=font-size: 14px; font-weight: bold; margin-top: 12px;]','You are using an outdated browser')
40
+ 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
+ # browsers
43
+ markup.should have_tag('div > a[@href=http://getfirefox.com/] > img') do |img|
44
+ img.attributes['src'].should == 'http://www.ie6nomore.com/files/theme/ie6nomore-firefox.jpg'
45
+ img.attributes['alt'].should == 'Get Firefox 3.5'
46
+ end
47
+ markup.should have_tag('div > a[@href=http://www.browserforthebetter.com/download.html] > img') do |img|
48
+ img.attributes['src'].should == 'http://www.ie6nomore.com/files/theme/ie6nomore-ie8.jpg'
49
+ img.attributes['alt'].should == 'Get Internet Explorer 8'
50
+ end
51
+ markup.should have_tag('div > a[@href=http://www.apple.com/safari/download/] > img') do |img|
52
+ img.attributes['src'].should == 'http://www.ie6nomore.com/files/theme/ie6nomore-safari.jpg'
53
+ img.attributes['alt'].should == 'Get Safari 4'
54
+ end
55
+ markup.should have_tag('div > a[@href=http://www.google.com/chrome] > img') do |img|
56
+ img.attributes['src'].should == 'http://www.ie6nomore.com/files/theme/ie6nomore-chrome.jpg'
57
+ img.attributes['alt'].should == 'Get Google Chrome'
58
+ end
59
+
60
+ end
61
+
62
+ end #/ with defaults
63
+
64
+ describe "with options" do
65
+
66
+ 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' ) %>]
68
+ # remove the comments so we can test the code output
69
+ @markup = remove_enclosing_html_comments(last_response.body)
70
+ # @markup.should have_tag('debug')
71
+ end
72
+
73
+ it "should set the border style attribute" do
74
+ @markup.should match(/<div style="border: 10px dashed #fff; background: yellow;/)
75
+ end
76
+
77
+ it "should set the background style attribute" do
78
+ @markup.should match(/<div style="(.*)background: yellow;/)
79
+ end
80
+
81
+ it "should set the text color style attribute" do
82
+ @markup.should match(/<div style="(.*)color: red;/)
83
+ end
84
+
85
+ it "should set the image src attributes to the value given by img_host" do
86
+ @markup.should have_tag('img[@src=http://example.com/images/ie6nomore-cornerx.jpg]')
87
+ end
88
+
89
+ end #/ with options
90
+
91
+
92
+ describe "with localizations" do
93
+
94
+ it "should have Spanish version" do
95
+ erb_app %Q[<%= ie6_no_more(:locale => :es ) %>]
96
+ # remove the comments so we can test the code output
97
+ markup = remove_enclosing_html_comments(last_response.body)
98
+ # markup.should have_tag('debug')
99
+
100
+ # text
101
+ markup.should have_tag('img[@alt=Cierra este aviso]')
102
+ markup.should have_tag('div[@style=font-size: 14px; font-weight: bold; margin-top: 12px;]','Usted está usando un navegador obsoleto.')
103
+ markup.should have_tag('div[@style=font-size: 12px; margin-top: 6px; line-height: 12px;]','Para navegar mejor por este sitio, por favor, actualice su navegador.')
104
+
105
+ # browsers
106
+ markup.should have_tag('div > a[@href=http://www.mozilla-europe.org/es/firefox/] > img') do |img|
107
+ img.attributes['src'].should == 'http://www.ie6nomore.com/files/theme/ie6nomore-firefox.jpg'
108
+ img.attributes['alt'].should == 'Consiga Firefox 3.5'
109
+ end
110
+ 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|
111
+ img.attributes['src'].should == 'http://www.ie6nomore.com/files/theme/ie6nomore-ie8.jpg'
112
+ img.attributes['alt'].should == 'Consiga Internet Explorer 8'
113
+ end
114
+ markup.should have_tag('div > a[@href=http://www.apple.com/es/safari/download/] > img') do |img|
115
+ img.attributes['src'].should == 'http://www.ie6nomore.com/files/theme/ie6nomore-safari.jpg'
116
+ img.attributes['alt'].should == 'Consiga Safari 4'
117
+ end
118
+ markup.should have_tag('div > a[@href=http://www.google.com/chrome?hl=es] > img') do |img|
119
+ img.attributes['src'].should == 'http://www.ie6nomore.com/files/theme/ie6nomore-chrome.jpg'
120
+ img.attributes['alt'].should == 'Consiga Google Chrome'
121
+ end
122
+ end
123
+
124
+ it "should have French version" do
125
+ erb_app %Q[<%= ie6_no_more(:locale => :fr ) %>]
126
+ # remove the comments so we can test the code output
127
+ markup = remove_enclosing_html_comments(last_response.body)
128
+ # markup.should have_tag('debug')
129
+
130
+ # text
131
+ markup.should have_tag('img[@alt=Fermez cette notification]')
132
+ markup.should have_tag('div[@style=font-size: 14px; font-weight: bold; margin-top: 12px;]','Vous utilisez un navigateur dépassé depuis près de 8 ans!')
133
+ markup.should have_tag('div[@style=font-size: 12px; margin-top: 6px; line-height: 12px;]','Pour une meilleure expérience web, prenez le temps de mettre votre navigateur à jour.')
134
+
135
+ # browsers
136
+ markup.should have_tag('div > a[@href=http://fr.www.mozilla.com/fr/] > img') do |img|
137
+ img.attributes['alt'].should == 'Obtenez Firefox 3.5'
138
+ end
139
+ markup.should have_tag('div > a[@href=http://www.microsoft.com/downloads/details.aspx?FamilyID=341c2ad5-8c3d-4347-8c03-08cdecd8852b&DisplayLang=fr] > img') do |img|
140
+ img.attributes['alt'].should == 'Obtenez Internet Explorer 8'
141
+ end
142
+ markup.should have_tag('div > a[@href=http://www.apple.com/fr/safari/download/] > img') do |img|
143
+ img.attributes['alt'].should == 'Obtenez Safari 4'
144
+ end
145
+ markup.should have_tag('div > a[@href=http://www.google.com/chrome?hl=fr] > img') do |img|
146
+ img.attributes['alt'].should == 'Obtenez Google Chrome'
147
+ end
148
+ end
149
+
150
+ it "should have Portugese version" do
151
+ erb_app %Q[<%= ie6_no_more(:locale => :br ) %>]
152
+ # remove the comments so we can test the code output
153
+ markup = remove_enclosing_html_comments(last_response.body)
154
+ # markup.should have_tag('debug')
155
+
156
+ # text
157
+ markup.should have_tag('img[@alt=Feche esta observação]')
158
+ markup.should have_tag('div[@style=font-size: 14px; font-weight: bold; margin-top: 12px;]','Você está usando um navegador desatualizado')
159
+ markup.should have_tag('div[@style=font-size: 12px; margin-top: 6px; line-height: 12px;]','Para navegar melhor neste site, por favor, atualize seu navegador.')
160
+
161
+ # browsers
162
+ markup.should have_tag('div > a[@href=http://pt-br.www.mozilla.com/pt-BR/] > img') do |img|
163
+ img.attributes['alt'].should == 'Obtenha Firefox 3.5'
164
+ end
165
+ markup.should have_tag('div > a[@href=http://www.microsoft.com/downloads/details.aspx?FamilyID=341c2ad5-8c3d-4347-8c03-08cdecd8852b&DisplayLang=pt-br] > img') do |img|
166
+ img.attributes['alt'].should == 'Obtenha Internet Explorer 8'
167
+ end
168
+ markup.should have_tag('div > a[@href=http://www.apple.com/br/safari/download/] > img') do |img|
169
+ img.attributes['alt'].should == 'Obtenha Safari 4'
170
+ end
171
+ markup.should have_tag('div > a[@href=http://www.google.com/chrome?hl=pt-BR] > img') do |img|
172
+ img.attributes['alt'].should == 'Obtenha Google Chrome'
173
+ end
174
+ end
175
+
176
+ it "should have Italian version" do
177
+ erb_app %Q[<%= ie6_no_more(:locale => :it ) %>]
178
+ # remove the comments so we can test the code output
179
+ markup = remove_enclosing_html_comments(last_response.body)
180
+ # markup.should have_tag('debug')
181
+
182
+ # text
183
+ markup.should have_tag('img[@alt=Chiuda questo avviso]')
184
+ markup.should have_tag('div[@style=font-size: 14px; font-weight: bold; margin-top: 12px;]','Stai usando un browser obsoleto')
185
+ markup.should have_tag('div[@style=font-size: 12px; margin-top: 6px; line-height: 12px;]','Per una migliore navigazione su questo sito, per cortesia passa ad un browser di ultima generazione.')
186
+
187
+ # browsers
188
+ markup.should have_tag('div > a[@href=http://www.mozilla-europe.org/it/] > img') do |img|
189
+ img.attributes['alt'].should == 'Ottenga Firefox 3.5'
190
+ end
191
+ markup.should have_tag('div > a[@href=http://www.microsoft.com/downloads/details.aspx?FamilyID=341c2ad5-8c3d-4347-8c03-08cdecd8852b&DisplayLang=it] > img') do |img|
192
+ img.attributes['alt'].should == 'Ottenga Internet Explorer 8'
193
+ end
194
+ markup.should have_tag('div > a[@href=http://www.apple.com/it/safari/download/] > img') do |img|
195
+ img.attributes['alt'].should == 'Ottenga Safari 4'
196
+ end
197
+ markup.should have_tag('div > a[@href=http://www.google.com/chrome?hl=it] > img') do |img|
198
+ img.attributes['alt'].should == 'Ottenga Google Chrome'
199
+ end
200
+ end
201
+
202
+ it "should have Japanese version" do
203
+ erb_app %Q[<%= ie6_no_more(:locale => :jp ) %>]
204
+ # remove the comments so we can test the code output
205
+ markup = remove_enclosing_html_comments(last_response.body)
206
+ # markup.should have_tag('debug')
207
+
208
+ # text
209
+ markup.should have_tag('img[@alt=この注意を閉じなさい]')
210
+ markup.should have_tag('div[@style=font-size: 14px; font-weight: bold; margin-top: 12px;]','>あなたは旧式ブラウザをご利用中です')
211
+ markup.should have_tag('div[@style=font-size: 12px; margin-top: 6px; line-height: 12px;]','このウェブサイトを快適に閲覧するにはブラウザをアップグレードしてください。')
212
+
213
+ # browsers
214
+ markup.should have_tag('div > a[@href=http://www.mozilla.jp/] > img') do |img|
215
+ img.attributes['alt'].should == 'Get Firefox 3.5'
216
+ end
217
+ markup.should have_tag('div > a[@href=http://www.microsoft.com/downloads/details.aspx?FamilyID=341c2ad5-8c3d-4347-8c03-08cdecd8852b&DisplayLang=ja] > img') do |img|
218
+ img.attributes['alt'].should == 'Get Internet Explorer 8'
219
+ end
220
+ markup.should have_tag('div > a[@href=http://www.apple.com/jp/safari/download/] > img') do |img|
221
+ img.attributes['alt'].should == 'Get Safari 4'
222
+ end
223
+ markup.should have_tag('div > a[@href=http://www.google.com/chrome?hl=ja] > img') do |img|
224
+ img.attributes['alt'].should == 'Get Google Chrome'
225
+ end
226
+ end
227
+
228
+ it "should have Swedish version" do
229
+ erb_app %Q[<%= ie6_no_more(:locale => :se ) %>]
230
+ # remove the comments so we can test the code output
231
+ markup = remove_enclosing_html_comments(last_response.body)
232
+ # markup.should have_tag('debug')
233
+
234
+ # text
235
+ markup.should have_tag('img[@alt=Stäng denna notering]')
236
+ markup.should have_tag('div[@style=font-size: 14px; font-weight: bold; margin-top: 12px;]','Du använder en föråldrad webbläsare')
237
+ markup.should have_tag('div[@style=font-size: 12px; margin-top: 6px; line-height: 12px;]','För en bättre upplevelse på denna webbplats, vänligen byt till en modern webbläsare.')
238
+
239
+ # browsers
240
+ markup.should have_tag('div > a[@href=http://sv-se.www.mozilla.com/sv-SE/] > img') do |img|
241
+ img.attributes['alt'].should == 'Ladda ner Firefox 3.5'
242
+ end
243
+ markup.should have_tag('div > a[@href=http://www.microsoft.com/downloads/details.aspx?FamilyID=341c2ad5-8c3d-4347-8c03-08cdecd8852b&DisplayLang=sv-SE] > img') do |img|
244
+ img.attributes['alt'].should == 'Ladda ner Internet Explorer 8'
245
+ end
246
+ markup.should have_tag('div > a[@href=http://www.apple.com/se/safari/download/] > img') do |img|
247
+ img.attributes['alt'].should == 'Ladda ner Safari 4'
248
+ end
249
+ markup.should have_tag('div > a[@href=http://www.google.com/chrome?hl=sv-SE] > img') do |img|
250
+ img.attributes['alt'].should == 'Ladda ner Google Chrome'
251
+ end
252
+ end
253
+
254
+ it "should have further localizations" do
255
+ pending "awaiting translations from www.ie6nomore.com"
256
+ end
257
+
258
+ end #/ with localizations
259
+
260
+ end #/ ie6_no_more
261
+
262
+ describe "#load_i18n" do
263
+
264
+ module Sinatra::IE6NoMore
265
+ public :load_i18n
266
+ end
267
+
268
+ it "should return a Hash" do
269
+ app.load_i18n.should be_a_kind_of(Hash)
270
+ end
271
+
272
+ it "should have further tests" do
273
+ pending "energy and time to fix this...."
274
+ end
275
+
276
+ end #/ #load_i18n
277
+
278
+ end #/ IE6NoMore
279
+
280
+ end #/ Sinatra
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ require 'spec/interop/test'
4
+ require 'rack/test'
5
+ require 'rspec_hpricot_matchers'
6
+
7
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
8
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
9
+ require 'sinatra/ie6nomore'
10
+
11
+ Spec::Runner.configure do |config|
12
+ config.include RspecHpricotMatchers
13
+ end
14
+
15
+ class MyTestApp < Sinatra::Base
16
+
17
+ helpers Sinatra::IE6NoMore
18
+
19
+ get '/tests' do
20
+ case params[:engine]
21
+ when 'erb'
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
29
+
30
+ end #/class MyTestApp
31
+
32
+
33
+
34
+ class Test::Unit::TestCase
35
+ include Rack::Test::Methods
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
+
50
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sinatra-ie6nomore
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - kematzy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-18 00:00:00 +08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: sinatra
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.9.2
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: spec
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.7
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: rspec_hpricot_matchers
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.0
44
+ version:
45
+ description:
46
+ email: kematzy@gmail.com
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - LICENSE
53
+ - README.rdoc
54
+ files:
55
+ - .document
56
+ - .gitignore
57
+ - LICENSE
58
+ - README.rdoc
59
+ - Rakefile
60
+ - VERSION
61
+ - lib/sinatra/ie6nomore.i18n.yml
62
+ - lib/sinatra/ie6nomore.rb
63
+ - spec/sinatra-ie6nomore_spec.rb
64
+ - spec/sinatra/ie6nomore_spec.rb
65
+ - spec/spec_helper.rb
66
+ has_rdoc: true
67
+ homepage: http://github.com/kematzy/sinatra-ie6nomore
68
+ licenses: []
69
+
70
+ post_install_message:
71
+ rdoc_options:
72
+ - --charset=UTF-8
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ version:
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: "0"
86
+ version:
87
+ requirements: []
88
+
89
+ rubyforge_project:
90
+ rubygems_version: 1.3.5
91
+ signing_key:
92
+ specification_version: 3
93
+ summary: "'IE6 No More' Sinatra Extension to make the eradication of IE6 easier"
94
+ test_files:
95
+ - spec/sinatra/ie6nomore_spec.rb
96
+ - spec/sinatra-ie6nomore_spec.rb
97
+ - spec/spec_helper.rb