/ dev

Automating pelican

So following on my post about moving back to pelican I needed to automate some stuff. Google wasn't quite giving me the answers that I wanted. What I wanted was a full end to end automation process, i.e. I write a post, it appears on my blog. I did a bit of thinking and decided there were 2 steps to this: * Source content and pelican creation of output * Publishing the output to github Starting at the beginning then, I have my output folder setup as its own github repo at http://chvck.github.io, the rest of the blog setup and the theme will go into another repo which will have the content and output folders ignored (I'll explain why the content is ignored later). To publish the output it seemed pretty obvious that I needed to have some sort of git auto commit folder watcher. There are a few git auto-commit hits on google so one of those plus a post-commit hook to push was my first idea. But, then I found gitwatch which is a handy script that handles all of this for me. Worth noting, I have a ssh key stored with ssh-agent so I don't need to enter a password to push. OK cool, so now when my output folder is updated then it gets published. Rad! Next step, and this one was tricker, was to work out how to automate the output generation. Well, pelican has a -r switch which means that it monitors the content directory for changes. OK cool, that's easy. Problem for me was that I didn't want my content directory to simply be a directory on my local filesystem, this would mean I could only post from my PC. I also wanted to be able to easily post from my mobile (and easily add images). Hey, google drive support is now kinda built into some linux distros. Cool! No, not so great. Whilst it is built in it's not great. For me it was really, really slow and it also doesn't do offline sync i.e. it won't update a local copy of something until you open it (well, containing folder). Hmm. Then I found overgrive which claims to do what the official google drive apps do on windows/macos. For $4.99 I figured it was worth a go (turns out there's a free 14 day trial too, didn't know that though) and it's good. It's fast and it does offline sync... great! Next up I put all of my current content into a dir on google drive and then I symlinked that folder as my pelican content directory. Using the -r switch in pelican I now have automated generation. So that's generation and publishing sorted. Rad! Final piece of the puzzle is something that means that I can write posts directly on google drive (I use markdown which google drive doesn't support). Enter stackedit, a web app that I can use from any online device. It lets you write markdown (even gives a live preview of the processed markdown) and save it to google drive. So, with any luck, this post is going to be saved from stackedit and it'll appear on my blog. Here we go! Edit: It works!

Automating pelican
Share this