Page 1 of 2

New Plugin: Autosave in Browsercache

Posted: Sun Jun 09, 2013 12:31 pm
by onli
When logging into serendipity without the "remember me" setting enabled it happens that after some time one gets logged out. If writing an article at that time and trying to save it, the data is normally lost, as the browsers don't seem to properly cache the content of the textareas used. A disconnect can have the same effect.

We already have the autosave-plugin for that, but it never worked for me. I also disliked the approach to save the data on the server, as this will also fail on a disconnect.

The attached plugin will save the content of both the normal editor and the extended one automatically every 5 seconds in the browser, using indexeddb. This is supported by all modern browsers (http://caniuse.com/#feat=indexeddb), bot not on mobile devices thus far.

I aim to integrate it into 2.0, but it should work on 1.7 as well. Would be nice if someone can write whether it works for him.

Re: New Plugin: Autosave in Browsercache

Posted: Sun Jun 09, 2013 1:46 pm
by garvinhicking
Hi!

I'd love to not have two plugins for that, but rather offer an option in the autosave plugin to do the local saving. I'd also opt for making that the default option, since autosaver was always really heavy on the complexity side :)

Or do you mean you want to integrate this functionality into 2.0 not as a plugin but a core thing? So that you wouldn't want to put this as a plugin into spartacus? (Fine with me as well, I do think this could be core functionality!).

Regards,
Garvin

Re: New Plugin: Autosave in Browsercache

Posted: Sun Jun 09, 2013 1:55 pm
by onli
Yes, I thought that having this functionality as one of the default-plugins in 2.0 would be a good idea. I even thought about writing this directly into the core, but this wouldn't make it easier, having it as a plugins fits better. Though the javascript for the cache proabably fits into serendipity_editor.js.tpl, we could use it in other places as well.

Re: New Plugin: Autosave in Browsercache

Posted: Sun Jun 09, 2013 2:10 pm
by garvinhicking
Hi!

I'm just thinking of the overhead it imposes to the event plugin (RAM), and since it's a rather small functionality, it feels a bit odd to have it as a plugin?

I think adding this directly to the core backend template and wiring it into serendipity_editor.js would be better for the user, because otherwise we also need upgrader functions to install the plugin automatically, etc... sounds like maintenance hell, for both developers and users ;)

(I do think this is functionality that no one would actually turn off or NOT need, so I think forcing it on the user shouldn't hurt?)

Regards,
Garvin

Re: New Plugin: Autosave in Browsercache

Posted: Sun Jun 09, 2013 2:16 pm
by onli
Ok. I am a bit surprised, but that is fine :)

Let's wait if we get some reports. Maybe it proves to be less hassle free than we expect. But if everything goes fine, we or I can add this to the core later on (But yes, I expect that no harm is possible, if the machine isn't really really slow).

The whole functions_entries and the preview_iframe-area needs to get some work in regard of the smartification anyway.

Re: New Plugin: Autosave in Browsercache

Posted: Thu Jun 13, 2013 7:48 am
by bernd_d
FYI: There seems to be a problem if an old entry is modified. Sometimes it can be, that the entry-part is overwritten by old content of autosave-cache.

For the moment, it could be better to disable the plugin until there is an update available.

Re: New Plugin: Autosave in Browsercache

Posted: Thu Jun 13, 2013 1:03 pm
by onli
Thanks for the report Bernd. What was missing was logic to not replace text in the textarea, i added that now.

Re: New Plugin: Autosave in Browsercache

Posted: Thu Jun 13, 2013 1:11 pm
by onli
Better directly use this version. It toggles the extended editor if it inserts something in it, and doesn't insert the cache into the extended editor if the normal editor has already text, thus preventing mixing old with new entries.

Re: New Plugin: Autosave in Browsercache

Posted: Thu May 29, 2014 7:58 pm
by onli
I integrated this into the 2.0 core (including adjustments necessary for it to work in ckeditor) in https://github.com/s9y/Serendipity/comm ... 80a03e18c9

Re: New Plugin: Autosave in Browsercache

Posted: Mon Jun 02, 2014 9:46 am
by garvinhicking
Hey,

this is awesome, thanks for committing.

Seems to work great in my browser. Maybe everyone could test this out and see if it creates trouble in maybe older browsers...

Thanks,
Garvin

Re: New Plugin: Autosave in Browsercache

Posted: Mon Jun 02, 2014 10:33 am
by onli
It could also create issues when writing really long articles on some setups, that would be interesting too. Not on my setup though.

Re: New Plugin: Autosave in Browsercache

Posted: Wed Jun 04, 2014 8:59 am
by mattsches
Great stuff! It works for me, saves and loads both body and extended body from IndexedDB. Would it make sense to save the entry title, too?

Re: New Plugin: Autosave in Browsercache

Posted: Wed Jun 04, 2014 10:02 am
by Timbalu
  • Prologue: I have never understood why an autosave was a need. IMHO open forms keep unsafed entries... and this is a default behaviour.
I now have tested this autosave behaviour opening an entry form, entered some text, changed page and returned to a new entry form by sidebar link. This new form presents that browser cached text. This also happens on new tabs. Is that the suggested behaviour?

I don't like that! If I do such a page change, I do want a new entry form, nothing else.

Can this autosave feature be made optional, please?! Since this originally was an option by installing it as a plugin, even if that didn't work that good.

Re: New Plugin: Autosave in Browsercache

Posted: Wed Jun 04, 2014 10:44 am
by onli
Yes, it should be possible to save the title as well (either making the code more generic or more specific, I'll think about that).
IMHO open forms keep unsafed entries... and this is a default behaviour.
That is sadly just not true, especially in case of disconnects.
Is that the suggested behaviour?
Yes.
If I do such a page change, I do want a new entry form, nothing else.
If I don't miss something specific, it is impossible to distinguish this action from a normal pageload of the editor, that would happen in case of a disconnect. And besides, to keep the text is the whole point of this functionality.
Can this autosave feature be made optional, please?!
We could easily add an option to disable it.

Re: New Plugin: Autosave in Browsercache

Posted: Wed Jun 04, 2014 11:01 am
by Timbalu
onli wrote:
IMHO open forms keep unsafed entries... and this is a default behaviour.
That is sadly just not true, especially in case of disconnects.
That is why I wrote "open forms". ;-) I have to admit this disconnect in special while writing a new entry has never happenend to me (or I have learned to avoid). And I do not use the remember me option.
onli wrote:
If I do such a page change, I do want a new entry form, nothing else.
If I don't miss something specific, it is impossible to distinguish this action from a normal pageload of the editor, that would happen in case of a disconnect. And besides, to keep the text is the whole point of
Well, what I meant was, if I do such an approach I want a new empty form!
onli wrote:
Can this autosave feature be made optional, please?!
We could easily add an option to disable it.
Better to turn it ON, IMHO. Maybe we can get some more means here, since that really is a change for every user. And this is nothing against this elegant indexedDB solution!