The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Announcing Manifesto

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
John Topley

Posts: 233
Nickname: johntopley
Registered: Jul, 2003

John Topley is embarking on a journey to become a J2EE master.
Announcing Manifesto Posted: Jul 5, 2010 5:49 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by John Topley.
Original Post: Announcing Manifesto
Feed Title: John Topley's Weblog
Feed URL: http://johntopley.com/posts.atom
Feed Description: John Topley's Weblog - some articles on Ruby on Rails development.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by John Topley
Latest Posts From John Topley's Weblog

Advertisement

I’ve just released my first ever RubyGem. It’s a simple gem named Manifesto that dynamically generates an HTML 5 cache manifest for offline application caching. I got the idea whilst developing my Truth Tables Sinatra micro web application. 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.

Installation

To install the gem, use:

    [sudo] gem install manifesto
    

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
    

Sample Output

    CACHE MANIFEST
    # Generated by manifesto (http://github.com/johntopley/manifesto)
    # Hash: 7013a3b8292ceeeb6336849bee1d1365
    /apple-touch-icon.png
    /apple-touch-startup.png
    /index.html
    /mobile/mobile.css
    /mobile/mobile.js
    

Sinatra Example

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

Ruby on Rails Example

    # Create a Rails 2.x route for the manifest
    map.manifest '/manifest', :controller => 'manifest', :action => 'show'
    
    # ...or a Rails 3.x route
    match '/manifest' => 'manifest#show'
    
    # Create a controller action
    def show
      headers['Content-Type'] = 'text/cache-manifest'
      render :text => Manifesto.cache, :layout => false
    end
    

Enjoy!

Read: Announcing Manifesto

Topic: Ruby, the video Previous Topic   Next Topic Topic: “Ramble”, the Javascript Cucumber Port (work in progress)

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use