rubyrubygemssinatramanifest.cache

Using Manifesto gem with Sinatra


I'm very new to Ruby and using Sinatra, mainly so that I can do some quick prototyping of web apps and some of the newer things available in HTML5.

I am trying to use Manifesto to generate the application cache needed for an offline web app.

I've followed the example listed on github, like so:

require 'manifesto.rb'

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

I am able to go to localhost:4567/manifest and I see what it generates just fine. What I am unclear on is what to do after that. My first attempt was to just view what was taking place in Web Inspector, but it doesn't appear that it recognizes any application cache at all.

Next, I tried copying and pasting the info generated when I visited /manifest into an app.manifest file and referencing it in the <html> of my layout.erb. Still nothing. And, I figured that wasn't really what was intended, because the manifest wouldn't update as the gem implies.

Can someone please help a newb understand what to do next? :)

Thanks!

Additionally, I am using the latest version of Rack which is supposed to support the mimetype for application cache.


Solution

  • Let's see if I get it right here. You should be referencing the auto-generated /manifest page in your html tag instead of copying it to another file, right?

    <html manifest="/manifest">
    

    And if you want it named something else, such as app.manifest it's as simple as changing that in your Sinatra code.

    get '/app.manifest' do
    

    I'm not entirely sure if this was what you asked however. Feel free to elaborate if needed. :)