-
Notifications
You must be signed in to change notification settings - Fork 0
/
_publish_site.php
91 lines (73 loc) · 2.91 KB
/
_publish_site.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
$destination = '../flourishlib.com';
$source = '../site';
$dirname = dirname(__file__);
$force = isset($argv[1]) && $argv[1] == '-f' ? TRUE : FALSE;
function render($url, $source, $destination, $original_source=NULL)
{
global $force;
// Check the file time of the original to allow pre-processing
if (!$original_source) {
$original_source = $source;
}
if (!$force && file_exists($destination) && filemtime($original_source) < filemtime($destination)) {
echo "Skipping $url - latest source already rendered\n";
return;
}
echo "Rendering $url\n";
`php ../wiki-engine/render.php $source > $destination`;
}
$start = microtime(TRUE);
render("/", "$source/$source/index.wiki", "$destination/index.html");
render("/About", "$source/$source/About.wiki", "$destination/About.html");
render("/Download", "$source/$source/Download.wiki", "$destination/Download.html");
render("/AdvancedDownload", "$source/$source/AdvancedDownload.wiki", "$destination/AdvancedDownload.html");
render("/Support", "$source/$source/Support.wiki", "$destination/Support.html");
render("/Tests", "$source/$source/Tests.wiki", "$destination/Tests.html");
render("/NotFound", "$source/$source/NotFound.wiki", "$destination/NotFound.html");
$blogs = array_diff(scandir('../site/blog'), array('.', '..'));
foreach ($blogs as $blog) {
if (!preg_match('#\.wiki$#', $blog)) {
continue;
}
$blog_path = '../site/blog/' . $blog;
$html_path = $destination . '/blog/' . str_replace('.wiki', '.html', $blog);
$blogs_wiki = file_get_contents($blog_path);
$title = str_replace('.wiki', '', $blog);
render("/blog/$title", "$blog_path", "$html_path");
}
$docs = array_diff(scandir('../docs'), array('.', '..'));
foreach ($docs as $doc) {
$doc_path = '../docs/' . $doc;
$html_path = $destination . '/docs/' . str_replace('.wiki', '.html', $doc);
if (!preg_match('#\.wiki$#', $doc)) {
continue;
}
$docs_wiki = file_get_contents($doc_path);
$tmp_path = '/var/tmp/' . $doc;
$page = str_replace('.wiki', '', $doc);
if (preg_match('#^f[A-Z]#', $doc)) {
$title = $page . ' – Class Documentation – ';
} elseif ($doc == 'index.wiki') {
$title = 'Documentation – ';
} else {
$title = $page . ' – General Documentation – ';
}
$docs_wiki = '<<include path="' . $dirname . '/../site/partials/header.html" title="' . $title . 'Flourish">>' . "\n\n" . $docs_wiki .
"\n\n" . '<<include path="' . $dirname . '/../site/partials/footer.html">>';
file_put_contents($tmp_path, $docs_wiki);
render("/docs/$page", "$tmp_path", "$html_path", "$doc_path");
unlink($tmp_path);
}
echo "Copying /favicon.ico\n";
`cp $source/favicon.ico $destination/`;
echo "Copying /img/\n";
`cp -R $source/img $destination/`;
echo "Copying /css/\n";
`cp -R $source/css $destination/`;
echo "Copying /files/\n";
`cp -R $source/files $destination/`;
echo "Copying /js/\n";
`cp -R $source/js $destination/`;
$total = microtime(TRUE) - $start;
echo "Run time: " . round($total, 2) . " seconds\n";