2016-04-27 17:21:12 +05:00
|
|
|
#!/usr/bin/env bash
|
2016-10-15 18:05:38 +05:00
|
|
|
|
2016-10-18 16:08:49 +05:00
|
|
|
neochan="no"
|
|
|
|
if [ "$1" == "--enable-neochan" ] ; then
|
|
|
|
neochan="yes"
|
2016-10-15 18:05:38 +05:00
|
|
|
fi
|
|
|
|
|
2016-07-03 02:30:03 +05:00
|
|
|
root=$(readlink -e "$(dirname "$0")")
|
2016-05-03 21:16:36 +05:00
|
|
|
set -e
|
|
|
|
if [ "x" == "x$root" ] ; then
|
|
|
|
root=$PWD/${0##*}
|
|
|
|
fi
|
2016-07-03 02:30:03 +05:00
|
|
|
cd "$root"
|
2016-05-03 21:16:36 +05:00
|
|
|
|
2016-04-27 17:21:12 +05:00
|
|
|
if [ -z "$GOPATH" ]; then
|
2016-05-03 21:16:36 +05:00
|
|
|
export GOPATH=$root/go
|
2016-07-03 02:30:03 +05:00
|
|
|
mkdir -p "$GOPATH"
|
2016-04-27 17:21:12 +05:00
|
|
|
fi
|
|
|
|
|
2016-07-03 02:30:03 +05:00
|
|
|
if [ ! -f "$GOPATH/bin/minify" ]; then
|
|
|
|
echo "set up minifiy"
|
2016-04-30 17:26:14 +05:00
|
|
|
go get -v github.com/tdewolff/minify/cmd/minify
|
2016-04-27 17:21:12 +05:00
|
|
|
fi
|
2016-05-18 22:16:06 +05:00
|
|
|
|
2016-10-15 18:05:38 +05:00
|
|
|
outfile="$PWD/contrib/static/nntpchan.js"
|
|
|
|
neochan_js_outfile="$PWD/contrib/static/neochan.js"
|
|
|
|
neochan_css_outfile="$PWD/contrib/static/neochan.css"
|
2016-04-30 21:25:15 +05:00
|
|
|
|
2016-04-30 18:58:21 +05:00
|
|
|
mini() {
|
|
|
|
echo "minify $1"
|
|
|
|
echo "" >> $2
|
2016-10-07 19:17:29 +05:00
|
|
|
echo "/* begin $1 */" >> $2
|
2016-07-03 02:30:03 +05:00
|
|
|
"$GOPATH/bin/minify" --mime=text/javascript >> $2 < $1
|
2016-10-15 18:05:38 +05:00
|
|
|
echo "" >> $2
|
2016-10-07 19:17:29 +05:00
|
|
|
echo "/* end $1 */" >> $2
|
2016-04-30 18:58:21 +05:00
|
|
|
}
|
2016-04-27 17:21:12 +05:00
|
|
|
|
2016-10-15 18:05:38 +05:00
|
|
|
css() {
|
|
|
|
echo "minify $1"
|
|
|
|
echo "" >> $2
|
|
|
|
echo "/* begin $1 */" >> $2
|
|
|
|
lessc $1 >> $2
|
|
|
|
echo "" >> $2
|
|
|
|
echo "/* end $1 */" >> $2
|
|
|
|
}
|
2016-04-30 21:25:15 +05:00
|
|
|
|
2016-10-15 18:05:38 +05:00
|
|
|
initfile() {
|
|
|
|
|
|
|
|
rm -f "$1"
|
2016-10-07 19:17:29 +05:00
|
|
|
|
2016-10-15 18:05:38 +05:00
|
|
|
echo '/*' >> "$1"
|
|
|
|
echo ' * For source code and license information please check https://github.com/majestrate/nntpchan' >> "$1"
|
|
|
|
brandingfile=./contrib/branding.txt
|
|
|
|
if [ -e "$brandingfile" ] ; then
|
|
|
|
echo ' *' >> "$1"
|
|
|
|
while read line; do
|
|
|
|
echo -n ' * ' >> "$1";
|
|
|
|
echo $line >> "$1";
|
|
|
|
done < $brandingfile;
|
|
|
|
fi
|
|
|
|
echo ' */' >> "$1"
|
|
|
|
}
|
|
|
|
echo
|
|
|
|
echo "building nntpchan.js ..."
|
|
|
|
echo
|
|
|
|
initfile "$outfile"
|
2016-04-30 18:58:21 +05:00
|
|
|
|
2017-01-30 03:21:37 +05:00
|
|
|
|
|
|
|
for f in ./contrib/js/contrib/*.js ; do
|
|
|
|
mini "$f" "$outfile"
|
|
|
|
done
|
2016-07-03 02:30:03 +05:00
|
|
|
|
2016-10-08 17:29:46 +05:00
|
|
|
mini ./contrib/js/entry.js "$outfile"
|
2016-04-30 18:58:21 +05:00
|
|
|
|
|
|
|
# local js
|
2016-10-07 19:06:25 +05:00
|
|
|
for f in ./contrib/js/nntpchan/*.js ; do
|
2016-07-03 02:30:03 +05:00
|
|
|
mini "$f" "$outfile"
|
2016-04-27 17:21:12 +05:00
|
|
|
done
|
2016-10-07 19:06:25 +05:00
|
|
|
|
|
|
|
# vendor js
|
|
|
|
for f in ./contrib/js/vendor/*.js ; do
|
2016-10-08 17:29:46 +05:00
|
|
|
mini "$f" "$outfile"
|
2016-04-27 17:21:12 +05:00
|
|
|
done
|
2016-10-07 19:06:25 +05:00
|
|
|
|
2016-10-15 18:05:38 +05:00
|
|
|
if [ "$neochan" == "yes" ] ; then
|
|
|
|
set +e
|
2016-10-18 19:30:32 +05:00
|
|
|
for exe in lessc coffee ; do
|
2016-10-15 18:05:38 +05:00
|
|
|
which $exe &> /dev/null
|
|
|
|
if [ "$?" != "0" ] ; then
|
|
|
|
echo "$exe not installed";
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "building neochan.js ..."
|
|
|
|
echo
|
|
|
|
|
|
|
|
initfile "$neochan_js_outfile"
|
2016-10-18 19:30:32 +05:00
|
|
|
for f in ./contrib/js/neochan/*.coffee ; do
|
|
|
|
echo "compile $f"
|
|
|
|
coffee -cs < "$f" > "$f.js"
|
|
|
|
done
|
2016-10-15 18:05:38 +05:00
|
|
|
for f in ./contrib/js/neochan/*.js ; do
|
|
|
|
mini "$f" "$neochan_js_outfile"
|
|
|
|
done
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "building neochan.css ..."
|
|
|
|
echo
|
|
|
|
initfile "$neochan_css_outfile"
|
|
|
|
for f in ./contrib/js/neochan/*.less ; do
|
|
|
|
css "$f" "$neochan_css_outfile"
|
|
|
|
done
|
2016-12-31 18:36:28 +05:00
|
|
|
|
2016-10-15 18:05:38 +05:00
|
|
|
fi
|
|
|
|
echo
|
2016-04-30 17:26:14 +05:00
|
|
|
echo "ok"
|