summaryrefslogtreecommitdiff
path: root/scripts/php/build_www_site.php
blob: 2defb92d1bb0a6fe3ac7e728fd05573b1cc6709c (plain)
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
<?php declare(strict_types=1);

require_once __DIR__.DIRECTORY_SEPARATOR.'functions.php';

$hostname = 'davidtsadler.com';

$geminiSrc = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'gemini';

if (!is_dir($geminiSrc)) {
    echo "Unable to locate gemini directory.\n\n";
    exit(1);
}

if (!is_readable($geminiSrc)) {
    echo "Gemini directory is not readable.\n\n";
    exit(1);
}

$output = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'www';

if (!is_dir($output)) {
    echo "Unable to locate output directory.\n\n";
    exit(1);
}

if (!is_writable($output)) {
    echo "Output directory is not writable.\n\n";
    exit(1);
}

$htmlTemplateDiretory = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'html_templates';

if (!is_dir($htmlTemplateDiretory)) {
    echo "Unable to locate html template directory.\n\n";
    exit(1);
}

if (!is_readable($htmlTemplateDiretory)) {
    echo "HTML template directory is not readable.\n\n";
    exit(1);
}

$pages = getPages($geminiSrc, $output);

buildWWWSite($pages, $hostname, $htmlTemplateDiretory, $output);