Publishing from Day One to Pelican with Hazel and Dropbox
Posted on 2016-08-19
I'll be soon embarking on a long bike tour and was searching for a way to keep a journal of my trip but also post updates to a website. Day One was an obvious journaling choice, but with version 2, publishing isn't yet available. With a little poking around, it turned out to be fairly easy to export Day One entries and publish to Pelican (my static blog generator of choice).
I've not been a heavy user of Day One, and with the new version, I've stopped entirely until they provide end-to-end encryption with their proprietary sync service. Journaling my bike trip isn't anything I'm worried about being out in the open, and so I'll use it to keep a log of my days on the trip. At the same time, I want to keep my friends and family up-to-date on my trip. Since I use Pelican for this site, it seemed like a reasonable choice to use it for this trip and use Github Pages as an easy, free place to host it.
The first step was getting the Pelican site set up. I used the basic quickstart and put in a custom theme that I found online. The only modifications I made was using the photos plugin to make it easier to add galleries if I want in the future. Publishing to Github Pages is trivial. You can follow the steps here.
Now the fun part. Day One lets you export a journal entry as Markdown. When exported, it's compressed into a zip file which includes a folder of photos if you've included any in the journal entry. For each post, I use the export action and then upload to a folder I've created in Dropbox. I have Hazel watching this folder which will do the following:
- Unarchive any file that appears
- Move the unarchived contents into a new folder I unoriginally name "decompressed"
I then have a separate rule watching "decompressed" which will
- Move any image file type into my blog's images folder
- Move any text file into the content folder
Step 2 here requires a little bit of extra work. Day One has some weird formatting issues and I also need to update the image urls in the entry to match what Pelican expects. The script isn't my finest, but it takes care of everything
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 |
|
Now the file is cleaned up and in the right place. We can now publish and push to Github.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
That's it! You can see the posts and follow my bike tour at http://rjames86.github.io
Tags: hazel pelican automation dropbox