The Artima Developer Community
Sponsored Link

Java Buzz Forum
Google Gears Manifest Generator

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
dion

Posts: 5028
Nickname: dion
Registered: Feb, 2003

Dion Almaer is the Editor-in-Chief for TheServerSide.com, and is an enterprise Java evangelist
Google Gears Manifest Generator Posted: Jun 28, 2007 7:44 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by dion.
Original Post: Google Gears Manifest Generator
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Latest Java Buzz Posts
Latest Java Buzz Posts by dion
Latest Posts From techno.blog(Dion)

Advertisement

One of the modules that makes up Google Gears is the LocalServer that allows you to capture web resources so they can be served up when a user is offline.

The ManagedResourceStore component allows you to declare which resources you want the LocalServer to capture for you. You use a simple JSON manifest file that you can maintain with any text editor.

However, if your application gets large (lots of resources) you may not want to manage it in this way, so I created an open source Ruby library that allows me to generate this file given some rules:

For example, this will generate the manifest as a json string, and create entries using the current directory and sucking in everything apart from files starting with a '.'.

json = Google::Gears::LocalServer::Manifest.new do |m|
  m.version = 'MyNewVer'
  m.add_entry({ :url => 'main.html', :src => 'foo.html' })
  m.add_extra_info :to => 'main.html', :redirect => 'foo_redirect.html'
  m.find_entries :in => '.', :ignore => Google::Gears::LocalServer::Manifest::LEADING_PERIOD
end
find_entries is the real meat here:
# Defaults to '.'
find_entries :ignore => Google::Gears::LocalServer::Manifest::LEADING_PERIOD

# Only capture HTML pages
find_entries :include => '\.html'

# Look in the resources subdirectory, but use the URL 'static'. This is useful if your directory on disk doesn't match your URLs
find_entries :in => 'resources', :root => 'static'
Once you have created the entries, you may want to add some metadata to a few of them. This is where add_extra_info comes in:
# Find the 'main.html' entry and add a redirect. You can also use a different :src or :ignore_query.
add_extra_info :to => 'main.html', :redirect => 'foo_redirect.html'
You can also create a manifest object (instead of using the block version) if you need to add a few things, get the output, add a few more, etc etc.

If you find yourself not wanting to manage your Manifest file, check out the project.

Read: Google Gears Manifest Generator

Topic: Can't add entity methods to your session bean? Previous Topic   Next Topic Topic: Getting Sun Java 5 On Debian 4.0: So Easy

Sponsored Links



Google
  Web Artima.com   

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