Sha256: 29fbe4935998fb84949ec53c5102dfdde31adf891573c1709f703077339d40de

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

= LocalAssets

LocalAssets facilitates loading of assets normally served by various content delivery networks (CDNs) from local sources in development so your site loads faster, and works even when you don't have an Internet connection (eg, on an airplane). 

To set up a local CDN mirror, see: http://github.com/alexreisner/cdn_mirror


== Rails

Add the gem to your +Gemfile+. Then add the following to your <tt>config/environments/development.rb</tt> file:

  config.middleware.use "Rack::LocalAssets", {
    "//ajax.googleapis.com/ajax/libs/" => "//localhost/cdn_mirror/google/"
  }

The configuration hash should contain any URL fragments that should be replaced with local alternatives in the development environment. The above example is for assets normally served by Google's CDN.


== Sinatra

require 'local_assets'

use Rack::LocalAssets, {
  "//ajax.googleapis.com/ajax/libs/" => "//localhost/cdn_mirror/google/"
}


== To-do List

* require replaced URLs to be in src or href attributes
* allow external config file which does not get committed to repo
  * allows different local URLs on different development machines
* implement as a railtie and load middleware automatically on app_middleware config hook


Copyright (c) 2009-10 Alex Reisner, released under the MIT license

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
local_assets-0.4.0 README.rdoc