#!/usr/bin/env zsh DIR=`dirname $0` CMD=`basename $0` { test -r $DIR } || { echo "error: launch webnomad commands from your project directory" echo "i.e: ./$DIR/$CMD" return 1 } source ${DIR}/utils { test -r config.zsh } || { error "Directory not configured for WebNomad. First use ./webnomad/init" exit 1 } source config.zsh notice "Rendering $BRAND website" act "Title: $TITLE" source ${DIR}/render source # Main mkdir -p test mkdir -p test/css # side menu stylesheet cp $DIR/css/jquery.sidr.dark.css test/css fonts=('Arial' 'Arial Black' 'Comic Sans MS' 'Courier New' 'Georgia' 'Impact' 'Monaco' 'Lucida Grande') fonts+=('Book Antiqua' 'Tahoma' 'Times New Roman' 'Trebuchet MS' 'Verdana' 'Geneva' 'New York') custom_fonts=() total_fonts=${#fonts} # string match case insensitive unsetopt CASE_GLOB # if there are custom fonts add them { test -d fonts } && { notice "Indexing custom fonts" rm -f test/css/custom.fonts.css mkdir -p test/fonts ttf=`find -L fonts -iname '*.ttf'` for f in ${(f)ttf}; do ffile=`basename "$f"` cp "$f" test/css/"$ffile" custom_fonts+=("${ffile%.ttf}") cat <> test/css/custom.fonts.css @font-face { font-family: '${ffile%.ttf}'; src: url('$ffile') format('truetype'); } EOF total_fonts=$(( $total_fonts + 1 )) done otf=`find -L fonts -iname '*.otf'` for f in ${(f)otf}; do ffile=`basename "$f"` cp "$f" test/css/"$ffile" custom_fonts+=("${ffile%.otf}") cat <> test/css/custom.fonts.css @font-face { font-family: '${ffile%.otf}'; src: url('$ffile') format('opentype'); } EOF total_fonts=$(( $total_fonts + 1 )) done act "$total_fonts custom fonts indexed" } fonts=($custom_fonts $fonts) # render all HTML views htmls=(`find views -type f -name '*.html'`) for src in $htmls; do # read meta commands cat ${src} | read_meta # compute destination file dst="test/`basename ${src%.*}`$EXTENSION" render_header > $dst # close as nothing else is needed cat <> $dst
EOF # navbar cat tmpl/navbar.html >> $dst # start the body of article cat <> $dst

 

Design test
EOF # render html act -n "Html rendering: $dst " cat $src | render_html >> $dst cat <> $dst

 

Design test

EOF # Font size selector font-size_select() { cat < EOF c=.5 while [[ $c -le 8 ]]; do cat <${c%.} em EOF c=$(( $c + .5 )) done cat < EOF } print "

H1 font size

" >> $dst font-size_select h1size >> $dst print "

H2 font size

" >> $dst font-size_select h2size >> $dst # font family selector font-family_select() { cat < EOF for f in $fonts; do cat <$f EOF done print "" } cat <> $dst

Brand font family

EOF font-family_select brand-font-family >> $dst cat <> $dst

Header font family

EOF font-family_select header-font-family >> $dst cat <> $dst

Body font family

EOF font-family_select body-font-family >> $dst cat <> $dst

Navigation Font family

EOF font-family_select nav-font-family >> $dst cat <> $dst
EOF render_footer >> $dst act "done" done for m in `find views -mindepth 1 -type d `; do act -n "publishing $m... " rsync -r $m test/ print "done" done # add design test libs mkdir -p test/js cp $DIR/js/jquery.min.js test/js cp $DIR/js/jquery.sidr.js test/js