Start adding basic login infrastructure (still needs styling)
[gitphp.git] / util / minify.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
#
# minify.sh
#
# Minfies javascript files
#
# @author Christopher Han <xiphux@gmail.com>
# @copyright Copyright (c) 2010 Christopher Han
# @package GitPHP
# @subpackage util
#
 
JSDIR="js"
 
JSEXT=".js"
MINEXT=".min.js"
GZEXT=".gz"
 
CSSDIR="css"
CSSEXT=".css"
MINCSSEXT=".min.css"
 
rm -fv ${JSDIR}/*${MINEXT}
rm -fv ${CSSDIR}/*${MINCSSEXT}
rm -fv ${JSDIR}/*${GZEXT}
rm -fv ${JSDIR}/ext/*${GZEXT}
rm -fv ${CSSDIR}/*${GZEXT}
rm -fv ${CSSDIR}/ext/*${GZEXT}
 
if [ "$1" == "clean" ]; then
        exit;
fi
 
for i in ${JSDIR}/*${JSEXT}; do
        echo "Minifying ${i}..."
        JSMODULE="`basename ${i%$JSEXT}`"
        java -classpath lib/rhino/js.jar:lib/closure/compiler.jar org.mozilla.javascript.tools.shell.Main lib/requirejs/r.js -o name=${JSMODULE} out=${JSDIR}/${JSMODULE}${MINEXT}.tmp baseUrl=${JSDIR} paths.jquery="empty:" paths.qtip="empty:" paths.d3="empty:" paths.modernizr="ext/modernizr.custom" optimize="closure" preserveLicenseComments="false"
        cat util/jsheader.js ${JSDIR}/${JSMODULE}${MINEXT}.tmp > ${JSDIR}/${JSMODULE}${MINEXT}
        rm -f ${JSDIR}/${JSMODULE}${MINEXT}.tmp
done
 
for i in ${CSSDIR}/*${CSSEXT}; do
        echo "Minifying ${i}..."
        CSSBASE=${i%$CSSEXT}
        java -classpath lib/rhino/js.jar org.mozilla.javascript.tools.shell.Main lib/requirejs/r.js -o cssIn=${i} out=${CSSBASE}${MINCSSEXT} optimizeCss="standard"
done
 
for i in ${JSDIR}/*${MINEXT}; do
        gzip -v -c ${i} > ${i}${GZEXT}
        touch ${i} ${i}${GZEXT}
done
 
for i in ${JSDIR}/ext/jquery*${MINEXT}; do
        gzip -v -c ${i} > ${i}${GZEXT}
        touch ${i} ${i}${GZEXT}
done
 
gzip -v -c ${JSDIR}/ext/require.js > ${JSDIR}/ext/require.js${GZEXT}
touch ${JSDIR}/ext/require.js ${JSDIR}/ext/require.js${GZEXT}
 
for i in ${CSSDIR}/*${MINCSSEXT}; do
        gzip -v -c ${i} > ${i}${GZEXT}
        touch ${i} ${i}${GZEXT}
done
 
gzip -v -c ${CSSDIR}/ext/jquery.qtip.min.css > ${CSSDIR}/ext/jquery.qtip.min.css${GZEXT}
touch ${CSSDIR}/ext/jquery.qtip.min.css ${CSSDIR}/ext/jquery.qtip.min.css${GZEXT}
 
comments