use the Jekyll pages information to create the menu
[web.git] / build.sh
1 #!/bin/bash
2
3 PROJECTS_BASE="$HOME/src"
4 TMPFILE=$(mktemp)
5
6 while getopts "ds" opt; do
7   case $opt in
8     d)
9       DEVEL=1
10       ;;
11     s)
12       SYNC=1
13       ;;
14   esac
15 done
16
17 # update READMEs
18 for PROJECT in lilass schsh; do
19     # get the file
20     if [ -n "$DEVEL" ]; then
21         INFILE="$PROJECTS_BASE/$PROJECT/README.md"
22     else
23         cd "$PROJECTS_BASE/$PROJECT"
24         git show master:README.rst > "$TMPFILE"
25         INFILE="$TMPFILE"
26         cd - > /dev/null
27     fi
28     OUTFILE="projects/$PROJECT/index.md"
29     # process it
30     echo "---" > "$OUTFILE"
31     head -n 1 "$INFILE" | sed 's/^# \(.*\)$/title: "\1"/' >> "$OUTFILE"
32     echo "---" >> "$OUTFILE"
33     echo >> "$OUTFILE"
34     tail -n +3 "$INFILE" >> "$OUTFILE"
35 done
36
37 # call jekyll
38 jekyll build
39
40 if [ -n "$SYNC" ]; then
41     echo "TODO: sync to server"
42 fi