Compare commits
5
Commits
d7071727bf
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
222d3e54c2 | ||
|
|
d4901ec329 | ||
|
|
3a96bc8f25 | ||
|
|
ead99e6769 | ||
|
|
6e6052483c |
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
const DISCORD_ID = '298221448642953217';
|
const DISCORD_ID = '298221448642953217';
|
||||||
const SITE_TITLE = '0xA0.dev';
|
const SITE_TITLE = '0xA0.dev';
|
||||||
|
const REPO_URL = 'https://git.0xa0.dev';
|
||||||
|
|
||||||
define('DATA_DIR', getenv('DATA_DIR') ?: '/var/www/data');
|
define('DATA_DIR', getenv('DATA_DIR') ?: '/var/www/data');
|
||||||
|
|||||||
+5
-2
@@ -1,11 +1,14 @@
|
|||||||
<?php $build = trim((string) @file_get_contents(__DIR__ . '/../build.txt')) ?: 'dev'; ?>
|
<?php
|
||||||
|
$build = trim((string) @file_get_contents(__DIR__ . '/../build.txt'));
|
||||||
|
$build = preg_match('/[0-9a-f]{7,40}/i', $build, $m) ? $m[0] : ($build ?: 'dev');
|
||||||
|
?>
|
||||||
<?php require_once __DIR__ . '/buttons.php'; ?>
|
<?php require_once __DIR__ . '/buttons.php'; ?>
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
<footer>
|
||||||
<div class="buttons88x31">
|
<div class="buttons88x31">
|
||||||
<?= render_buttons_88x31() ?>
|
<?= render_buttons_88x31() ?>
|
||||||
</div>
|
</div>
|
||||||
<small>© <?= date('Y') ?> · <a href="https://git.0xa0.dev">source</a> · build: <?= htmlspecialchars($build) ?></small>
|
<small>© <?= date('Y') ?> · build: <a href="<?= htmlspecialchars(REPO_URL) ?>"><?= htmlspecialchars($build) ?></a></small>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<section class="status-widget">
|
<section class="status-widget">
|
||||||
<h2>status</h2>
|
<h2>status</h2>
|
||||||
<div id="status" hx-get="/status.php" hx-trigger="every 10s" hx-ext="morph" hx-swap="morph:innerHTML">
|
<div id="status" hx-get="/status.php" hx-trigger="every 3s" hx-ext="morph" hx-swap="morph:innerHTML">
|
||||||
<?php include __DIR__ . '/status.php'; ?>
|
<?php include __DIR__ . '/status.php'; ?>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<?php $age = (new DateTime('2002-11-07'))->diff(new DateTime('today'))->y; ?>
|
<?php $age = (new DateTime('2002-11-07'))->diff(new DateTime('today'))->y; ?>
|
||||||
<p>I'm a <?= $age ?>-year-old developer (I know I'm unc), I hold a bachelor's degree in computer science (BUT Informatique) and I'm also a 42 school student.</p>
|
<p>I'm a <?= $age ?>-year-old developer (I know I'm unc), I hold a bachelor's degree in computer science (BUT Informatique) and I'm also a 42 school student.</p>
|
||||||
|
|
||||||
<p>if you wanna see what I'm building, feel free to check out my <a href="https://github.com/0xa00">GitHub</a> !</p>
|
<p>if you wanna see what I'm building, feel free to check out my <a href="https://github.com/0xa00">GitHub</a> or follow me on <a href="https://x.com/0xa0_">Twitter</a> !</p>
|
||||||
|
|
||||||
<section class="posts-widget">
|
<section class="posts-widget">
|
||||||
<h2>recent posts</h2>
|
<h2>recent posts</h2>
|
||||||
|
|||||||
+4
-13
@@ -2,7 +2,7 @@
|
|||||||
require_once __DIR__ . '/config.php';
|
require_once __DIR__ . '/config.php';
|
||||||
|
|
||||||
$cacheFile = DATA_DIR . '/lanyard.json';
|
$cacheFile = DATA_DIR . '/lanyard.json';
|
||||||
$ttl = 15;
|
$ttl = 2;
|
||||||
|
|
||||||
if (!function_exists('lanyard_refresh')) {
|
if (!function_exists('lanyard_refresh')) {
|
||||||
function lanyard_refresh(string $cacheFile): void {
|
function lanyard_refresh(string $cacheFile): void {
|
||||||
@@ -21,12 +21,11 @@ if (!function_exists('lanyard_refresh')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$haveCache = is_file($cacheFile);
|
$isPoll = realpath($_SERVER['SCRIPT_FILENAME'] ?? '') === __FILE__;
|
||||||
$stale = !$haveCache || (time() - filemtime($cacheFile) > $ttl);
|
$stale = !is_file($cacheFile) || (time() - filemtime($cacheFile) > $ttl);
|
||||||
|
|
||||||
if ($stale && !$haveCache) {
|
if ($stale && ($isPoll || !is_file($cacheFile))) {
|
||||||
lanyard_refresh($cacheFile);
|
lanyard_refresh($cacheFile);
|
||||||
$stale = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = json_decode(@file_get_contents($cacheFile), true)['data'] ?? null;
|
$data = json_decode(@file_get_contents($cacheFile), true)['data'] ?? null;
|
||||||
@@ -83,11 +82,3 @@ $banner = $bannerHash
|
|||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
|
||||||
if ($stale && realpath($_SERVER['SCRIPT_FILENAME'] ?? '') === __FILE__) {
|
|
||||||
if (function_exists('fastcgi_finish_request')) {
|
|
||||||
fastcgi_finish_request();
|
|
||||||
}
|
|
||||||
lanyard_refresh($cacheFile);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user