Taking WordPress Blogging Offline

After my extremely annoying experience with a broken network connection last weekend that cost me about an hour of writing, I've been thinking about what could be done to make sure such a thing couldn't happen again. I believe looking into offline access for WordPress may represent a viable solution.

I think having offline access to your blog's post writing would be a great feature to have for blog authors. It means, for example, that you'd be able to take a laptop on holiday with you and know that you can at least

write your blog posts when they're in your head and you can upload them to your server when you have an internet connection.

It also means that you wouldn't need to have WordPress connected to the internet to be able to save posts. This means that clicking save has no chance of losing your work since it is saved to a local database. Another side effect is that periodically saving the post can occur much more frequently since local access is much faster and lower latency than accessing a remote server.

The problem, naturally, is how to implement this new functionality.

I think that offline access to the entire blog administration area is going to be practically impossible. This is mostly because of WordPress's extremely flexible plugin system which means no two blogs can never be assumed to contain the same features. In fact, most blogs would have quite a number of modifications to the admin area such as SEO optimisations for posts and pages, comment filters, related posts and so on. This is, of course, to say nothing of the options for all of those plugins, as well as the themes used for the blog. So, overall, I believe true offline functionality would need to be limited to the "write" pages and, even then, the functionality of the system would need to be limited to the bare essentials: title, post content, optional excerpt, categories, trackbacks, and the post options such as post slug, post status, etc. Other pages could still be shown from a cached version with "disabled in offline mode" in a lightbox or something.

So if we just want to enable offline post editing then a plugin needs to be created that loads the required offline access API (I thinking Google Gears) and all the client-side JavaScript to handle it. Presumably the plugin itself is not hard. The client-side logic would be more difficult. There is first the question of whether or not to allow "modal" or "modeless" offline access, which basically asks the question of whether or not to make offline "transparent" to the end user. If they lose their internet connection does everything keep working with reduced functionality (modeless) or do you require the user to switch into offline mode (modal)? To solve the initial problem I was discussing you would ideally want modeless access but then you have great problems reconciling the full functionality of the WordPress system when connected with the reduced functionality when there is no connection. For example, when connected you would naturally allow any and all plugins but what do you do when the connection is lost? The user will have had access to extra fields that the client-side code did not know about and so would not save. Hardly a great solution!

Some of my programmer intuition (is there such a thing?) tells me that there might be room for a devious system design that could read the code of the rendered writing page, pick out all the extra fields that are placed in there by plugins and add these dynamically to the local database store. This would effectively get around the reconciliation issue. I'm not how easy that would be to implement but my brief foray into jQuery makes me think it shouldn't be that hard to detect "new" input fields.

There are still synchronisation issues but these are present in any web application wishing to provide offline functionality.

Overall, I'd say an offline WordPress system is definitely possible but how much work involved to get around some of the issue may be another matter entirely. I shall endeavour to look into the creation of a "WordPress Offline" plugin once I have time. :)