Manifesto dynamically generates an HTML5 cache manifest for offline application caching. It returns a list of files within the specified directory and sub-directories. By default it also includes a computed hash of the files’ contents, so that if a file is changed a different hash is produced, causing the cache to be automatically invalidated.
-
Ruby >= 1.8.6 (not tested with previous versions)
Manifesto has been successfully tested against the following Ruby releases:
-
Ruby 1.8.6
-
Ruby 1.8.7
-
Ruby 1.9.1
This library is intended to be installed as a Gem.
$ gem install manifesto
You might need administrator privileges on your system to install it.
# Basic usage, list all non-hidden files in ./public and include a computed hash of their contents Manifesto.cache # Specify a directory Manifesto.cache :directory => './mobile' # Specify a directory and don't compute the hash Manifesto.cache :directory => './mobile', :compute_hash => false # Add network includes Manifesto.cache :directory => '.mobile', :network_includes => ['http://google.com', 'http://github.com'] # Add file exclusions Manifesto.cache :directory => '.mobile', :excludes => ['dynamic-dir/', 'dynamic.js')]
CACHE MANIFEST # Generated by manifesto (https://github.com/johntopley/manifesto) # Hash: 7013a3b8292ceeeb6336849bee1d1365 CACHE: /apple-touch-icon.png /apple-touch-startup.png /index.html /mobile/mobile.css /mobile/mobile.js NETWORK: http://github.com
require 'manifesto.rb' get '/manifest' do headers 'Content-Type' => 'text/cache-manifest' # Must be served with this MIME type Manifesto.cache end
-
Create a route for the cache manifest:
map.manifest '/manifest', :controller => 'manifest', :action => 'show' # Rails 2.x -- or -- match '/manifest' => 'manifest#show' # Rails 3.x
-
Create a controller action:
def show headers['Content-Type'] = 'text/cache-manifest' render :text => Manifesto.cache, :layout => false end
Please use the GitHub issues tracker.
-
Fork the project
-
Make your feature addition or bug fix
-
Add tests for it. This is important so I don’t break it in a future version unintentionally
-
Commit, do not mess with rakefile, version, or history (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-
Send me a pull request. Bonus points for topic branches
-
Thanks to Nasir Jamal for helping me with RSpec.
Copyright © 2010 John Topley. See LICENSE for details.