build: remove php, replace with bash script
This commit is contained in:
parent
78ced31e9d
commit
0bafa59358
10
Makefile
10
Makefile
@ -17,7 +17,6 @@ all: $(BINNAME)-$(VERSION)-win32.7z $(BINNAME)-$(VERSION)-linux64.tar.xz $(BINNA
|
|||||||
#./build.sh -v ${VERSION}
|
#./build.sh -v ${VERSION}
|
||||||
|
|
||||||
deps:
|
deps:
|
||||||
apt install php-cli p7zip
|
|
||||||
npm install -g less uglify-js less-plugin-clean-css html-minifier
|
npm install -g less uglify-js less-plugin-clean-css html-minifier
|
||||||
go get github.com/googollee/go-socket.io
|
go get github.com/googollee/go-socket.io
|
||||||
go get code.ivysaur.me/libnmdc
|
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
|
uglifyjs clientpack/dcwebui.js -o clientpack/dcwebui.min.js -c -m
|
||||||
lessc --clean-css clientpack/dcwebui.css clientpack/dcwebui.min.css
|
lessc --clean-css clientpack/dcwebui.css clientpack/dcwebui.min.css
|
||||||
#php ./clientpack.php
|
#php ./clientpack.php
|
||||||
./minipack clientpack/index.htm css dcwebui.css clientpack/dcwebui.min.css
|
cat clientpack/index.htm \
|
||||||
./minipack clientpack/index.htm js dcwebui.js clientpack/dcwebui.min.js
|
| ./minipack style dcwebui.css clientpack/dcwebui.min.css \
|
||||||
./minipack clientpack/index.htm js socket.io-1.7.2.js clientpack/socket.io-1.7.2.js
|
| ./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
|
html-minifier --collapse-whitespace -o clientpack/index.min.htm clientpack/index.htm
|
||||||
mv clientpack/index.min.htm clientpack/index.htm
|
mv clientpack/index.min.htm clientpack/index.htm
|
||||||
rm ./clientpack/*.js
|
rm ./clientpack/*.js
|
||||||
|
35
minipack
35
minipack
@ -1,23 +1,22 @@
|
|||||||
#!/usr/bin/php
|
#!/bin/bash
|
||||||
<?php
|
|
||||||
|
|
||||||
// Embed content into HTML file
|
set -eu
|
||||||
function embed($filename, $mode, $find, $sourcefile) {
|
|
||||||
$html_content = file_get_contents($filename);
|
embed() {
|
||||||
$modes = [
|
local tag="$1"
|
||||||
'js' => ['script', 'script'],
|
local find="$2"
|
||||||
'css' => ['link', 'style'],
|
local sourcefile="$3"
|
||||||
];
|
|
||||||
|
|
||||||
$html_content = preg_replace_callback(
|
while IFS= read -r line ; do
|
||||||
'~<'. $modes[$mode][0] .'[^>]+'.$find.'[^>]*>~',
|
if [[ "${line}" =~ "${find}" ]] ; then
|
||||||
function() use ($modes, $mode, $sourcefile) {
|
echo -n "<${tag}>"
|
||||||
return '<'. $modes[$mode][1] . '>'.file_get_contents($sourcefile).'</'. $modes[$mode][1] .'>';
|
cat "${sourcefile}"
|
||||||
},
|
echo -n "</${tag}>"
|
||||||
$html_content
|
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 "$@"
|
||||||
|
Loading…
Reference in New Issue
Block a user