-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.sh
executable file
·126 lines (105 loc) · 3.4 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
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
# builds pages from source
function build_page {
FILE_SOURCE=$1
FILE_TARGET=$2
cat $HEAD_FILE > $OUTDIR/$FILE_TARGET
echo "<!-- This is a generated file. Do not edit. -->" >> $OUTDIR/$FILE_TARGET
./edit.py < $FILE_SOURCE >> $OUTDIR/$FILE_TARGET
cat $FOOT_FILE >> $OUTDIR/$FILE_TARGET
}
HEAD_FILE=head.html
FOOT_FILE=foot.html
OUTDIR=build
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
# for backwards compatibility, remove next semester
build_page "index.html" "syllabus.html"
build_page "logistics.html" "intro.html"
for DIR in grass arcgis arcpro resources project_titles 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
./edit.py < $FILE >> $TGT_FILE
./increase-link-depth.py < $FOOT_FILE >> $TGT_FILE
done
for SUBDIR in data img
do
# copy only if directory exists
if [ -d "$DIR/$SUBDIR" ]; then
cp -r $DIR/$SUBDIR $OUTDIR/$DIR
fi
done
done
# GRASS GIS index
FILES="`./extract-links.py "grass/.+html" assignments.html`"
TITLE="List of GRASS GIS assignments"
HEAD_TEXT=""
# if this gets longer, it must go to a file
FOOT_TEXT="<img src='../img/grass_index.png' style='max-width: 90%;'>
<p>
If you are a non-NCSU visitor, you may find these additional pages useful:
<ul>
<li><a href='../topics/grass.html'>Introduction to GRASS GIS</a>
<li><a href='../lectures.html'>Lectures</a>
<li><a href='../logistics.html#software'>Software download instructions</a>
<li><a href='../logistics.html#data'>Dataset download instructions</a>\
</ul>
"
DIR="grass"
TGT_FILE=$OUTDIR/$DIR/index.html
./increase-link-depth.py < $HEAD_FILE > $TGT_FILE
echo "<!-- This is a generated file. Do not edit. -->" >> $TGT_FILE
./generate-index.py "$TITLE" "$HEAD_TEXT" "$FOOT_TEXT" $DIR/ ul $FILES >> $TGT_FILE
./increase-link-depth.py < $FOOT_FILE >> $TGT_FILE
# Topics index
FILES="`./extract-links.py "topics/.+html" schedule.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.
<p>
<img src='../img/graphics.png' style='max-width: 90%;'>"
DIR="topics"
TGT_FILE=$OUTDIR/$DIR/index.html
./increase-link-depth.py < $HEAD_FILE > $TGT_FILE
echo "<!-- This is a generated file. Do not edit. -->" >> $TGT_FILE
./generate-index.py "$TITLE" "$HEAD_TEXT" "$FOOT_TEXT" $DIR/ ul ul $FILES >> $TGT_FILE
./increase-link-depth.py < $FOOT_FILE >> $TGT_FILE
for FILE in *.css
do
cp $FILE $OUTDIR
done
for DIR in img
do
cp -r $DIR $OUTDIR
done
for DIR in resources
do
mkdir -p $OUTDIR/$DIR
for FILE in `ls $DIR/*.pdf $DIR/*.docx $DIR/*.odt $DIR/*.tex $DIR/*.png`
do
cp $FILE $OUTDIR/$DIR
done
for SUBDIR in `ls $DIR/*`
do
if [ -d "$DIR/$SUBDIR" ]; then
cp -r $DIR/$SUBDIR $OUTDIR/$DIR
fi
done
done
# URL backwards compatibility
cp $OUTDIR/grass/terrain_modeling.html $OUTDIR/grass/terrain_modeling_survey_2013.html