#!/bin/bash function linkify() { echo "$2" } function preamble() { echo "" echo '' echo "" } function generate_index() { preamble echo "

/blog

" echo '

Subscribe via RSS!

' echo '

' echo 'Built and served with:' echo 'build.sh' echo 'rss.c' echo '' echo 'server.c' echo 'mobile.c' echo '

' echo '

' echo 'page view count: stats.html' echo '

' echo "
"
    echo "-----"
    echo
    for f in {999..001}.txt; do
        [ ! -f "$f" ] && continue
        #date="$(head -n1 "$f" | cut -d' ' -f2-)"
        date="$(sed -n '2p' "$f"  | awk '{$1=""; print $0}' | sed 's/^ //g')"
        date_without_day="$(cut -d, -f2- <<< "$date")"
        title="$(sed -n '4p' "$f" | awk '{$1=$1;print}')"
        linkify "$f" "$date_without_day - $title"
    done
    echo "
" } compile() { mkdir -p bin for f in *.c; do gcc -x c -I. <(sed 1d "$f") -o "bin/${f%.c}" done } rm -rf bin compile generate_index | tee index.html ./rss.c > rss.xml for f in *.txt; do ./mobile.c "$f" > $f.html done