Slowly I'm getting acquainted with Octopress and really like it! The design is very nice and blogging is just a pleasure and very convenient.
At first, the fact that I had to install ruby (I don't use ruby in my everyday development) on every machine I want to post from was a bit annoying. I'm currently using an svn server for versioning of my files, so I came up with the idea to write an automatic post-commit hook script to generate the Octopress pages and deploy them automatically.
After a little fiddling around with the linux shell, I ended up with the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#!/bin/sh REPOS="$1" REV="$2" # The directory where you checked out octopress. It must contain the 'octopress' subdir. CHECKOUTDIR="/your/checkout/dir" # ruby and gem binary folders to be added to the path. Contain rake and ruby bin-files. E.g.: PATHDIRS="/home/youruser/.rvm/ruby-1.9.3-p237/bin:/home/youruser/.rvm/bin" # Your public web-folder for the blog. BLOGDIR="/your/www/folder" # Your Email-address EMAILADDR="firstname.lastname@example.org" # From Email-address (may be arbitrary) FROMEMAIL="email@example.com" # Create a message variable for svnnotify MESSAGE="Updating blog from svn-commit. svn update:" # Change to working directory cd $CHECKOUTDIR # Update it to the current revision MESSAGE="$MESSAGE`svn update 2>&1`" # Change into blog directory cd octopress # Adjust the path variable. Include the ruby bin-folders. export PATH=$PATH:$PATHDIRS # Generate the blog contents MESSAGE="$MESSAGE Invoking rake: `rake generate 2>&1`" # Sync the files with the blog directory MESSAGE="$MESSAGE Invoking rsync: `rsync -rl --delete --stats public/ $BLOGDIR 2>&1`" # Send email notification svnnotify --repos-path $REPOS --revision $REV --to $EMAILADDR --from $FROMEMAIL --footer "$MESSAGE" # Exit. exit 0
This script will update the blog after an svn commit and sends you an email via
telling you about the changes. The email contains all important outputs from the svn update
and rake generate commands as well as the details about the synchronization with your
Take care that the svn user (executing the post-commit script) has permissions to access all respective folders. It is necessary to create the working directory manually and do an initial checkout from the repo.
Happy blogging! :)
Edit: By the way, I had a problem with the charset since I use German characters on my disclaimer page. This was quickly fixed adding the lines
export LC_CTYPE=de_DE.UTF-8 export LANG=de_DE.UTF-8
to very the beginning of the script after the shebang, to set the console charset. This fix was originally suggested on this issue page.