• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Manifest Builder for HTML5 and Gears (Offline) Application Cache

My first open source contribution. :-) I hope this is useful to anybody and also hope to get some useful feedback from more knowledgeable coders. ANY SUGGESTIONS to improve the code are VERY welcome!

Questions I have myself are:
- Is it better to implement this as a library with a thin controller?
- Is is better to move the configuration variables from the controller to an application/config file?

Code is hosted on github.com/MartijnR/Manifest-Builder


This class dynamically creates a manifest file that contains a list of the resources for the browser’s Application Cache. Using an Application Cache will speed up loading times and make the application available offline. Both HTML5 and Gears (deprecated) manifest formats are supported.
The builder is implemented as a fat controller to keep things simple (and I can’t think of a situation where you’d have more than 1 manifest in an application).


The following features are included:

- automatically detect all resources in and tags in html and add these to the manifest
- automatically detect all images files in the linked css stylesheets files and add these to the manifest
- automatic version number update when the manifest resources have changed (so client browser is prompted to re-download the resources)
- ability to manually update the version number (for troubleshooting and when edits may not result in changes in the dynamically created resources)
- ability to manually add additional pages to include, a fallback resource and resources that should never be cached

How to use

The controller (manifest.php) can simply be copied into the application/controllers folder and the two views in the application/views folder. To test go to: yourdomain.com/manifest/html5 (or yourdomain.com/manifest/gears). If it works add the manifest url to your html.

The commented block in the controller right after the class declaration allows customization of the manifest and includes:

- a forced version number update ($hash_manual_override) in case this is necessary</li>
- adding additional cache resources ($pages), such as any pages in addition to the main page (index.php e.g.) which is already included (’’)
- the fallback page to load when an app is offline and gets a request for a page that does not exist in the Application Cache ($offline)
- any resources that should never be cached ($network)</li>

I got some feedback about some code remnants that shouldn't have been there, i.e. a reference to Survey_model and a method of this model. (Thanks Stéphane!). I have updated GitHub to remove this code.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.