Skip to content

johntopley/manifesto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

manifesto

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.

Requirements

  • 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

Installation

This library is intended to be installed as a Gem.

$ gem install manifesto

You might need administrator privileges on your system to install it.

Usage

# 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')]

Sample Output

CACHE MANIFEST
# Generated by manifesto (http://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

Sinatra Example

require 'manifesto.rb'

get '/manifest' do
  headers 'Content-Type' => 'text/cache-manifest' # Must be served with this MIME type
  Manifesto.cache
end

Ruby on Rails Example

  • 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
    

Issues

Please use the GitHub issues tracker.

Note on Patches/Pull Requests

  • 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

Copyright © 2010 John Topley. See LICENSE for details.

About

HTML5 cache manifest generation.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages