aboutsummaryrefslogtreecommitdiff
path: root/prepare_static.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-07-10 01:30:05 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-07-10 23:53:02 +0300
commit1c524efbf7da91cb99bb4516feb514071e938495 (patch)
treee1fced0104749014db154f5d3b29881e705bfafc /prepare_static.php
parent8979719a1af4bc0712407db7f95704f645f261a3 (diff)
dark theme support
Diffstat (limited to 'prepare_static.php')
-rwxr-xr-xprepare_static.php48
1 files changed, 0 insertions, 48 deletions
diff --git a/prepare_static.php b/prepare_static.php
deleted file mode 100755
index e3663f8..0000000
--- a/prepare_static.php
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/env php8.1
-<?php
-
-function gethash(string $path): string {
- return substr(sha1(file_get_contents($path)), 0, 8);
-}
-
-function sassc(string $src_dir, string $dst_dir, string $file): int {
- $cmd = 'sassc -t expanded '.escapeshellarg($src_dir.'/'.$file).' '.escapeshellarg($dst_dir.'/'.preg_replace('/\.scss$/', '.css', $file));
- exec($cmd, $output, $code);
- return $code;
-}
-
-require __DIR__.'/init.php';
-global $config;
-
-function build_static(): void {
- $css_dir = ROOT.'/htdocs/css';
- $hashes = [];
-
- if (!file_exists($css_dir))
- mkdir($css_dir);
-
- $files = ['common-bundle.scss', 'admin.scss'];
- foreach ($files as $file) {
- if (sassc(ROOT.'/htdocs/scss', $css_dir, $file) != 0)
- fwrite(STDERR, "error: could not compile $file\n");
- }
-
- foreach (['css', 'js'] as $type) {
- $reldir = ROOT.'/htdocs/';
- $files = glob_recursive($reldir.$type.'/*.'.$type);
- if (empty($files)) {
- continue;
- }
- foreach ($files as $file) {
- $name = preg_replace('/^'.preg_quote($reldir, '/').'/', '', $file);
- $hashes[$name] = gethash($file);
- }
- }
-
- $scfg = "<?php\n\n";
- $scfg .= "return ".var_export($hashes, true).";\n";
-
- file_put_contents(ROOT.'/config-static.php', $scfg);
-}
-
-build_static(); \ No newline at end of file