forked from turtl/js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen-minified-index
executable file
·46 lines (37 loc) · 1.45 KB
/
gen-minified-index
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
#!/bin/bash
### This script generates index.html, which loads all needed javascript and
### css for the app.
pwd=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
ASSET_ROOT=""
SEARCH_PATH=""
source "$pwd/include.sh"
## -----------------------------------------------------------------------------
## generate extra
## -----------------------------------------------------------------------------
extra='<base href="/">'
## -----------------------------------------------------------------------------
## generate CSS links
## -----------------------------------------------------------------------------
css="$(
echo "$(all_css)" \
| sed 's|^|<link rel=\"stylesheet\" href=\"/|' \
| sed 's|$|">|'
)"
## -----------------------------------------------------------------------------
## generate JS includes
## -----------------------------------------------------------------------------
js="$(
cat $(echo "$(all_js)" \
| sed 's|___| |g' \
) > turtl.min.js
echo '<script src="/turtl.min.js"></script>'
)"
## -----------------------------------------------------------------------------
## put it all together
## -----------------------------------------------------------------------------
index="$(cat views/layouts/default.html)"
index="$(do_replace "$index" '{{extra}}' "$extra")"
index="$(do_replace "$index" '{{gencss}}' "$css")"
index="$(do_replace "$index" '{{genjs}}' "$js")"
# send our generated data into their restecpive files
echo -ne "$index" > index.html