-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.sh
executable file
·69 lines (56 loc) · 1.84 KB
/
compile.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
#!/bin/bash
#Including .ini file
. config.ini
#dirs/files
WORK_DIR=$(pwd)
OUTPUT_FILENAME="$WORK_DIR""/""$OUTPUT_FILE"
HTML_DIR="$WORK_DIR""/html_data/"
HTML_HEAD="$HTML_DIR""head.html"
HTML_TAIL="$HTML_DIR""tail.html"
#html strings
HTML_TITLE="<h3>$PROJECT_TITLE</h3>$PROJECT_SUBTITLE<br><br>"
HTML_GROUP_HEAD="<br><b>"
HTML_GROUP_TAIL="</b><br>"
HTML_BUTTON_HEAD="<div onClick='drawer_toggle(this)' class='button'>"
HTML_BUTTON_BODY="</div><div class='drawer'>"
HTML_BUTTON_TAIL="</div>"
#apply color
HTML_HEAD_COLOR_STRING=$(cat $HTML_HEAD)
HTML_HEAD_COLOR_FIX=${HTML_HEAD_COLOR_STRING//PROJECT_COLOR_A/$BACK_COLOR}
HTML_HEAD_COLOR_CHANGED=${HTML_HEAD_COLOR_FIX//PROJECT_COLOR_B/$FRONT_COLOR}
#write html
echo "" > $OUTPUT_FILENAME
echo $HTML_HEAD_COLOR_CHANGED >> $OUTPUT_FILENAME
echo $HTML_TITLE >> $OUTPUT_FILENAME
#get text
cd ./note_data/
SUB_SECTIONS=$( find -path './*' -prune -type d | sed 's/ /\\ /g')
for GROUP in $SUB_SECTIONS
#SUB_SECTIONS_FILES
do cd "$GROUP"
SUB_SECTIONS_FILES=$( find -path './*' -prune -type f )
FIX_GROUPNAME=$( echo "$GROUP" | cut -c 3- )
echo $HTML_GROUP_HEAD >> $OUTPUT_FILENAME
echo $FIX_GROUPNAME >> $OUTPUT_FILENAME
echo $HTML_GROUP_TAIL >> $OUTPUT_FILENAME
for FILE in $SUB_SECTIONS_FILES
do
FIX_FILENAME=$( echo "$FILE" | cut -c 3- )
echo $HTML_BUTTON_HEAD >> $OUTPUT_FILENAME
echo $FIX_FILENAME >> $OUTPUT_FILENAME
echo $HTML_BUTTON_BODY >> $OUTPUT_FILENAME
NOTE_STRING=$(cat $FILE)
NOTE_STRING=${NOTE_STRING//&/&}
NOTE_STRING=${NOTE_STRING//</<}
NOTE_STRING=${NOTE_STRING//>/>}
NOTE_STRING=${NOTE_STRING//'"'/"}
NOTE_STRING=${NOTE_STRING//$'\n'/<br />}
echo $NOTE_STRING >> "$OUTPUT_FILENAME"
echo $HTML_BUTTON_TAIL >> $OUTPUT_FILENAME
done
cd ..
done
#html tail
cat $HTML_TAIL >> $OUTPUT_FILENAME
#strip empty lines
#sed -i '/^$/d' $OUTPUT_FILENAME