forked from labluapucrio/site
-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate.sh
executable file
·43 lines (37 loc) · 1.12 KB
/
generate.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
#!/bin/bash
[ "$1" = "running" ] || {
echo "Do not launch this one directly. Use ./upload.sh instead."
exit 1
}
source ./config.sh
[ "$output_dir" ] || { echo "Couldn't load config.sh"; exit 1 ;}
root_dir="$PWD"
# Make paths absolute
pages_dir=$(readlink -f "$pages_dir")
output_dir=$(readlink -f "$output_dir")
common_dir=$(readlink -f "$common_dir")
# Reset output dir
rm -rf "$output_dir"
mkdir -p "$output_dir"
cd "$pages_dir"
find . -type f | while read file
do
file_dir=$(dirname "$file")
mkdir -p "$output_dir/$file_dir"
output_file="$output_dir/$file"
echo "<!-- THIS FILE WAS AUTOMATICALLY GENERATED. -->" > "$output_file"
cat "$common_dir/header.html" $file "$common_dir/footer.html" |\
sed -e 's/á/\á/g' \
-e 's/é/\é/g' \
-e 's/í/\í/g' \
-e 's/ó/\ó/g' \
-e 's/ú/\ú/g' \
-e 's/à/\à/g' \
-e 's/â/\â/g' \
-e 's/ê/\ê/g' \
-e 's/ô/\ô/g' \
-e 's/ã/\ã/g' \
-e 's/õ/\õ/g' \
-e 's/ç/\ç/g' \
>> "$output_file"
done