Life sucks

This commit is contained in:
William 2023-01-20 20:33:45 +01:00
parent a788533c4a
commit 2539675aed
10 changed files with 57 additions and 50 deletions

View File

@ -1,15 +1,17 @@
FROM docker.io/alpine:latest FROM docker.io/alpine:latest
RUN apk update && apk add nginx php-fpm && \ RUN apk update && \
apk add tini nginx php-fpm && \
adduser -D -g 'www' www && \ adduser -D -g 'www' www && \
mkdir /www && \ mkdir /www && \
chown -R www:www /var/lib/nginx && \ chown -R www:www /var/lib/nginx && \
chown -R www:www /www chown -R www:www /www
COPY ./docker/nginx.conf /etc/nginx/nginx.conf COPY ./docker/nginx.conf /etc/nginx/nginx.conf
COPY ./ /www #COPY ./ /www
COPY ./docker/run.sh /opt/run.sh COPY ./docker/run.sh /opt/run.sh
RUN chmod +x /opt/run.sh RUN chmod +x /opt/run.sh
ENTRYPOINT ["tini", "--"]
CMD ["/opt/run.sh"] CMD ["/opt/run.sh"]

View File

@ -6,4 +6,4 @@ Made by yours truly
docker build --no-cache -f ./Dockerfile --tag willy-club-website docker build --no-cache -f ./Dockerfile --tag willy-club-website
docker run -dt -p 8080:8080 --name willy-club-website willy-club-website docker run -dt -v ./:/www -p 8080:8080 --name willy-club-website willy-club-website

View File

@ -65,7 +65,8 @@ abstract class Route
public static function put(string $path, callable $callback) { self::match('put', $path, $callback); } public static function put(string $path, callable $callback) { self::match('put', $path, $callback); }
public static function patch(string $path, callable $callback) { self::match('patch', $path, $callback); } public static function patch(string $path, callable $callback) { self::match('patch', $path, $callback); }
public static function delete(string $path, callable $callback) { self::match('delete', $path, $callback); } public static function delete(string $path, callable $callback) { self::match('delete', $path, $callback); }
public static function any(string $path, callable $callback) { self::match('get|post|put|patch|delete', $path, $callback); } public static function options(string $path, callable $callback) { self::match('options', $path, $callback); }
public static function any(string $path, callable $callback) { self::match('get|post|put|patch|delete|options', $path, $callback); }
public static function middleware(callable|array $middlewares) public static function middleware(callable|array $middlewares)
{ {

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh
nginx nginx
/usr/sbin/php-fpm* /usr/sbin/php-fpm*
tail -f /var/log/nginx/error.log exec tail -f /var/log/nginx/error.log

View File

@ -1,14 +1,5 @@
<?php <?php
// minimum PHP version required to continue
$php_version = '8.1';
if (version_compare(PHP_VERSION, $php_version, '<')) {
http_response_code(500);
echo 'This app requires a minimum of PHP ' . $php_version;
die();
}
unset($php_version);
// PSR-4 like autoloader // PSR-4 like autoloader
spl_autoload_register( spl_autoload_register(
function ($class_name) { function ($class_name) {
@ -37,6 +28,14 @@ function json_response(mixed $data, int $status_code = 200)
echo json_encode($data); echo json_encode($data);
} }
/**
* Helper for reading and decoding JSON from request body
*/
function json_decode_input(): array
{
return json_decode(file_get_contents('php://input'), true);
}
/** /**
* Helper for generating URLs * Helper for generating URLs
*/ */

View File

@ -3,11 +3,10 @@ body {
background: #fff; background: #fff;
line-height: 1.5; line-height: 1.5;
font-size: 1rem; font-size: 1rem;
font-family: Arial, Helvetica, sans-serif; font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif;
margin: 0; margin: 0;
} }
/* text based browsers */
hr { hr {
display: none; display: none;
} }
@ -16,26 +15,23 @@ a {
color: #00f; color: #00f;
} }
h1, h2, h3 {
font-weight: normal;
border-bottom: 1px solid #e9ecef;
padding-bottom: .25rem;
}
header { header {
background: #ddf; background: #77f;
border-bottom: 1px solid #aaa;
} }
header > nav { header > nav {
padding: 0.75rem; padding: .75rem;
margin: auto; margin: auto;
max-width: 37rem; max-width: 36rem;
}
header > nav > a {
text-decoration: none;
color: #fff;
} }
main { main {
padding: 0 0.75rem 0 0.75rem; padding: 0 .75rem 0 .75rem;
margin: auto; margin: auto;
max-width: 37rem; max-width: 36rem;
} }
img { img {
@ -55,20 +51,16 @@ tbody {
} }
td, th { td, th {
text-align: left; text-align: left;
padding: .5rem; padding: .75rem;
}
tr {
border-bottom: 1px solid #aaa;
} }
tr:nth-child(even) { tr:nth-child(even) {
background: #eee; background: #eee;
} }
pre, code { pre, code {
font-family: "DejaVu Sans Mono", Consolas, monospace; font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace;
background: #eee; background: #eee;
border: 1px solid #aaa; padding: .75rem;
padding: .5rem;
max-width: 100%; max-width: 100%;
display: block; display: block;
overflow-x: auto; overflow-x: auto;
@ -76,7 +68,20 @@ pre, code {
} }
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
html { body {
filter: invert(1); color: #fff;
background: #000;
}
header {
background: #111;
}
a {
color: #aaf;
}
tr:nth-child(even) {
background: #111;
}
pre, code {
background: #111;
} }
} }

View File

@ -19,6 +19,4 @@ Route::get('/error', fn() => 1 / 0);
// since no route was matched we show a page not found error // since no route was matched we show a page not found error
http_response_code(404); http_response_code(404);
view('templates/header', ['title' => 'Page not found']);
view('errors/404'); view('errors/404');
view('templates/footer');

View File

@ -1,3 +1,5 @@
<?=view('templates/header', ['title' => 'Page not found'])?>
<h1>Page not found</h1> <h1>Page not found</h1>
<p>The page you requested could not be found on this server</p> <p>The page you requested could not be found on this server</p>
<a href="<?=url('/')?>">Go home</a> <a href="<?=url('/')?>">Go home</a>
<?=view('templates/footer')?>

View File

@ -2,7 +2,7 @@
<h1>Welcome to the Willy Club</h1> <h1>Welcome to the Willy Club</h1>
<p>Theres more than just willies! Most of the time.</p> <p>More than just willies! Most of the time.</p>
<p>Not at all associated with thewilly.club ASSHOLES squatting my domain name with their shitty NFTs, this is the original.</p> <p>Not at all associated with thewilly.club ASSHOLES squatting my domain name with their shitty NFTs, this is the original.</p>
@ -27,7 +27,7 @@
</tr> </tr>
</table> </table>
<h1>Flirt with the WEBMASTER</h1> <h1>Flirt with the webmaster</h1>
<p>Send me a nice and positive message on matrix: <a href="https://matrix.to/#/@william:willy.club">@william:willy.club</a></p> <p>Send me a nice and positive message on matrix: <a href="https://matrix.to/#/@william:willy.club">@william:willy.club</a></p>

View File

@ -11,7 +11,7 @@
<header> <header>
<nav> <nav>
<span>[&nbsp;<a href="<?=url('/')?>">Home</a>&nbsp;]</span> <a href="<?=url('/')?>">the Willy Club</a>
</nav> </nav>
</header> </header>