DOTA2 LogoIf you see this, run. Away.

I have recently been writing more and more (or, at least, trying to), mainly because I’ve been busying myself with a variety of interesting things and I figured that writing about them could help other people. I am fully expecting to fall back into a DOTA2 binge one of these days and completely cease all productive endeavors, but I’m enjoying it while it lasts.

One of the frustrating things about writing for this website, at least with my current setup, is the interface. I wrote this website in Python using Django because:

  1. It’s what I know best.
  2. I wanted some flexibility.
  3. I just like overcomplicated solutions to simple problems.

The Django admin interface, though, is less than stellar when it comes to writing, because it simply wasn’t meant for that. I write most of my posts in Markdown, so I would like to avoid fiddling around in a plain edit box and use the excellent MdCharm editor on my desktop to write my posts. So, I’ve been doing just that, but navigating to the post page on the site always takes many, many clicks, and copy/pasting between the editor and the web interface is very cumbersome. It would be much simpler if the site could just read the file I’m writing in and post that.

…you can probably see where I’m going with this.

Getting files to the web is something Dropbox does pretty well, and they have an API, so it was only reasonable that I should write some code to integrate Dropbox to my blog.

Man sitting in boxI am enjoying this integration a lot.

Luckily, Dropbox makes such a thing easy with the concept of apps, which are basically folders in your Dropbox that are the only place a specific app can access. I created a “Stavros’ Stuff” app and gave it access to my Dropbox folder. I tried to use the Python API, but it turns out it doesn’t work very well with AppEngine, so I just used the REST API instead, which was equally simple to use (for authentication, you pretty much only need to send the OAuth access token in the Bearer header, which was a bit underspecified in the documentation).

A few hours later, integration was fully working, and it is bidirectional. This means that, whenever I write or edit a post on the web interface, it will get posted to my Dropbox folder, so I have a complete copy of all the posts at any time, and adding new files to the Dropbox folder will automatically create and post them on the site.

This is awesome.

I am previewing this post that way right now (well, when I was writing it, anyway. It’s published now), and it is fantastic how well it works. I can save it, refresh the page and see it online, as if my site were running on my local machine. This will definitely make writing and keeping up with people’s corrections much easier, and I have noticed that it also makes me want to write more (which, I hope, is a good thing).

Please leave a comment (or email me) if you need any clarification on the integration or have any feedback whatsoever. Thanks!