-
Notifications
You must be signed in to change notification settings - Fork 1
/
generator.php
38 lines (34 loc) · 1008 Bytes
/
generator.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
<?php
global $github_sha;
$github_sha = ( isset( $argv[1] ) ) ? $argv[1] : 'Unknown';
$base = __DIR__ . '/';
$output = $base . 'output/';
$files = glob( $base . '*.php' );
@mkdir( $output );
function recurse_copy( $src, $dst ) {
$dir = opendir( $src );
@mkdir( $dst );
while ( false !== ( $file = readdir( $dir ) ) ) {
if ( ( $file != '.' ) && ( $file != '..' ) ) {
if ( is_dir( $src . '/' . $file ) ) {
recurse_copy( $src . '/' . $file, $dst . '/' . $file );
} else {
copy( $src . '/' . $file, $dst . '/' . $file );
}
}
}
closedir( $dir );
}
if ( ! empty( $files ) ) {
foreach ( $files as $_file ) {
if ( basename( __FILE__ ) !== basename( $_file ) ) {
ob_start();
include( $_file );
$data = ob_get_clean();
$data = str_replace( '.php', '.html', $data );
$save_file = str_replace( '.php', '.html', basename( $_file ) );
file_put_contents( $output . $save_file, $data );
}
}
recurse_copy( $base . '/assets/', $output . 'assets/' );
}