echo making html... mightNeedNewToC=false; if uname | grep -q "Darwin"; then modTimeFmt="-f %m" # BSD else modTimeFmt="-c %Y" # GNU fi # kludgy to look only at top level and one level down: for m in *.md */*.md; do bn=`basename $m .md`; if [ "$bn" == "navigation-menu" ] then # This one MD file is inserted on every call to pandoc # and should not on its own be converted to html continue fi # echo $m; outfile=$bn.html dn=`dirname $m`; if [ "$dn" == "raw" ] then echo skipping raw/ continue elif [ "$dn" == "doorsigns" ] then echo skipping doorsigns/ continue fi pushd $dn > /dev/null; # figure out how many subfolders down we are so we can link to # the top-level README.md thisDir=`dirname $m`; if [[ $thisDir == "." ]]; then # this is a top-level .md file like toc.md or README.md homePrefix=""; else # XXX should really do this right for arbitrary nesting: count # the number of "/" characters, etc. For now assume just one level. homePrefix="../"; fi infile=${homePrefix}$m # if [ -f $m ] ; then # infile=$m; # else # infile=../$m; # fi if [[ -e $outfile ]] ; then outfileModTime=`stat $modTimeFmt $outfile` else outfileModTime=0 fi commitTime=`git log -1 --pretty="format:%at" $infile`; if [ -z "$commitTime" ]; then # XXX Kludgy way to check if a file will be gitignored # Should do it properly so it works with wildcard syntax ignore=`grep $infile ${homePrefix}.gitignore` if [ -z "$ignore" ]; then echo $infile "is not yet in git" fi commitTime=0 fi if [[ $outfile -nt $infile && $outfileModTime -gt $commitTime ]] ; then popd > /dev/null; continue # nothing to rebuild, move onto next .md file fi nicetitle=`echo $bn | tr '-' ' '` ; if [[ ! $nicetitle =~ "CCRMA" ]]; then nicetitle="CCRMA $nicetitle"; fi # Generate the link back to this file's entry in the table of contents linktarget=`echo $bn | \ tr '[:upper:]' '[:lower:]' | \ tr '-' ' ' | \ tr -d '[:punct:]' | \ tr ' ' '-' | \ tr -s '-'`; toclink="${homePrefix}toc.html#${linktarget}" toclinkfile="/tmp/toclink.md" rm -f $toclinkfile echo "([contents of this file](${toclink}): links to each section)" > $toclinkfile # Say when this file was updated datefile="/tmp/rightnow"; rm -f $datefile; touch $datefile; if [[ $outfile != "toc.html" && $outfile != "index.html" ]]; then commitDate=`git log -1 --pretty="format:%ad" $infile`; commitAuthor=`git log -1 --pretty="format:%an" $infile`; git diff --exit-code -s $infile; uncommitted=$?; echo "
This page of CCRMA documentation" >> $datefile; if [[ ! -z $commitDate ]]; then echo "last committed on $commitDate by $commitAuthor." >> $datefile; else echo "is not yet in the git repository." >> $datefile; uncommitted=1; fi if [[ $uncommitted -ne 0 ]]; then echo "This page was built with uncommitted changes on `date` by `whoami`." >> $datefile; fi echo "Stanford has a page for Digital Accessibility." >> $datefile; fi # echo infile $infile outfile $outfile nicetitle $nicetitle echo " " $infile to $outfile...; pandoc "${homePrefix}navigation-menu.md" $toclinkfile $infile \ -o $outfile --css "${homePrefix}css/pandoc.css" \ --metadata pagetitle="$nicetitle" \ --metadata date="`date -u '+%Y-%m-%d'`" -A $datefile -s; popd > /dev/null; if [[ $m -nt toc.md ]] ; then echo " " \($m is newer than toc.md\) mightNeedNewToC=true; fi done if [ $# -eq 0 ] ; then if $mightNeedNewToC ; then echo " " You might want to rebuild the table of contents \(by passing any argument to this script\). fi else echo Remaking toplevel index... ./buildindex.sh > index.md echo Remaking table of contents... ./buildindex.sh toc > toc.md echo Recursively calling build.sh to make toc.html from new toc.md echo and to make index.html from new index.md ./build.sh fi echo done