forked from wiedehopf/tar1090
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconcat-example.sh
More file actions
29 lines (23 loc) · 837 Bytes
/
concat-example.sh
File metadata and controls
29 lines (23 loc) · 837 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
# cache busting and concatenation example
function magic() {
FN="$1.$2"
MD5="$1_$(md5sum "$FN" | cut -f1 -d' ').$2"
sed -i -e "s/$FN/$MD5/" index.html
mv "$FN" "$MD5"
}
for file in $(grep -oP -e '"stylesheet" href="\K[^"]*' index.html); do
sed -i -e "\\#$file#d" index.html
cat "$file" >> all.css
done
sed -i -e 's$.*CSS_ANCHOR.*$\0\n<link rel="stylesheet" href="all.css" type="text/css" />$' index.html
magic all css
for file in $(grep -oP -e 'script src="\K[^"]*' index.html); do
sed -i -e "\\#$file#d" index.html
cat "$file" >> all.js
done
sed -i -e 's$.*JS_ANCHOR.*$\0\n<script src="all.js"></script>$' index.html
magic all js
DB_VERSION=$(date +%s)
# or better
DB_VERSION=$(git rev-parse --short HEAD)
sed -i -e "s/let databaseFolder = .*;/let databaseFolder = \"db-$DB_VERSION\";/" index.html