#!/bin/bash ODP=$1 PDF=$2 if [ -z "$ODP" ]; then echo "Syntax: $0 presentation.odp [presentation.pdf]" exit fi if [ ! -e "$ODP" ]; then echo "OpenOffice presentation $ODP does not exist" exit fi if [ -z "$PDF" ]; then PDF=$(dirname "$ODP")/$(basename "$ODP" .odp).pdf fi if [ ! -e "$PDF" ]; then echo "PDF $PDF does not exist" exit fi ODPNAME=$(basename "$ODP") PDFNAME=$(basename "$PDF") RND=/tmp/ppm$RANDOM echo Converting PDF to images mkdir $RND PREFIX=$(echo "$PDF" | python -c "import sys,re; print ''.join([x[0] for x in re.sub('[^a-z ]','',sys.stdin.read().replace('/',' ').lower().strip()).split()])") SLUG=$(echo "$PDF" | python -c "import sys,re; print re.sub('[^a-z0-9-]','',sys.stdin.read().split('/')[-2].lower().replace(' ','-'))") TITLE=$(echo "$PDF" | python -c "import sys,re; print sys.stdin.read().split('/')[-2]") pdftoppm -scale-to 350 "$PDF" $RND/$PREFIX >/dev/null 2>&1 for f in $RND/*.ppm; do convert $f $(dirname $f)/$(basename $f .ppm).png; done rm $RND/*.ppm echo Copying presentation and PDF to folder mv $RND $SLUG cp "$ODP" $SLUG cp "$PDF" $SLUG SLIDES=$(ls $SLUG/*.png | wc -l) DESCFILE=$(dirname "$ODP")/description DESCRIPTION=$(cat "$DESCFILE") TRANSCRIPT="" for f in `seq 1 $SLIDES`; do TXT=$(pdftotext -f $f -l $f "$PDF" -) TRANSCRIPT="$TRANSCRIPT
  • $TXT
  • " done cat > $SLUG/index.html < $TITLE

    $TITLE

    a presentation by stuart langridge

    $DESCRIPTION

    Download as OpenOffice · Download as PDF

      $TRANSCRIPT
    ENDMSG cat > $SLUG/stepper.js <>")); lip.onclick = function() { imgstep.changeBy(img, -1); }; lin.onclick = function() { imgstep.changeBy(img, 1); }; imgstep.lii.className = "slideof"; lip.className = "direction"; lin.className = "direction"; ul.appendChild(lip); ul.appendChild(imgstep.lii); ul.appendChild(lin); img.parentNode.appendChild(ul); }, changeBy: function(img, inc) { var src = img.src; var parts = src.split("-"); var num = parts[parts.length - 1]; var numlen = num.length - 4; // remove .png; var i = parseInt(num, 10); // specify base 10 or it's octal i = i + inc; if (i > imgstep.SLIDES) { i = 1; } if (i < 1) { i = imgstep.SLIDES; } zeroes = ""; for (var idx=0; idx < numlen; idx++) { zeroes += "0"; } var newnum = zeroes + i; newnum = newnum.substr(newnum.length - numlen); var first = src.substr(0,src.length - 4 - newnum.length); var last = src.substr(src.length - 4); var newsrc = first + newnum + last; img.src = newsrc; imgstep.lii.firstChild.nodeValue = i + " of " + imgstep.SLIDES; imgstep.setAlt(img, i); }, setAlt: function(img, idx) { var li = document.getElementById("transcript").getElementsByTagName("li")[idx-1]; img.setAttribute("alt", li.firstChild.firstChild.nodeValue); } }; imgstep.init(); ENDMSG cat > $SLUG/style.css <