-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-page.php
More file actions
55 lines (39 loc) · 1.05 KB
/
create-page.php
File metadata and controls
55 lines (39 loc) · 1.05 KB
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
<?php
require 'vendor/autoload.php';
if (PHP_SAPI !== 'cli') {
exit;
}
$what = $argv[1] ?? null;
// does web/$what exist?
if (!$what) {
echo "Usage: php create-page.php <slug>\n";
exit;
}
if (is_dir(__DIR__ . "/web/$what")) {
echo "Directory web/$what already exists.\n";
exit;
}
mkdir(__DIR__ . "/web/$what");
$yaml_data = [
'title' => $what,
];
Spyc::YAMLDump($yaml_data, __DIR__ . "/web/$what/$what.yaml");
$content = '<?php
require_once __DIR__ . \'/../../loader.php\';
$lab = new ArtlungLab\Lab();
$lab->printHeader(
\''. $what .
'\'
);
?>
<p class="date-attribution">Created '. date('M Y').'</p>
<h1 class="p-name">'. $what.'</h1>';
$yaml_data = [
'title' => $what,
'slug' => $what,
];
$yaml_string = Spyc::YAMLDump($yaml_data);
file_put_contents(__DIR__ . "/web/$what/$what.scss", '');
file_put_contents(__DIR__ . "/web/$what/index.php", "<?php\nrequire \"$what.php\";");
file_put_contents(__DIR__ . "/web/$what/$what.php", $content);
file_put_contents(__DIR__ . "/web/$what/$what.yaml", $yaml_string);