Blogging Autosave

This Blogger autosave feature is something I’ve been wanting to do for WordPress for a while, but I had envisioned it as an asynchronous javascript updating the draft every minute or so if the post was over 50 words long. Perhaps this cookie approach is better. Anyone want to try it for WP?

25 thoughts on “Blogging Autosave

  1. It costs us next to nothing to save all the time, so why not? It’ll be worth it that one time you lose a post, I know I’ve lost tons of stuff even though I know better to save more often.

  2. I’ve written a few scripts that do this sort of thing to give “wiki-ish” functionality to a static html page (using javascript). I can send you what I’ve got if you want it.
    It saves the contents of a text field as a cookie using a “title field” as part of the cookie “key”. It also lists all the keys it has saved too.

  3. From my understanding, “Pages” are just posts with their “status” set to “page”. This means to have drafts for pages you’d need to add “Page Draft” to the list of status options – not a bit deal, but could break a number of things.

  4. I briefly played with a form-save feature that kicked-in on the unLoad event. It just serialized all the form fields and dumped them to a cookie. Then, when you returned to the page, it spawned a little link asking if you’d like to repopulate. *searches for the code*

    30-second autosave would be pretty sweet, though.

  5. Hey Matt, if this actually happens, the ‘Save and Continue Editing’ button could be changed as well to call the javascript function that saves the cookie (if it’s implemented as a cookie); instant saving with no reloading required.

  6. Tim, that would make me nervous. I sort of take comfort knowing that when I save a post, lightning could strike my computer, and my post would be safe. Of course, it would be really cool if we used AJAX to “Save and Continue Editing,” so I like the general “don’t have to reload” concept.

    One limit that I can forsee is the 4KB per cookie limit. For that reason, tend to think an AJAX/MySQL method might be more reliable.

  7. The only thing about cookies is what if somehow your browser window gets closed and the cookes all get cleared. This has happened in Firefox to me.

  8. Mark J, after considering the consequenses, I realized what importance the ‘Save and Continue Editing’ button’ has, and why javascript should not be used for that button. Sure, it would be great for instant retrival of posts (for times when your computer does not crash and your cookies continue working), but what about people that rely on that button to save their posts to the database? Those that use it to save wouldn’t be ‘Saving’ their post, just making a temp draft copy for restoration in case something happened, and their posts would only exist in their cookies, not on their sites.

    I do foresee an ‘AutoSave’ section in the WordPress options in the future though with a customizable time limit for autosaving.

  9. And why are we not just inplementing this with AJAX and a timer function? I have the timer bit done on an autosave plugin for WP, I just haven’t gotten around to creating the AJAX bit yet.

    Might have to now.

  10. Chris – AJAX would make sense for general saving, but for an auto-save its a bit much, especially as you’d be saving after every keystroke or word. You’d be slamming your server with requests that are… well.. pointless.

    Plus it would eat bandwidth, not by much, but it would. Also this means that if I want to save it to a draft manually (good from a UI point of view) then I can specifically press a button. Just like an auto save doesn’t save into the same file you wouldn’t want to be overwriting all you did before.

    Timer’s aren’t really the best solution either. Ideally you’d capture a keypress, or just the space and full stop.

  11. especially as you’d be saving after every keystroke or word.

    No no, only save every X seconds (30 would be fine) IF the post is Y (say 50) characters longer/shorter than it was last. That would work great as an AJAX implementation. In fact, it could quite easily be done with a plugin that just shoves the JS into the wp_head() call.

    Have the JS create a “fake” post request and send it to the server. The only big issue is that there isn’t a simple “update-post.php” as far as I know. You might have to make the plugin do it manually since when you update a post in WP normally, it’s a big deal processing the whole post-edit page and returning a huge pile of results.

    Wait, isn’t there some kind of XML interface that could be used for this as well? Hrm…

  12. I’ve just finished writing a long entr about having to work on a good Friday. When I clicked “publish,” was a the next page was blank. Must be a server error or due to my dialup connection. Whatever the case was, I could only wish WP had an autosave feature like that of Gmail. :p