-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
136 lines (111 loc) · 3.26 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
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
######################################################
# Get English alphabet letters used in the index files
######################################################
COUNTER=0
for file in index-english/*
do
letter=$(perl -nle 'print $& if m{lpTitlePara">.}' $file)
if [ "$letter" ];then
char="${letter: 13}"
charNew=${char%????}
charNew2=$(echo $charNew | perl -pe 's/(\S+)/\u\L$1/g')
array[COUNTER]=$charNew2
fi
let COUNTER++
done
length=${#array[@]}
lettersString=""
for ((i=0; i<$length; i++))
do
lettersString+="\"${array[$i]}\""
if (($i < $length - 1)); then
lettersString+=","
fi
done
sed -i '' 's/$lettersIndex = array();/$lettersIndex = array('$lettersString');/' include/variables.php
######################################################
# Get Mawng alphabet letters used in the lexicon files
######################################################
COUNTER2=0
for file2 in lexicon/*
do
letter2=$(perl -nle 'print $& if m{lpTitlePara">.* }' $file2)
if [ "$letter2" ];then
char2="${letter2: 13}"
char3=${char2%?????}
char4=$(echo $char3 | perl -pe 's/(\S+)/\u\L$1/g')
array2[COUNTER2]=$char4
fi
let COUNTER2++
done
length2=${#array2[@]}
lettersString2=""
for ((i=0; i<$length2; i++))
do
lettersString2+="\"${array2[$i]}\""
if (($i < $length2 - 1)); then
lettersString2+=","
fi
done
sed -i '' 's/$lettersLexicon = array();/$lettersLexicon = array('$lettersString2');/' include/variables.php
################
# Get categories
################
COUNTER3=0
for file3 in categories/*
do
subcat=$(perl -nle 'print $& if m{Sub-categories:}' $file3)
if [ "$subcat" ];then
# get category name
letter3=$(perl -nle 'print $& if m{lpTitlePara">.*<}' $file3)
cat2="${letter3: 13}"
cat3=${cat2%?}
# echo $cat3
array3[COUNTER3]=$cat3
# get number from file name, e.g. 131 from categories/c131.htm
file3new="${file3: 12}"
file3new2=${file3new%????}
file3new3=$(echo $file3new2 | perl -pe 's/ /\\ /g')
# echo $file3new2
array4[COUNTER3]=$file3new3
let COUNTER3++
fi
done
length3=${#array3[@]}
categoryString=""
for ((i=0; i<$length3; i++))
do
# categoryString+="\"${array4[$i]}\"=>"
categoryString+="\"${array4[$i]}\" => \"${array3[$i]}\""
if (($i < $length3 - 1)); then
categoryString+=", "
fi
done
categoryStringNew=$(printf %q "$categoryString") # escape special charaters
sed -i '' "s/$categoryNames = array();/$categoryNames = array($categoryStringNew);/" include/variables.php
#################################
# Write language name to variable
#################################
languageName=$(perl -nle 'print $& if m{<title>.*</title>}' title.htm)
languageName2=${languageName%????????}
languageName3="${languageName2: 7}"
sed -i '' 's/$language = "Language1";/$language = \"'$languageName3'\";/' include/variables.php
#######################
# Set link to home page
#######################
if [ $# -eq 0 ];
then
echo "no args"
else
homepageAddress=$(printf %q "$1") # escape special charaters
sed -i '' "s|$homepage = \"\";|$homepage = \"$homepageAddress\";|" include/variables.php
fi
###################################
# Swap index.htm with index-new.htm
###################################
if [ -f "index-new.htm" ];
then
mv index.htm index-old.htm
mv index-new.htm index.htm
fi