-
Notifications
You must be signed in to change notification settings - Fork 18
/
build.php
76 lines (63 loc) · 2.08 KB
/
build.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
// NOTES:
// - php must be in your path
// - git must be in your path if you want to use 'update'
function addFiles(&$files, $pattern, $autoversion = false) {
$abspath = dirname(__FILE__).'/web';
$abspathLen = strlen($abspath)+1;
$filesToAdd = glob($abspath.'/'.$pattern);
foreach($filesToAdd as $filename) {
$newfilename = $filename;
$path = pathinfo($filename);
if($autoversion) {
$ver = '..'.filemtime($filename).'.';
$newfilename = $path['dirname'].'/'.$path['filename'].$ver.$path['extension'];
}
array_push($files, substr($newfilename, $abspathLen));
}
}
$debug = false;
$debugString = '';
if($argc > 1) {
// Check for debugging mode
if(in_array('debug', $argv)) {
$debug = true;
$debugString = 'debug';
}
}
// Always build manifest
$files = array();
array_push($files, '# Version '.time());
addFiles($files, '*.html');
addFiles($files, 'favicon.ico');
addFiles($files, 'apple-touch-icon.png');
addFiles($files, 'apple-touch-icon-precomposed.png');
addFiles($files, 'css/style.css', true);
addFiles($files, 'js/*.js', true);
addFiles($files, 'images/*');
addFiles($files, 'about/*.html');
addFiles($files, 'about/*.png');
//array_push($files, "\nFALLBACK:");
//array_push($files, '/ offline.html');
array_push($files, "\nNETWORK:");
//array_push($files, 'api/');
//array_push($files, 'google-analytics.com/ga.js');
array_push($files, '*');
$manifestFile = fopen('web/cache.manifest', 'wb');
if($manifestFile) {
fputs($manifestFile, "CACHE MANIFEST\n");
foreach($files as $filename) {
fputs($manifestFile, $filename."\n");
}
fclose($manifestFile);
echo "Manifest file created.\n";
} else {
echo "Error opening Manifest file.\n";
}
// Always rebuild index
shell_exec('php web/index-src.php '.$debugString.' > web/index.html');
echo "index.html rebuilt.\n";
shell_exec('php web/index-src.php '.$debugString.' desktop > web/d.html');
echo "d.html rebuilt.\n";
shell_exec('php web/index-src.php '.$debugString.' mobile > web/m.html');
echo "m.html rebuilt.\n";