-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
33 lines (25 loc) · 871 Bytes
/
build.sh
File metadata and controls
33 lines (25 loc) · 871 Bytes
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
#!/bin/bash
# $ bash build.sh outdir ga-id
SRCDIR="$( cd "$( dirname "$0" )" && pwd )"
OUTDIR=$1
GAID=$2
rm -rf $OUTDIR
cp -R $SRCDIR $OUTDIR
cd $OUTDIR
rm build.sh
rm -rf .git
sed -i '' -e "s/##GA##/$GAID/" index.php
sed -i '' -e "s/UA--/$GAID/" json.php
python - <<EOF
import re, subprocess
def css(m):
proc = subprocess.Popen(["yuicompressor", "--type", "css"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
return "<style>" + proc.communicate(m.group(1))[0] + "</style>"
def js(m):
proc = subprocess.Popen(["closure-compiler", "--language_in", "ECMASCRIPT5"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
return "<script>" + proc.communicate(m.group(1))[0] + "</script>"
file = open("index.php").read()
file = re.sub("<style>((?:.|\n)+)</style>", css, file)
file = re.sub("<script>((?:.|\n)+)</script>", js, file)
open("index.php", "w").write(file)
EOF