Here is a PHP script for auto-generating a manifest. The functionality
for grabbing all the file urls comes from a script by Ron Poulton, and
the JSON formatting from a script by Nick Halstead. Edit the eregi to
define which file types will be included in the manifest. The substr
removes an extra ./ that was at the beginning of all the urls.

<?php
// This script will grab all the selected file types from the same
directory this file is in and all
// it's sub-directories and echo the list formatted as a JSON manifest
for Google Gears.


$urls = explode("\n",`find .|sort`);
$fileurls = array();
$version = 'my_version_string';
?>
        {
        "betaManifestVersion": 1,
        "version": "<?php echo $version; ?>",
        "entries": [
                { "url": "."},
                <?php

                        foreach($urls as $url) {                
                                if (eregi("html$|css$|js$|gif$|png$|jpg$", 
$url) && !is_dir($url)) {                                    
                                        array_push($fileurls, substr($url, 2));
                                }
                        }       
                        $last = end($fileurls);
                        foreach($fileurls as $fileurl) {                        
        
                        ?>                      
                        { "url": "<?php echo $fileurl; ?>"}<?php
                                if($fileurl != $last) {
                                         echo ',';
                        }

                                 echo "\n";
                        }
                        ?>
                ]
        }

Reply via email to