diff --git a/app/Controllers/Findingaid.php b/app/Controllers/Findingaid.php index 61e140f..7e6a2a5 100644 --- a/app/Controllers/Findingaid.php +++ b/app/Controllers/Findingaid.php @@ -32,6 +32,11 @@ public function show() return; } + $css = [ + 'extra_version' => $this->assetVersion('css/extra.css'), + 'mediaelementplayer_version' => $this->assetVersion('css/mediaelementplayer.min.css'), + ]; + /* First, fill out top-level metadata, including the * table of contents. */ @@ -305,17 +310,10 @@ public function show() 'content' => $content, 'toc' => $toc, 'requests' => $requests, + 'css' => $css, 'js' => [[ 'href' => 'js/app.js', - 'hash' => hash_file('sha256', implode( - DIRECTORY_SEPARATOR, - [ - ROOT, - 'public', - 'js', - 'app.js', - ] - )), + 'version' => $this->assetVersion('js/app.js'), ]], 'title' => $model->title(), 'requestable' => $requestable, @@ -353,6 +351,7 @@ public function show() [ 'title' => $meta['title'], 'repository' => $meta['repository'], + 'css' => $css, ] ); } else { @@ -362,6 +361,7 @@ public function show() 'title' => $meta['title'], 'repository' => $meta['repository'], 'repo_url' => $repo_url, + 'css' => $css, ] ); } diff --git a/app/Core/Controller.php b/app/Core/Controller.php index 4373916..15b5369 100644 --- a/app/Core/Controller.php +++ b/app/Core/Controller.php @@ -11,4 +11,16 @@ public function __construct(protected $params = []) global $g_config; $this->config = $g_config; } + + public function assetVersion($path) + { + $file_path = implode(DIRECTORY_SEPARATOR, [ + realpath(ROOT), + 'public', + $path, + ]); + $algo = 'sha384'; + $version = $algo . '-' . base64_encode(hash($algo, file_get_contents($file_path), true)); + return $version; + } } diff --git a/app/Views/Euk_Shared/head-common.mustache b/app/Views/Euk_Shared/head-common.mustache index 4c034ee..ff81cea 100644 --- a/app/Views/Euk_Shared/head-common.mustache +++ b/app/Views/Euk_Shared/head-common.mustache @@ -8,8 +8,8 @@ - - + + diff --git a/app/Views/Layouts/application.mustache b/app/Views/Layouts/application.mustache index 0e1a3ef..44c6983 100644 --- a/app/Views/Layouts/application.mustache +++ b/app/Views/Layouts/application.mustache @@ -47,7 +47,7 @@ {{> universal-footer}} {{> limestone-resources}} {{#js}} - + {{/js}} {{#requestable}}