I was very excited about getting the Epistle Retriever to work with Monolog, Behat and all the other sorts of things needed to make a proper software project. Mainly as an exercise to get used to it, but also because I’d quite like to get the product out there.
But now postach.io exists, which is pretty much the same thing. It uses Evernote rather than Epistle (which is a better idea because that doesn’t limit it), and then provides a full hosted site (and a CMS or something? Sounds a bit counter-invuitive).
So I’d like to get it out there, but it’s really only for jekyll-heroku sites and needs to be hosted on the user’s site…
Not sure how this would actually work out. But whatever, let’s plan this stuff out.
The current app has a number of functions, starting with:
- Instantiate the Dropbox client
- Get the UID from the session
Then it branches:
- If the Dropbox object isn’t authorised, then set the return URL, add the request token to the session, and send the user to Dropbox.
- If we’re coming back from Dropbox, get the request token from the session, get the access token from the Dropbox object - how? - and save the access token / UID pair.
- If there’s an access token, set it on the Dropbox object.
After all this, do this sequence:
- Get all the files in the folder, loop over them.
- If there’s no metadata file locally, or the local metadata revision is lower than the vision in Dropbox, then mark this as a file to download.
- If we should get this file, mark the fact that we’ve downloaded any file.
- Put the title in the file and save it to the local cache.
- Find the existing post via rake find - if it exists, then use that date, otherwise use today’s date.
- Save the file as date - slugified name.
- Copy to the jekyll-heroku _posts directory
- Run git add on the _posts file
- Run git commit
If we downloaded any files at all, then do this:
- Run jekyll –no-auto to regenerate the site
- Add the _site directory to git
- Git commit
- Git push using the passphraseless keyfile.
So how to get this working in a better context than a single index.php? Let’s try some BDD using those requirements above, and as different sections have been abstracted into looped parts, they can be objectified and have parameters passed to them.