Skip to content

Commit

Permalink
Separate 404.html
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Oct 19, 2024
1 parent d5445b2 commit 806f551
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 59 deletions.
12 changes: 8 additions & 4 deletions bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ $iterator = new CallbackFilterIterator($iterator, function (SplFileInfo $fileInf

foreach ($iterator as $fileInfo) {
$file = str_replace(__ROOT__, '', $fileInfo->getRealPath());
echo "Add file: " . $file . "\n";
echo "+ " . $file . "\n";
$phar->addFile($fileInfo->getRealPath(), $file);

if (!array_key_exists('nozip', $opt)) {
Expand All @@ -69,15 +69,19 @@ foreach ($iterator as $fileInfo) {
}

// Add schema.json
echo "Add file: /src/schema.json\n";
echo "+ /src/schema.json\n";
$phar->addFile(realpath(__DIR__ . '/../src/schema.json'), '/src/schema.json');

// Add Caddyfile
echo "Add file: /recipe/provision/Caddyfile\n";
echo "+ /recipe/provision/Caddyfile\n";
$phar->addFile(realpath(__DIR__ . '/../recipe/provision/Caddyfile'), '/recipe/provision/Caddyfile');

// Add 404.html
echo "+ /recipe/provision/404.html\n";
$phar->addFile(realpath(__DIR__ . '/../recipe/provision/404.html'), '/recipe/provision/404.html');

// Add bin/dep file
echo "Add file: /bin/dep\n";
echo "+ /bin/dep\n";
$depContent = file_get_contents(__ROOT__ . '/bin/dep');
$depContent = str_replace("#!/usr/bin/env php\n", '', $depContent);
$depContent = str_replace('__FILE__', 'str_replace("phar://", "", Phar::running())', $depContent);
Expand Down
51 changes: 51 additions & 0 deletions recipe/provision/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>404 Not Found</title>
<style>
body {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
align-content: center;
background: #343434;
color: #fff;
display: grid;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
font-size: 20px;
justify-content: center;
margin: 0;
min-height: 100vh;
}

main {
padding: 0 30px;
}

svg {
animation: 2s ease-in-out infinite hover;
}

@keyframes hover {
0%, 100% {
transform: translateY(0)
}
50% {
transform: translateY(-8px)
}
}
</style>
</head>
<body>
<main>
<svg width="68" viewBox="0 0 48 40" xmlns="http://www.w3.org/2000/svg">
<path
d="M41.8253 0.269788C44.8519 -0.884712 47.9239 1.84927 47.1284 4.98944L39.3219 35.8043C38.615 38.5948 35.2805 39.7475 33.0012 37.9892L19.9291 27.905C17.8765 26.3215 17.8492 23.2338 19.8735 21.6144L35.3856 9.20469C36.2481 8.51467 37.5067 8.65451 38.1967 9.51704C38.8868 10.3796 38.7469 11.6381 37.8844 12.3282L22.8693 24.3402C22.6163 24.5427 22.6197 24.9286 22.8762 25.1266L34.8414 34.3568C35.1263 34.5766 35.5431 34.4325 35.6315 34.0837L43.0145 4.94009C43.1139 4.54757 42.7299 4.20583 42.3516 4.35014L5.41328 18.44C4.96316 18.6117 4.99234 19.2581 5.4561 19.3885L12.954 21.4973C14.4463 21.917 15.5617 23.1612 15.8166 24.6903L17.2908 33.5357C17.3714 34.0193 18.0276 34.11 18.2364 33.6664L18.8254 32.4148C19.2957 31.4154 20.4872 30.9865 21.4866 31.4568C22.486 31.9271 22.915 33.1186 22.4446 34.118L21.1735 36.8193C19.5032 40.3685 14.2535 39.6429 13.6086 35.7737L11.9232 25.6611C11.8913 25.4699 11.7519 25.3144 11.5654 25.2619L2.9172 22.8296C-0.792895 21.7862 -1.02636 16.6153 2.5746 15.2417L41.8253 0.269788Z"
fill="white"/>
</svg>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
</main>
</body>
</html>
56 changes: 1 addition & 55 deletions recipe/provision/website.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,62 +15,8 @@
desc('Configures a server');
task('provision:server', function () {
run('usermod -a -G www-data caddy');
$html = <<<'HTML'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>404 Not Found</title>
<style>
body {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
align-content: center;
background: #343434;
color: #fff;
display: grid;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
font-size: 20px;
justify-content: center;
margin: 0;
min-height: 100vh;
}
main {
padding: 0 30px;
}
svg {
animation: 2s ease-in-out infinite hover;
}
@keyframes hover {
0%, 100% {
transform: translateY(0)
}
50% {
transform: translateY(-8px)
}
}
</style>
</head>
<body>
<main>
<svg width="48" height="38" viewBox="0 0 243 193">
<title>Deployer</title>
<g fill="none" fill-rule="evenodd">
<path fill="#0CF" d="M242.781.39L.207 101.653l83.606 21.79z"/>
<path fill="#00B3E0" d="M97.555 186.363l14.129-50.543L242.78.39 83.812 123.442l13.743 62.922"/>
<path fill="#0084A6" d="M97.555 186.363l33.773-39.113-19.644-11.43-14.13 50.543"/>
<path fill="#0CF" d="M131.328 147.25l78.484 45.664L242.782.391 111.683 135.82l19.644 11.429"/>
</g>
</svg>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
</main>
</body>
</html>
HTML;
run("mkdir -p /var/deployer");
run("echo $'$html' > /var/deployer/404.html");
upload(__DIR__ . '/404.html', '/var/deployer/404.html');
})->oncePerNode();

desc('Provision website');
Expand Down

0 comments on commit 806f551

Please sign in to comment.