pyratelog

personal blog
git clone git://git.pyratebeard.net/pyratelog.git
Log | Files | Refs | README

preview (816B)


      1 #!/bin/bash
      2 
      3 # use arg as title and set entry file path
      4 TITLE=$1
      5 ENTRY="entry/${TITLE}.md"
      6 
      7 # create a tmp dir
      8 mkdir demo
      9 
     10 # copy entry file, entry_template and css
     11 # to temp dir
     12 cp ${ENTRY} demo/index.md
     13 cp entry_template.html style.css demo/
     14 
     15 # small change to entry_template for stylesheet
     16 sed -i 's%\.\./%%' demo/entry_template.html
     17 
     18 # generate html file
     19 pandoc -s \
     20 	--template=demo/entry_template.html \
     21 	--metadata title="demolog" \
     22 	-f markdown \
     23 	-t html \
     24 	-o demo/index.html \
     25 	demo/index.md
     26 
     27 # start web server and capture pid for later
     28 busybox httpd -f -h ./demo -p 8080 &
     29 busypid=$!
     30 
     31 # open demo entry file in browser
     32 xdg-open http://localhost:8080
     33 
     34 # wait until ready to stop web server
     35 echo press any key to cancel
     36 read -n 1
     37 
     38 # kill the web server and remove temp dir
     39 kill -9 ${busypid}
     40 rm -rf demo/