forked from leeds-maths-pgr/leeds-maths-pgr.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·75 lines (59 loc) · 1.89 KB
/
build.sh
File metadata and controls
executable file
·75 lines (59 loc) · 1.89 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
67
68
69
70
71
72
73
74
75
#!/usr/bin/env sh
. "./utility.sh"
# Globals
DIR_CONT="content"
DIR_OUTP=
DIR_ASST=
LST_FILE=
# Options
if [ $# -eq 0 ]; then
echo "ERR: No options provided"
echo "(run $0 -h for help)"
echo ""
exit 1
fi
oflag=
cflag=
aflag=
while getopts "i:o:a:ch" OPTION; do
case $OPTION in
o)
oflag="true"
DIR_OUTP="$OPTARG";;
c)
cflag="true";;
i)
DIR_CONT="$OPTARG";;
a)
aflag="true"
DIR_ASST="$(str_add "$DIR_ASST" "$OPTARG")";;
h)
echo "Usage:"
echo "args.sh -h "
echo "args.sh [-ic] -o OUTPDIR "
echo ""
echo " -o OUTPDIR Set the output directory"
echo " -i INPTDIR Set the input directory. Default value is 'content'"
echo " -a ASSTDIR Add an asset directory, can be called multiple times."
echo " -c Do not build the site and just exit after cleaning the output directory"
echo " -h help (this output)"
exit 0
;;
esac
done
if [ -z "$oflag" ]; then
echo "ERR: Output directory not specified."
echo "Please specify an output directory using the flag '-o OUTPDIR'"
exit 1
fi
# Generic sed command that needs to be passed to other functions
SUBSTITUTION="s|${DIR_CONT}|${DIR_OUTP}|"
mkdir -p "${DIR_OUTP}"
_clean "${DIR_OUTP}"
if [ ! -z "$cflag" ]; then
exit 0
fi
LST_FILE="$(collect_files ${DIR_CONT})"
_make_dirs "$LST_FILE" "$SUBSTITUTION"
_render_site "${LST_FILE}" "$SUBSTITUTION"
_copy_assets "${DIR_ASST}" "${DIR_OUTP}"