-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen-posts.sh
executable file
·87 lines (73 loc) · 2.26 KB
/
gen-posts.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
#!/bin/bash
# This script creates all the static assets for octetz.com.
# It achieves this in the following steps.
#
# 1. Clone all repositories if not already existent in $OCTETZ_PATH
# 2. Convert markdown to html using pandoc against a custom HTML template
# 3. Move generated HTML to $STATIC_SITE_PATH/posts
# 3. Copy images to $STATIC_SITE_PATH/img
bold=`tput bold`
green=`tput setaf 2`
reset=`tput sgr0`
CURRENT_DIR=$(pwd)
OCTETZ_PATH=/home/josh/f/d/octetz
STATIC_SITE_PATH=${CURRENT_DIR}/../octetz-static
POSTS=(
"k8s-controllers-vs-operators"
"k8s-static-pods"
"vim-as-go-ide"
"k8s-network-policy-apis"
"contour-adv-ing-and-delegation"
"ha-control-plane-k8s-kubeadm"
"secure-port-k8s-cm-sched"
"setting-up-psps"
"rr-setup"
)
TEMPLATE=template.html
if [ ! -d ${STATIC_SITE_PATH} ]
then
mkdir -p ../octetz-static/posts/img
fi
if [ ! -d ${STATIC_SITE_PATH}/posts ]
then
mkdir -p ../octetz-static/posts/img
fi
if [ ! -d ${STATIC_SITE_PATH}/posts/img ]
then
mkdir -p ../octetz-static/posts/img
fi
printf "${green}===============> Pulling any missing repos${reset}"
for POST in "${POSTS[@]}"
do
if [ ! -d ${OCTETZ_PATH}/${POST} ]
then
cd ${OCTETZ_PATH}
git clone https://github.com/octetz/${POST}
cd ${CURRENT_DIR}
fi
done
echo
printf "${green}===============> Generating HTML and Copying resources to ${STATIC_SITE_PATH}${reset}"
for POST in "${POSTS[@]}"
do
echo
echo Processing ${OCTETZ_PATH}/${POST}
echo
pandoc -f markdown -t html5 --template=${TEMPLATE} -o ${POST}.html ${OCTETZ_PATH}/${POST}/README.md
mv -v ${POST}.html ${STATIC_SITE_PATH}/posts/
cp -v ${OCTETZ_PATH}/${POST}/img/* ${STATIC_SITE_PATH}/posts/img/
done
echo
printf "${green}===============> Moving static assets\n${reset}"
cp -v index.html ${STATIC_SITE_PATH}/
cp -v styles.css ${STATIC_SITE_PATH}/
cp -v posts/index.html ${STATIC_SITE_PATH}/posts
cp -v rss/feed.xml ${STATIC_SITE_PATH}/rss
echo
echo
printf "${green}===============> Static site regenerated\n${reset}"
printf "${green}git -C ${STATIC_SITE_PATH} add -A &&\ \n${reset}"
printf " ${green}git -C ${STATIC_SITE_PATH} commit -m \"update\" &&\ \n${reset}"
printf " ${green}git -C ${STATIC_SITE_PATH} push origin master\n${reset}"
echo
cp -v ${CURRENT_DIR}/styles.css ${STATIC_SITE_PATH}/posts/