Yesterday I covered how I’m handling scheduling with my Jekyll-based blog. The at command I mentioned there could be used in tandem with any static blogging system. Today I’m dropping in the “publish” task from my Rakefile, so you can see how I apply it specifically with Jekyll. The concepts are still portable, though.
The rake task can be run with or without an argument. If the argument is there and it’s a filename (and the file exists), it operates directly on that file. If no argument is passed, it offers a menu of available drafts to choose from.
To schedule a post, I just set the “date:” field in the YAML headers to a date in the future. That triggers all of the scheduling features. If the task is being run from the shell, it double checks with you for confirmation that you want to schedule a deploy. If confirmed (or forced), at is run and reads from a file with the necessary commands to generate and deploy the task. In my case, it bumps the site version (used to bust cache on any CSS/JS files), runs a generate task and deploys the site using Rsync.
I’ll be covering my “draft” system in more detail in a future post. I’ll mention a relevant part of it now, though. The _drafts folder is a symlink from my Dropbox writing folder. If a post shows up in there with a “publish_” prefix in the filename, Hazel triggers this system automatically. It passes a filename directly, bypassing the need for any shell interaction. The file gets published and the site gets deployed. There’s also an incomplete “preview_” mode that will generate the staging site but not deploy.
Here’s the relevant part of the Rakefile with lots of comments. For people who would be implementing something like this, they should be explanatory enough. Because it’s a work-in-progress, I’m posting its current state directly. When it’s closer to finished it will be included in a full Git repo of all of my hacks with its most current version.