Skip to content

A Rails gem that rejects non-modern browsers with only one line code

License

Notifications You must be signed in to change notification settings

dao42/browser_warrior

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BrowserWarrior

Are you a warrior? Are you brave enough to reject your non-modern browser users?

It is time to say YES.

BrowserWarrior makes this super easy with one line of code.

Note: Only Ruby on Rails 5.x is supported at this time.

Note: Ruby on Rails 6.x is supported as well.

# in your Gemfile
gem 'browser_warrior', '~> 0.14.0'

And then:

$ bundle install

That's it.

All non-modern browser users will be redirected to a page that suggests they should upgrade their browsers.

Upgrading browser screenshot (en) screenshot

Upgrading browser screenshot (zh-CN) screenshot

Configuration

Question: Can I add more unsupported browsers?

Very easy. Run:

$ rails g browser_warrior:install

It will generate browser_warrior.rb in config/initializers/.

There is a browser object that you can easily customize.

See more: https://github.com/fnando/browser#usage

Question: Can I customize the suggested browser page?

Sure. Run:

$ rails g browser_warrior:views

It will generate view and css files for you that can be edited.

Nice and easy.

i18n

BrowserWarrior will render the correct page based on your i18n locale config. It currently supports en and zh-CN, and you can add more locale pages easily.

Advice

I suggest adding the code below to your base layout( e.g. application.html.erb ):

// app/layouts/application.html.erb
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="renderer" content="webkit" />

Roadmap

  • Release 0.11.0, support Ruby on Rails 6.x
  • Release 0.1.0, one line code to support rejecting old browser page
  • I18n support ( 0.3.0 )

Contributing

License

The gem is available as open source under the terms of the MIT License.

About

A Rails gem that rejects non-modern browsers with only one line code

Resources

License

Stars

Watchers

Forks

Packages

No packages published