diff --git a/Makefile b/Makefile index 388133a..081ab6f 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,6 @@ all: $(BINNAME)-$(VERSION)-win32.7z $(BINNAME)-$(VERSION)-linux64.tar.xz $(BINNA #./build.sh -v ${VERSION} deps: - apt install php-cli p7zip npm install -g less uglify-js less-plugin-clean-css html-minifier go get github.com/googollee/go-socket.io go get code.ivysaur.me/libnmdc @@ -36,9 +35,12 @@ bindata.go: client client/* uglifyjs clientpack/dcwebui.js -o clientpack/dcwebui.min.js -c -m lessc --clean-css clientpack/dcwebui.css clientpack/dcwebui.min.css #php ./clientpack.php - ./minipack clientpack/index.htm css dcwebui.css clientpack/dcwebui.min.css - ./minipack clientpack/index.htm js dcwebui.js clientpack/dcwebui.min.js - ./minipack clientpack/index.htm js socket.io-1.7.2.js clientpack/socket.io-1.7.2.js + cat clientpack/index.htm \ + | ./minipack style dcwebui.css clientpack/dcwebui.min.css \ + | ./minipack script dcwebui.js clientpack/dcwebui.min.js \ + | ./minipack script socket.io-1.7.2.js clientpack/socket.io-1.7.2.js \ + > clientpack/index.packed.htm + mv clientpack/index.packed.htm clientpack/index.htm html-minifier --collapse-whitespace -o clientpack/index.min.htm clientpack/index.htm mv clientpack/index.min.htm clientpack/index.htm rm ./clientpack/*.js diff --git a/minipack b/minipack index 5ffd65e..8b09afe 100755 --- a/minipack +++ b/minipack @@ -1,23 +1,22 @@ -#!/usr/bin/php - ['script', 'script'], - 'css' => ['link', 'style'], - ]; +set -eu + +embed() { + local tag="$1" + local find="$2" + local sourcefile="$3" - $html_content = preg_replace_callback( - '~<'. $modes[$mode][0] .'[^>]+'.$find.'[^>]*>~', - function() use ($modes, $mode, $sourcefile) { - return '<'. $modes[$mode][1] . '>'.file_get_contents($sourcefile).''; - }, - $html_content - ); + while IFS= read -r line ; do + if [[ "${line}" =~ "${find}" ]] ; then + echo -n "<${tag}>" + cat "${sourcefile}" + echo -n "" + else + echo "${line}" + fi + done - file_put_contents($filename, $html_content); } -embed($_SERVER['argv'][1], $_SERVER['argv'][2], $_SERVER['argv'][3], $_SERVER['argv'][4]); +embed "$@"