-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.sh
executable file
·114 lines (94 loc) · 2.89 KB
/
build.sh
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
# builds pages from source
function build_page_general {
FILE_SOURCE=$1
FILE_TARGET=$2
HEAD_FILE=$3
FOOT_FILE=$4
OUTDIR=$5
cat $HEAD_FILE > $OUTDIR/$FILE_TARGET
echo "<!-- This is a generated file. Do not edit. -->" >> $OUTDIR/$FILE_TARGET
cat $FILE_SOURCE >> $OUTDIR/$FILE_TARGET
cat $FOOT_FILE >> $OUTDIR/$FILE_TARGET
}
function build_page {
build_page_general $1 $2 $HEAD_FILE $FOOT_FILE $OUTDIR
}
HEAD_FILE=head.html
FOOT_FILE=foot.html
OUTDIR="build"
if [ ! -d "$OUTDIR" ]; then
mkdir $OUTDIR
echo "Creating directory $OUTDIR automatically."
fi
# disable Jekyll which is not needed for out GitHub pages
touch $OUTDIR/.nojekyll
if [ ! -d "$OUTDIR" ]; then
echo "The directory $OUTDIR does not exists and it will be created for you."
mkdir $OUTDIR
fi
for FILE in `ls *.html|grep -v foot|grep -v head`
do
build_page $FILE $FILE
done
# Topics index
# The first parameter is the regular expression to match links
# in the files which are all the remaining parameters (one or more).
FILES="`./extract-links.py "topics/.+html" schedule.html schedule_spring.html`"
TITLE="Topics"
HEAD_TEXT=""
# if this gets longer, it must go to a file
FOOT_TEXT="<h3>Related courses</h3>
To learn more about these topics, here are some
<a href=\"https://geospatial.ncsu.edu/geoforall/courses.html\">related courses</a>
which may be useful for you."
DIR="topics"
TGT_FILE=$OUTDIR/topics.html
cat < $HEAD_FILE > $TGT_FILE
echo "<!-- This is a generated file. Do not edit. -->" >> $TGT_FILE
./generate-index.py "$TITLE" "$HEAD_TEXT" "$FOOT_TEXT" "" ul ul $FILES >> $TGT_FILE
cat < $FOOT_FILE >> $TGT_FILE
for DIR in assignments topics
do
mkdir -p $OUTDIR/$DIR
for FILE in `ls $DIR/*.html`
do
TGT_FILE=$OUTDIR/$DIR/`basename $FILE`
./increase-link-depth.py < $HEAD_FILE > $TGT_FILE
echo "<!-- This is a generated file. Do not edit. -->" >> $TGT_FILE
./color-comments.py < $FILE | ./strip-whitestace.py >> $TGT_FILE
./increase-link-depth.py < $FOOT_FILE >> $TGT_FILE
done
for SUBDIR in data img resources
do
# copy only if directory exists
if [ -d "$DIR/$SUBDIR" ]; then
cp -r $DIR/$SUBDIR $OUTDIR/$DIR
fi
done
done
if [ ! -d "$OUTDIR/lectures" ]; then
mkdir $OUTDIR/lectures
fi
for FILE in lectures/*
do
if [ ${FILE: -5} == ".html" ]; then
if [ ${FILE: -9} == "head.html" ] || [ ${FILE: -9} == "foot.html" ]; then
continue
fi
build_page_general $FILE $FILE lectures/head.html lectures/foot.html $OUTDIR
else
cp -r $FILE $OUTDIR/lectures
fi
done
for FILE in *.css
do
cp $FILE $OUTDIR
done
for DIR in img
do
cp -r $DIR $OUTDIR
done
# backwards compatibility
cp $OUTDIR/assignments/lidar_import.html $OUTDIR/instructions_lidar_upload.html
cp $OUTDIR/assignments/trimble_install.html $OUTDIR/instructions_trimble.html