Auto generate Pelican blog from Dropbox

· 296 words · 2 minute read

This is my notes for how to update my Pelican blog automaticlly when I write new posts. See Creating a blog based on Pelican for getting started with Pelican blog engine.

A way to be able to blog from anywhere is to use Dropbox as repository for the your blog. Then let Pelican auto regenerate the blog on changes in the Dropbox folder.

A prerequest for this recipe is that /var/www is not directly exposed to the web.

Preparing Dropbox 🔗

First create a new Dropbox account and create a Pelican folder. Share this folder with your main Dropbox account. Now copy the sources for your Pelican blog into the the shared folder.

On your web server, install Dropbox under the www-data user.

cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -

Then link up the new Dropbox account to the web server by accessing the link you get from starting the Dropbox daemon.

~/.dropbox-dist/dropboxd

Edit crontab for www-data, crontab -e, to start Dropbox daemon if it’s not running. useful when the server reboots.

*/5 * * * * pgrep -F ~/.dropbox/dropbox.pid >/dev/null || (~/.dropbox-dist/dropboxd &)

Now Dropbox should be in sync and have your latest source for the blog.

Autogenerate blog on change 🔗

We need to install Pelican blog engine and incron to trigger auto generation of the blog on changes in the ~/Dropbox/Pelican/content folder.

sudo apt-get install python-pelican python-markdown incron

Edit DROPBOX_DIR the the Pelican Makefile to point to the VirtualHost which stores the blog.

Then allow the www-data user to run incron.

echo www-data | sudo tee -a /etc/incron.allow

And as a final step make the incrontab entry for www-data with ìncrontab -e

/var/www/Dropbox/Pelican/content IN_ATTRIB,IN_CREATE,IN_DELETE,IN_NO_LOOP make --directory /var/www/Dropbox/Pelican dropbox_upload

Now Pelican will recreate the blog on each change in ~/Dropbox/Pelican/content. Happy blogging!