Skip to content
This repository has been archived by the owner on Dec 3, 2018. It is now read-only.

eric1234/rack_new_window

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rack::NewWindow

Will open all external links and non-HTML links in a new window. Simple add as Rack middleware:

use Rack::NewWindow

There are a few options for this middleware:

local_domains

An array of all domains that should be considered local. The request domain is automatically included. This is just in case part of your site is hosted at a 3rd party. Domains comparison is done with include. So foo.com will make www.foo.com local. If the request domain starts with www. that prefix will be stripped off.

include_non_html

If true (the default) then all non-HTML links will also open in a new window. If a link has no extension it is assumed to be HTML.

In addition if the link has a “local” in the class attribute then it will be considered local regardless of domain or extension. This is a great way to override special cases.

If the link already has a “target” attribute it will be untouched.

Credit

This gem was developed by Eric Anderson (pixelwareinc.com).

About

Rack Middleware: Open all external and non-HTML links in a new window

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages