diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2022-07-11 02:59:35 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2022-07-11 02:59:40 +0300 |
commit | 864e73cdc75a2fb0e4fad500f649dae2343c10a8 (patch) | |
tree | 6ce6762c6be72c98592a32fe0bed4f2ce751d544 /htdocs/js.php | |
parent | cb13ea239b9f1ca6aea43125d5694d5a55dcd287 (diff) |
rewrite css and js assets building
Diffstat (limited to 'htdocs/js.php')
-rw-r--r-- | htdocs/js.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/htdocs/js.php b/htdocs/js.php new file mode 100644 index 0000000..c9939fe --- /dev/null +++ b/htdocs/js.php @@ -0,0 +1,31 @@ +<?php + +require __DIR__.'/../init.php'; +global $config; + +$name = $_REQUEST['name'] ?? ''; + +if (!$config['is_dev'] || !$name || !is_dir($path = ROOT.'/htdocs/js/'.$name)) { + http_response_code(403); + exit; +} + +header('Content-Type: application/javascript'); +header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +$files = scandir($path, SCANDIR_SORT_ASCENDING); +$first = true; +foreach ($files as $file) { + if ($file == '.' || $file == '..') + continue; + // logDebug(__FILE__.': reading '.$path.'/'.$file); + if (!$first) + echo "\n"; + else + $first = false; + echo "/* $file */\n"; + if (readfile($path.'/'.$file) === false) + logError(__FILE__.': failed to readfile('.$path.'/'.$file.')'); +} |