#!/bin/sh # sw - suckless webframework - 2012 - MIT License - nibble sw_filter() { for b in $BL; do [ "$b" = "$1" ] && return 0 done } sw_main() { $MDHANDLER $1 } sw_menu() { echo "" } sw_page() { # Header cat << _header_ ${TITLE} _header_ # Stylesheet sw_style cat << _header_

${TITLE} ${SUBTITLE}

_header_ # Menu echo "
" sw_menu $1 echo "
" # Body echo "
" sw_main $1 echo "
" # Footer cat << _footer_ _footer_ } sw_style() { if [ -f $CDIR/$STYLE ]; then echo '' fi } # Set input dir IDIR="`echo $1 | sed -e 's,/*$,,'`" if [ -z "$IDIR" ] || [ ! -d $IDIR ]; then echo "Usage: sw [dir]" exit 1 fi # Load config file if [ ! -f $PWD/sw.conf ]; then echo "Cannot find sw.conf in current directory" exit 1 fi . $PWD/sw.conf # Setup output dir structure CDIR=$PWD ODIR="$CDIR/`basename $IDIR`.static" rm -rf $ODIR mkdir -p $ODIR cp -rf $IDIR/* $ODIR rm -f `find $ODIR -type f -iname '*.md'` # Parse files cd $IDIR FILES=`find . -iname '*.md' | sed -e 's,^\./,,'` for a in $FILES; do b="$ODIR/`echo $a | sed -e 's,.md$,.html,g'`" echo "* $a" sw_page $a > $b; done exit 0