Initial Commit

This commit is contained in:
William 2023-03-21 18:23:14 +01:00
commit 418e8ff301
10 changed files with 249 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/vendor
/composer.lock

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# Website
The fourth redesign of my website, finally a solid base I can build upon... Yeah

11
composer.json Normal file
View File

@ -0,0 +1,11 @@
{
"repositories": [
{
"type": "vcs",
"url": "https://git.willy.club/WillySoft/Route"
}
],
"require": {
"willysoft/route": "dev-master"
}
}

44
helpers.php Normal file
View File

@ -0,0 +1,44 @@
<?php
/**
* Helper for evaluating/including views
*/
function view(string $_view, array $_data = [])
{
$_path = __DIR__ . '/view/' . $_view . '.php';
extract($_data);
require $_path;
}
/**
* Helper for converting and outputting JSON
*/
function json_response(mixed $data, int $status_code = 200)
{
http_response_code($status_code);
header('Content-type: application/json');
echo json_encode($data);
}
/**
* Helper for reading and decoding JSON from request body
*/
function json_decode_input(): array|bool|null
{
return json_decode(file_get_contents('php://input'), true);
}
/**
* Helper for generating URLs
*/
function url(string $url, bool $full = false): string
{
$dir = dirname($_SERVER['SCRIPT_NAME']);
if ($dir === '/') {
$dir = '';
}
if (!$full) {
return $dir . $url;
}
return isset($_SERVER['HTTPS']) ? 'https' : 'http' . '://' . $_SERVER['HTTP_HOST'] . $dir . $url;
}

14
public/index.php Normal file
View File

@ -0,0 +1,14 @@
<?php
require '../vendor/autoload.php';
require '../helpers.php';
use WillySoft\Route as App;
App::get('/', function() {
view('home');
});
http_response_code(404);
view('404');

96
public/style.css Normal file
View File

@ -0,0 +1,96 @@
:root {
--primary: #fff;
--secondary: #eee;
--text: #111;
--links: #00f;
}
@media (prefers-color-scheme: dark) {
:root {
--primary: #181820;
--secondary: #22222f;
--text: #eee;
--links: #aaf;
}
img {
filter: brightness(85%);
}
}
body {
background: var(--primary);
margin: 0;
color: var(--text);
line-height: 1.5;
font-size: 1rem;
font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif;
padding: .75rem;
max-width: 47rem;
margin: auto;
}
hr {
display: none;
}
a {
color: var(--links);
}
h1 {
font-size: 1.953rem;
line-height: 1.1;
}
h2 {
font-size: 1.563rem;
line-height: 1.2;
}
h3 {
font-size: 1.25rem;
line-height: 1.4;
}
h1+h2,
h2+h3,
h1 {
margin-top: 2rem;
margin-bottom: .75rem;
}
img {
display: block;
height: auto;
max-width: 100%;
max-height: 20rem;
}
table {
display: block;
border-collapse: collapse;
overflow: auto;
}
tbody {
display: table;
width: 100%;
}
td,
th {
text-align: left;
padding: .75rem;
}
tr:nth-child(even) {
background: var(--secondary);
}
pre,
code {
font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace;
background: var(--secondary);
}
pre {
padding: .75rem;
max-width: 100%;
display: block;
overflow-x: auto;
overflow-y: hidden;
}

17
view/404.php Normal file
View File

@ -0,0 +1,17 @@
<?= view('header', ['title' => 'Page not found']) ?>
<h1>Page not found</h1>
<p>Sorry, the page you requested could not be found on this server.</p>
<?php
if (!isset($_SERVER['HTTP_REFERER'])) {
$referer = url('/');
} else {
$referer = $_SERVER['HTTP_REFERER'];
}
?>
<a href="<?=htmlspecialchars($referer)?>">Return</a>
<?= view('footer') ?>

3
view/footer.php Normal file
View File

@ -0,0 +1,3 @@
</main>
</body>
</html>

21
view/header.php Normal file
View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="<?=url('/')?>style.css">
<title><?=$title?></title>
</head>
<body>
<header>
<nav>
<a href="<?=url('/')?>">Home</a> |
<a href="http://status.trygve.me">Status</a>
</nav>
<hr>
</header>
<main>

38
view/home.php Normal file
View File

@ -0,0 +1,38 @@
<?= view('header', ['title' => 'Home']) ?>
<h1>Service</h1>
<p>This space hosts some services for me and friends.</p>
<ul>
<li>
<a href="//git.willy.club">Gitea</a><br>
A place to host your code
</li>
<li>
<a href="#">Matrix homeserver</a><br>
<span style="color: red">Registrations closed for the time being maybe forever</span>
<br>
Easy to use end-to-end encrypted comms
</li>
<li>
<a href="mumble://mumble.willy.club">Mumble</a><br>
Voice chat application
</li>
</ul>
<h1>Touch</h1>
<p>Matrix: <a href="https://matrix.to/#/@william:willy.club">@william:willy.club</a></p>
<h1>Blog</h1>
<ul>
<li>
<a href="/posts/0">Restoring my dignity</a> (forever draft)<br>
I have fallen and I can't get up<br>
<small><b><?=date("d.m.Y")?></b></small>
</li>
</ul>
<?= view('footer') ?>