forked from rabbitmq/rabbitmq-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate
executable file
·49 lines (38 loc) · 1.03 KB
/
generate
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
#!/usr/bin/env bash
set -e
SOURCE=$(realpath ./site)
DESTINATION="${1:-/tmp/rabbitmq_website}"
MODE="${2:-www}"
echo "Generating the site, ${SOURCE} => ${DESTINATION}"
debug() {
[ -z "$DEBUG" ] || set -x
}
prepare() {
rm -rf "${DESTINATION}"
}
generate_pages() {
PYTHONENCODING="utf-8" python3 ./code/compile "${SOURCE}" "${DESTINATION}" "$MODE"
PYTHONENCODING="utf-8" python3 ./code/compile "${SOURCE}" "${DESTINATION}" "$MODE" index.xml
}
copy_assets() {
mkdir -p "${DESTINATION}/img" "${DESTINATION}/js" "${DESTINATION}/css"
cp -r "${SOURCE}"/img/* "${DESTINATION}/img/"
cp -r "${SOURCE}"/js/* "${DESTINATION}/js/"
cp -r "${SOURCE}"/css/* "${DESTINATION}/css/"
cp -r "${SOURCE}"/favicon.ico "${DESTINATION}"
}
generate_atom_feed() {
xsltproc --novalid "${SOURCE}/feed-atom.xsl" "${SOURCE}/news.xml" > "${SOURCE}/news.atom"
}
move_atom_feed_to_destination() {
mv "${SOURCE}/news.atom" "$DESTINATION"
}
main() {
debug
prepare
generate_atom_feed
generate_pages
copy_assets
move_atom_feed_to_destination
}
main