summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Kohl <gitlab@jonaskohl.de>2024-07-26 10:20:45 +0200
committerJonas Kohl <gitlab@jonaskohl.de>2024-07-26 10:20:45 +0200
commitc93880a266edaac4703a3f7be4047f404cff9c00 (patch)
tree6e3793375e8b40269dccd1810dfa86a304de4095
parent24af4c37a4b022907974f5b9dbfd975a7897eb56 (diff)
Add versions to assets
-rw-r--r--common.php7
-rw-r--r--src/pages/guestbook.php2
-rw-r--r--src/template.php2
3 files changed, 9 insertions, 2 deletions
diff --git a/common.php b/common.php
index cba823a..d1cd758 100644
--- a/common.php
+++ b/common.php
@@ -2,6 +2,13 @@
define("SRCDIR", realpath(__DIR__ . "/src/"));
+function assetver(string $path): string {
+ $path = SRCDIR . "/" . $path;
+ if (!is_file($path))
+ return "0";
+ return md5_file($path);
+}
+
function hzcom_expand(string $pageContents): string {
$params = [];
$page = SRCDIR . "/pages/" . bin2hex(random_bytes(8)) . ".tmp";
diff --git a/src/pages/guestbook.php b/src/pages/guestbook.php
index 6a3393d..0b44dac 100644
--- a/src/pages/guestbook.php
+++ b/src/pages/guestbook.php
@@ -8,7 +8,7 @@
<div id="guestbook" class="is-loading h32"></div>
<script type="text/javascript" src="/static/jquery-1.12.4.min.js"></script>
-<script type="text/javascript" src="/emoticons.js"></script>
+<script type="text/javascript" src="/emoticons.js?<?= md5(strval(time())) ?>"></script>
<script>
function htmlentities(str) {
return str.replace(/&/g, "&amp;")
diff --git a/src/template.php b/src/template.php
index 09f29a5..6061e1d 100644
--- a/src/template.php
+++ b/src/template.php
@@ -12,7 +12,7 @@ $nav = fn(string $ln) =>
<meta http-equiv="MSThemeCompatible" content="no" />
<meta name="format-detection" content="telephone=no" />
<title><?= htmlentities($params["title"] ?? "") ?></title>
- <link rel="stylesheet" href="/static/style.css" type="text/css" />
+ <link rel="stylesheet" href="/static/style.css?<?= assetver("static/style.css") ?>" type="text/css" />
</head>
<body>
<div id="wrapper">