Apr
11

Blogging Autosave

Filed under: Asides | April 11th, 2005
Post

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)

25 Responses

Remi P. | April 11th, 2005 @ 10:58 am

I guess it would be cool.

Denis de Bernardy | April 11th, 2005 @ 11:05 am

yup. it’s a much better approach than the js that autoloads in the background. you might even want to add it as a default in wp.

Chad | April 11th, 2005 @ 11:25 am

I find the “Save and continue editing” button to be good enough. Isn’t saving often a basic computer usage guideline?

XeroCool | April 11th, 2005 @ 11:31 am

I think It would be cool :). The deleted posts could go in a DB table and you can recover them with a couple of clicks via WP admin CP.

Craig Hartel | April 11th, 2005 @ 11:31 am

@Chad,

Isn’t eating right, getting lots of exercise, drinking moderately and not smoking a basic life guideline? :P

Peter | April 11th, 2005 @ 11:48 am

You might want to check with the guys at Frassle to see how they’re implementing their auto-save feature.

Matt | April 11th, 2005 @ 12:11 pm

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.

Phil Boardman | April 11th, 2005 @ 12:34 pm

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.

Craig Hartel | April 11th, 2005 @ 12:42 pm

I volunteer to test it…if there’s one person that I know who can break stuff, it’s me. Let’s do it. Now.
…dreaming of learning how to code…

Eli Sarver | April 11th, 2005 @ 12:47 pm

I would prefer a save as draft for ‘pages’ before this. It’s kinda annoying how it’s always an insta-publish with these documents.

Phil Boardman | April 11th, 2005 @ 1:09 pm

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.

Mike Purvis | April 11th, 2005 @ 1:39 pm

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.

Tom | April 11th, 2005 @ 1:47 pm

Auto-save would be a welcome idea!

Tim | April 11th, 2005 @ 3:01 pm

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.

Mark J | April 11th, 2005 @ 4:20 pm

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.

CarLBanks | April 11th, 2005 @ 7:21 pm

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.

Tim | April 11th, 2005 @ 7:54 pm

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.

Gregory Wild-Smith | April 11th, 2005 @ 10:48 pm

Hmmm… that seems like a productive way to spend an afternoon. I’ll have a look at doing that.

Chris J. Davis | April 12th, 2005 @ 6:51 am

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.

Lee | April 12th, 2005 @ 10:51 am

Your timing, as ever, is impeccable:

http://ifindkarma.typepad.com/relax/2005/01/life_in_a_texta.html

Gregory Wild-Smith | April 12th, 2005 @ 11:25 pm

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.

Gregory Wild-Smith | April 13th, 2005 @ 5:54 am

I’ve got this working as a plugin, ish.. its cludgy atm, but I’ll tidy it up when I get back from work and post it up when I’m done.

TedFox | April 14th, 2005 @ 9:57 pm

looking forward to what Gregory is going to post

Jeff Minard | April 16th, 2005 @ 1:46 pm

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…

Ederic | April 13th, 2006 @ 3:35 am

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

Share your thoughts