Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Wraps Rack::Static by adding useful headers to serve web fonts.
Ruby
tree: 8fb4d0fd14

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
lib
test
Changelog.md
Gemfile
LICENSE
README.md
RakeFile

README.md

rack-fonts

Rack::Static wrapper to give more love to web fonts.

Usage

This middleware merely wraps the Rack::Static one so it admits the same options:

:root => "public"

looks for all the assets under the public subdirectory of the current directory

:urls => ["/assets"]

intercepts the requests beginning with /media and tries to serve static files from the directory specified by the root option. (Note that you can indicate more that one URL in the urls option)

So, for instance:

use Rack::Fonts :root => 'public', :urls => ['/assets']

will respond to a request path /assets/images/nelson.gif with the file located in ./public/images/nelson.gif

In addition, Rack::Fonts supports a :cache_time option to easily indicate a cache expiration for your assets.

Apart from that, it will return appropiate Content-Type for webfonts and will add set the Access-Control-Allow-Origin header to *, so strict browsers like Firefox will be able to use these assets from different sites.

See the examples/config.ru file to see an example on how to use it.

Licenses

The test/assets directory includes the Forum font in several formats, see the Forum-Font-License-OFL.txt file to see the font license.

See the LICENSE file included in the distribution for the rest of the code.

Copyright

Copyright (C) 2011 Raul Murciano raul@murciano.net.

Something went wrong with that request. Please try again.