browser_warrior 0.1.0
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +69 -0
- data/Rakefile +37 -0
- data/app/assets/images/browser_warrior/chrome.png +0 -0
- data/app/assets/images/browser_warrior/firefox.png +0 -0
- data/app/assets/images/browser_warrior/ie.png +0 -0
- data/app/assets/images/browser_warrior/opera.png +0 -0
- data/app/assets/stylesheets/browser_warrior/application.scss +78 -0
- data/app/views/browser_warrior/index.html.erb +51 -0
- data/lib/browser_warrior.rb +41 -0
- data/lib/browser_warrior/engine.rb +11 -0
- data/lib/browser_warrior/version.rb +3 -0
- data/lib/generators/browser_warrior/install/USAGE +8 -0
- data/lib/generators/browser_warrior/install/install_generator.rb +12 -0
- data/lib/generators/browser_warrior/install/templates/browser_warrior.rb +9 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f97c57cb27ab03816722a3b38d19ce3010264a27
|
4
|
+
data.tar.gz: cb3987c4df2ff6a093c5cb9a0bcc25667ae87549
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 35a20cc3858ab6f1d5e107440f9de2aebc4838994f6515e9bf90a18b3bf36f9611ef06e36b6be7557a3e1599fb6ef321cf1b692da73ba64cd6897ab890b14341
|
7
|
+
data.tar.gz: aa7d7d0b4d25bd6f0f892a68b40d73a1dce5267ef0401b9457135a0915dec7e64616f8902fc48f01e0a4c8f33b004f2f46461b689b109b903105970278b8e58a
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2016 yafeilee
|
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.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# BrowserWarrior
|
2
|
+
|
3
|
+
Are you a warrior to reject your ie 6/7/8 user?
|
4
|
+
|
5
|
+
Yes, we should say YES.
|
6
|
+
|
7
|
+
**BrowserWarrior** make it super easy.
|
8
|
+
|
9
|
+
Make your Ruby on Rails Application rejecting ie6/7/8 with only one line code.
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
# in your Gemfile
|
13
|
+
gem 'browser_warrior'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then:
|
17
|
+
```bash
|
18
|
+
$ bundle
|
19
|
+
```
|
20
|
+
|
21
|
+
No need more code!!
|
22
|
+
|
23
|
+
Then all of ie 6/7/8 user will be rejected to a page that suggests upgrading their browsers.
|
24
|
+
|
25
|
+
Upgrading browser screenshot
|
26
|
+

|
27
|
+
|
28
|
+
## More configuration
|
29
|
+
|
30
|
+
**QA**: Can I add more unsupported browsers?
|
31
|
+
|
32
|
+
Very easy. Execute:
|
33
|
+
|
34
|
+
```bash
|
35
|
+
$ rails g browser_warrior:install
|
36
|
+
```
|
37
|
+
|
38
|
+
It will generate `browser_warrior.rb` in `config/initializers/`.
|
39
|
+
|
40
|
+
Edit it.
|
41
|
+
|
42
|
+
There is a `browser` object that you can easily custom your requirement.
|
43
|
+
|
44
|
+
See more: <https://github.com/fnando/browser#usage>
|
45
|
+
|
46
|
+
**QA**: Can I custom the suggested browser page?
|
47
|
+
|
48
|
+
Sure. Execute:
|
49
|
+
|
50
|
+
```bash
|
51
|
+
# We are doing more work on it
|
52
|
+
$ rails g browser_warrior:views
|
53
|
+
```
|
54
|
+
|
55
|
+
It will generate `view` and `css` files for you.
|
56
|
+
Then edit them.
|
57
|
+
|
58
|
+
Easy, is it?
|
59
|
+
|
60
|
+
## TODO
|
61
|
+
|
62
|
+
* i18n support
|
63
|
+
* extend support rails 4 or 3.
|
64
|
+
|
65
|
+
## Contributing
|
66
|
+
[windy](https://github.com/windy)
|
67
|
+
|
68
|
+
## License
|
69
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'BrowserWarrior'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
require 'bundler/gem_tasks'
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task default: :test
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,78 @@
|
|
1
|
+
.browser-warrior-mask {
|
2
|
+
position: fixed;
|
3
|
+
top: 0;
|
4
|
+
right: 0;
|
5
|
+
bottom: 0;
|
6
|
+
left: 0;
|
7
|
+
z-index: 100;
|
8
|
+
|
9
|
+
background: rgba(0,0,0,0.5);
|
10
|
+
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#CC000000', endColorstr='#CC000000',GradientType=0);
|
11
|
+
font: 12px/1.5 tahoma,arial,'Hiragino Sans GB',\5b8b\4f53,sans-serif;
|
12
|
+
color: #666;
|
13
|
+
}
|
14
|
+
.browser-warrior-mask a {
|
15
|
+
color: #09F;
|
16
|
+
text-decoration: none;
|
17
|
+
}
|
18
|
+
.browser-warrior-mask a:hover {
|
19
|
+
color: #F90;
|
20
|
+
}
|
21
|
+
.browser-warrior-dialog {
|
22
|
+
position: absolute;
|
23
|
+
top: 20%;
|
24
|
+
left: 50%;
|
25
|
+
margin-left: -340px;
|
26
|
+
padding: 40px;
|
27
|
+
background: #FAFAFA;
|
28
|
+
}
|
29
|
+
.browser-warrior-title {
|
30
|
+
font-size: 20px;
|
31
|
+
font-weight: normal;
|
32
|
+
margin: 0;
|
33
|
+
padding: 0;
|
34
|
+
}
|
35
|
+
.browser-warrior-para {
|
36
|
+
padding: 0;
|
37
|
+
margin: 15px 0;
|
38
|
+
zoom: 1;
|
39
|
+
}
|
40
|
+
.browser-warrior-para:after {
|
41
|
+
content: ' ';
|
42
|
+
display: block;
|
43
|
+
clear: both;
|
44
|
+
font-size: 0;
|
45
|
+
}
|
46
|
+
a.browser-warrior-browser-link {
|
47
|
+
float: left;
|
48
|
+
text-align: center;
|
49
|
+
padding: 12px;
|
50
|
+
color: #666;
|
51
|
+
}
|
52
|
+
a.browser-warrior-browser-link:hover {
|
53
|
+
background: #EEE;
|
54
|
+
}
|
55
|
+
.browser-warrior-browser-icon {
|
56
|
+
display: block;
|
57
|
+
margin-bottom: 5px;
|
58
|
+
font-style: normal;
|
59
|
+
width: 135px;
|
60
|
+
height: 135px;
|
61
|
+
cursor: pointer;
|
62
|
+
background-repeat: no-repeat;
|
63
|
+
background-position: center;
|
64
|
+
}
|
65
|
+
|
66
|
+
.browser-warrior-browser-icon-chrome {
|
67
|
+
background-image: asset-url('browser_warrior/chrome.png');
|
68
|
+
}
|
69
|
+
|
70
|
+
.browser-warrior-browser-icon-opera {
|
71
|
+
background-image: asset-url('browser_warrior/opera.png');
|
72
|
+
}
|
73
|
+
.browser-warrior-browser-icon-firefox {
|
74
|
+
background-image: asset-url('browser_warrior/firefox.png');
|
75
|
+
}
|
76
|
+
.browser-warrior-browser-icon-ie {
|
77
|
+
background-image: asset-url('browser_warrior/ie.png');
|
78
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>您的浏览器不被支持</title>
|
5
|
+
<%= stylesheet_link_tag "browser_warrior/application", media: "all" %>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div class="browser-warrior-mask">
|
9
|
+
<div class="browser-warrior-dialog" id="browser-warrior-dialog">
|
10
|
+
<div class="browser-warrior-text">
|
11
|
+
<h1 class="browser-warrior-title">您正在使用低版本的 IE 浏览器!</h1>
|
12
|
+
<p class="browser-warrior-para">
|
13
|
+
这可能会带来非常严重的安全隐患,并且不利于我们为您提供良好的用户体验。
|
14
|
+
</p>
|
15
|
+
<p class="browser-warrior-para">
|
16
|
+
使用非现代浏览器浏览本网站可能会遭遇文字错位,布局混乱,功能失灵等意外情况。
|
17
|
+
</p>
|
18
|
+
<p class="browser-warrior-para">
|
19
|
+
为了您的良好浏览体验,请安装以下浏览器:
|
20
|
+
</p>
|
21
|
+
<div class="browser-warrior-para">
|
22
|
+
<a class="browser-warrior-browser-link" href="http://www.baidu.com/s?wd=chrome" target="_blank" hidefocus>
|
23
|
+
<i class="browser-warrior-browser-icon browser-warrior-browser-icon-chrome"></i>
|
24
|
+
Chrome浏览器
|
25
|
+
</a>
|
26
|
+
<a class="browser-warrior-browser-link" href="http://www.firefox.com.cn/" target="_blank" hidefocus>
|
27
|
+
<i class="browser-warrior-browser-icon browser-warrior-browser-icon-firefox"></i>
|
28
|
+
Firefox浏览器
|
29
|
+
</a>
|
30
|
+
<a class="browser-warrior-browser-link" href="http://www.opera.com/zh-cn" target="_blank" hidefocus>
|
31
|
+
<i class="browser-warrior-browser-icon browser-warrior-browser-icon-opera"></i>
|
32
|
+
Opera浏览器
|
33
|
+
</a>
|
34
|
+
<a class="browser-warrior-browser-link" href="http://www.baidu.com/s?wd=ie" target="_blank" hidefocus>
|
35
|
+
<i class="browser-warrior-browser-icon browser-warrior-browser-icon-ie"></i>
|
36
|
+
升级IE到最新版本
|
37
|
+
</a>
|
38
|
+
</div>
|
39
|
+
<p class="browser-warrior-para">
|
40
|
+
如果您正在使用
|
41
|
+
<a href="http://ie.sogou.com/" target="_blank">搜狗浏览器</a>,
|
42
|
+
<a href="http://browser.qq.com/" target="_blank">QQ浏览器</a>,
|
43
|
+
<a href="http://www.liebao.cn/" target="_blank">猎豹浏览器</a>,
|
44
|
+
<a href="http://chrome.360.cn/" target="_blank">360极速浏览器</a>
|
45
|
+
等国产浏览器,您也可尝试将其切换到高速/极速模式
|
46
|
+
</p>
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
</div>
|
50
|
+
</body>
|
51
|
+
</html>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "browser_warrior/engine"
|
2
|
+
require 'browser/version'
|
3
|
+
require 'browser'
|
4
|
+
|
5
|
+
module BrowserWarrior
|
6
|
+
|
7
|
+
module Controllers
|
8
|
+
module Helpers
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
included do
|
11
|
+
before_action :check_browser_warrior! if BrowserWarrior.autoenable
|
12
|
+
end
|
13
|
+
|
14
|
+
def check_browser_warrior!
|
15
|
+
browser = ::Browser.new(request.user_agent)
|
16
|
+
if ! BrowserWarrior.do_detect(browser)
|
17
|
+
render 'browser_warrior/index', layout: false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
@detect_block = lambda do |browser|
|
24
|
+
if browser.ie?(6) or browser.ie?(7) or browser.ie?(8)
|
25
|
+
false
|
26
|
+
else
|
27
|
+
true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
@@autoenable = true
|
32
|
+
mattr_accessor :autoenable
|
33
|
+
|
34
|
+
def self.detect(&block)
|
35
|
+
@detect_block = block
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.do_detect(browser)
|
39
|
+
@detect_block.call(browser)
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module BrowserWarrior
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
desc "Create a browser_warrior initializer"
|
7
|
+
def copy_initializer
|
8
|
+
template "browser_warrior.rb", "config/initializers/browser_warrior.rb"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: browser_warrior
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- yafeilee
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sass-rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: browser
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sqlite3
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: byebug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: BrowserWarrior is a Ruby on Rails engine that let you reject your ie6/7/8
|
84
|
+
user just one line code
|
85
|
+
email:
|
86
|
+
- lyfi2003@gmail.com
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- MIT-LICENSE
|
92
|
+
- README.md
|
93
|
+
- Rakefile
|
94
|
+
- app/assets/images/browser_warrior/chrome.png
|
95
|
+
- app/assets/images/browser_warrior/firefox.png
|
96
|
+
- app/assets/images/browser_warrior/ie.png
|
97
|
+
- app/assets/images/browser_warrior/opera.png
|
98
|
+
- app/assets/stylesheets/browser_warrior/application.scss
|
99
|
+
- app/views/browser_warrior/index.html.erb
|
100
|
+
- lib/browser_warrior.rb
|
101
|
+
- lib/browser_warrior/engine.rb
|
102
|
+
- lib/browser_warrior/version.rb
|
103
|
+
- lib/generators/browser_warrior/install/USAGE
|
104
|
+
- lib/generators/browser_warrior/install/install_generator.rb
|
105
|
+
- lib/generators/browser_warrior/install/templates/browser_warrior.rb
|
106
|
+
homepage: https://github.com/80percent/browser_warrior
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.6.4
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Make your Rails app reject your ie 6/7/8 user just one line code
|
130
|
+
test_files: []
|