-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenerate_base64.sh
More file actions
executable file
·66 lines (56 loc) · 1.68 KB
/
Copy pathgenerate_base64.sh
File metadata and controls
executable file
·66 lines (56 loc) · 1.68 KB
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
#!/usr/bin/env bash
#
# generate the base64 encoded versions of the xslt files
#
set -o errexit
set -o pipefail
set -o nounset
echo "INFO: starting minification at $(date -u +"%Y-%m-%dT%H:%M:%SZ")"
GOBIN="$(go env GOBIN)"
# if not set use GOPATH/bin
if [ -z "${GOBIN}" ]; then
GOBIN="$(go env GOPATH)/bin"
fi
# check if minify is installed
MINIFY="${GOBIN}/minify"
if [ ! -f "${MINIFY}" ];
then
echo "INFO: minify could not be found, installing"
go install github.com/tdewolff/minify/cmd/minify@latest
fi
if [ ! -f "${MINIFY}" ];
then
echo "ERROR: minify could not be found at '${MINIFY}'"
echo "INFO: output from 'ls -lR $(go env GOPATH)'"
ls -lR "$(go env GOPATH)"
echo "INFO: output from 'go env'"
go env
echo "INFO: output from 'go env GOBIN'"
go env GOBIN
echo "INFO: exiting"
exit 1
fi
FILES=(simple-rss simple-atom)
TYPES=(css xslt)
for TYPE in "${TYPES[@]}"
do
for FILE in "${FILES[@]}"
do
if [ "${TYPE}" == "xslt" ]; then
MINIFY_TYPE="xml"
else
MINIFY_TYPE="${TYPE}"
fi
echo "INFO: generating base64 for ${FILE} ${TYPE}"
cat "docs/${TYPE}/${FILE}.${TYPE}" | "${MINIFY}" --type=${MINIFY_TYPE} | base64 --wrap=0 > "docs/${TYPE}/${FILE}.base64"
cp "docs/${TYPE}/${FILE}.base64" "docs/${TYPE}/_${FILE}.base64.html"
done
done
JSFILES=(rss-style atom-style)
for JSFILE in "${JSFILES[@]}"
do
echo "INFO: generating minified version of ${JSFILE}.js"
"${MINIFY}" --type=js "docs/js/${JSFILE}.js" > "docs/js/${JSFILE}.min.js"
cp "docs/js/${JSFILE}.min.js" "docs/js/_${JSFILE}.min.html"
done
echo "INFO: completed minification at $(date -u +"%Y-%m-%dT%H:%M:%SZ")"