Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 77 lines (63 sloc) 2.134 kb
44da91d @JasonHanley - Added offline capability
authored
1 <?php
2
fcef3a1 @JasonHanley - Completely restructured cache, offline, and build systems
authored
3 // NOTES:
4 // - php must be in your path
5 // - git must be in your path if you want to use 'update'
6
44da91d @JasonHanley - Added offline capability
authored
7 function addFiles(&$files, $pattern, $autoversion = false) {
8 $abspath = dirname(__FILE__).'/web';
9 $abspathLen = strlen($abspath)+1;
10 $filesToAdd = glob($abspath.'/'.$pattern);
11
12 foreach($filesToAdd as $filename) {
13 $newfilename = $filename;
14 $path = pathinfo($filename);
15 if($autoversion) {
16 $ver = '..'.filemtime($filename).'.';
17 $newfilename = $path['dirname'].'/'.$path['filename'].$ver.$path['extension'];
18 }
19 array_push($files, substr($newfilename, $abspathLen));
20 }
21 }
22
fcef3a1 @JasonHanley - Completely restructured cache, offline, and build systems
authored
23 $debug = false;
24 $debugString = '';
25
44da91d @JasonHanley - Added offline capability
authored
26 if($argc > 1) {
fcef3a1 @JasonHanley - Completely restructured cache, offline, and build systems
authored
27
28 // Check for debugging mode
29 if(in_array('debug', $argv)) {
30 $debug = true;
31 $debugString = 'debug';
32 }
44da91d @JasonHanley - Added offline capability
authored
33 }
fcef3a1 @JasonHanley - Completely restructured cache, offline, and build systems
authored
34
35 // Always build manifest
36 $files = array();
37
5af520b @JasonHanley - Cleaned up cache manifest dirtying mechanism
authored
38 array_push($files, '# Version '.time());
32fd976 @JasonHanley - More fun trying to make offline work (added dummy.js to try and get th...
authored
39
dedd0f8 @JasonHanley - Include all html files in the manifest for offline
authored
40 addFiles($files, '*.html');
fcef3a1 @JasonHanley - Completely restructured cache, offline, and build systems
authored
41 addFiles($files, 'favicon.ico');
354af97 @JasonHanley - Attempting to copy some other offline apps
authored
42 addFiles($files, 'apple-touch-icon.png');
8725e6d @JasonHanley - Build.php changes to go with last commit
authored
43 addFiles($files, 'apple-touch-icon-precomposed.png');
44 addFiles($files, 'css/style.css', true);
fcef3a1 @JasonHanley - Completely restructured cache, offline, and build systems
authored
45 addFiles($files, 'js/*.js', true);
46 addFiles($files, 'images/*');
e113e6f @JasonHanley - Disabled analytics in debug mode
authored
47 addFiles($files, 'about/*.html');
48 addFiles($files, 'about/*.png');
49758d8 @JasonHanley - Added __utm.gif to manifest
authored
49
f0f3f0f @JasonHanley - Tried removing FALLBACK section from cache manifest
authored
50 //array_push($files, "\nFALLBACK:");
51 //array_push($files, '/ offline.html');
04d5e3d @JasonHanley - A new attempt to make offline work better
authored
52
9cf43d7 @JasonHanley - Offline update
authored
53 array_push($files, "\nNETWORK:");
f0f3f0f @JasonHanley - Tried removing FALLBACK section from cache manifest
authored
54 //array_push($files, 'api/');
55 //array_push($files, 'google-analytics.com/ga.js');
9cf43d7 @JasonHanley - Offline update
authored
56 array_push($files, '*');
fcef3a1 @JasonHanley - Completely restructured cache, offline, and build systems
authored
57
58 $manifestFile = fopen('web/cache.manifest', 'wb');
59 if($manifestFile) {
60 fputs($manifestFile, "CACHE MANIFEST\n");
61 foreach($files as $filename) {
62 fputs($manifestFile, $filename."\n");
63 }
64 fclose($manifestFile);
37a58c3 @JasonHanley - Tidied up build script (added newlines)
authored
65 echo "Manifest file created.\n";
fcef3a1 @JasonHanley - Completely restructured cache, offline, and build systems
authored
66 } else {
37a58c3 @JasonHanley - Tidied up build script (added newlines)
authored
67 echo "Error opening Manifest file.\n";
fcef3a1 @JasonHanley - Completely restructured cache, offline, and build systems
authored
68 }
69
70 // Always rebuild index
62a73df @JasonHanley - Moved index file for easier debugging
authored
71 shell_exec('php web/index-src.php '.$debugString.' > web/index.html');
09fbd13 @JasonHanley - Started work on separate mobile and desktop versions
authored
72 echo "index.html rebuilt.\n";
73 shell_exec('php web/index-src.php '.$debugString.' desktop > web/d.html');
74 echo "d.html rebuilt.\n";
75 shell_exec('php web/index-src.php '.$debugString.' mobile > web/m.html');
76 echo "m.html rebuilt.\n";
Something went wrong with that request. Please try again.