New Plugin: Autosave in Browsercache

Creating and modifying plugins.
User avatar
onli
Regular
Posts: 2254
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

New Plugin: Autosave in Browsercache

Post by onli » Sun Jun 09, 2013 12:31 pm

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.
Attachments
serendipity_event_autosave_local-0.1.tar.gz
(1.52 KiB) Downloaded 210 times

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: New Plugin: Autosave in Browsercache

Post by garvinhicking » Sun Jun 09, 2013 1:46 pm

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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

User avatar
onli
Regular
Posts: 2254
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: New Plugin: Autosave in Browsercache

Post by onli » Sun Jun 09, 2013 1:55 pm

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.

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: New Plugin: Autosave in Browsercache

Post by garvinhicking » Sun Jun 09, 2013 2:10 pm

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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

User avatar
onli
Regular
Posts: 2254
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: New Plugin: Autosave in Browsercache

Post by onli » Sun Jun 09, 2013 2:16 pm

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.

bernd_d
Regular
Posts: 466
Joined: Thu Jun 03, 2010 9:28 am
Contact:

Re: New Plugin: Autosave in Browsercache

Post by bernd_d » Thu Jun 13, 2013 7:48 am

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.

User avatar
onli
Regular
Posts: 2254
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: New Plugin: Autosave in Browsercache

Post by onli » Thu Jun 13, 2013 1:03 pm

Thanks for the report Bernd. What was missing was logic to not replace text in the textarea, i added that now.
Attachments
serendipity_event_autosave_local-0.1.1.tar.gz
(1.54 KiB) Downloaded 180 times

User avatar
onli
Regular
Posts: 2254
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: New Plugin: Autosave in Browsercache

Post by onli » Thu Jun 13, 2013 1:11 pm

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.
Attachments
serendipity_event_autosave_local-0.1.2.tar.gz
(1.56 KiB) Downloaded 217 times

User avatar
onli
Regular
Posts: 2254
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: New Plugin: Autosave in Browsercache

Post by onli » Thu May 29, 2014 7:58 pm

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

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: New Plugin: Autosave in Browsercache

Post by garvinhicking » Mon Jun 02, 2014 9:46 am

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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

User avatar
onli
Regular
Posts: 2254
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: New Plugin: Autosave in Browsercache

Post by onli » Mon Jun 02, 2014 10:33 am

It could also create issues when writing really long articles on some setups, that would be interesting too. Not on my setup though.

mattsches
Regular
Posts: 440
Joined: Sat Nov 05, 2005 10:35 pm
Location: Wiesbaden, Germany
Contact:

Re: New Plugin: Autosave in Browsercache

Post by mattsches » Wed Jun 04, 2014 8:59 am

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?

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: New Plugin: Autosave in Browsercache

Post by Timbalu » Wed Jun 04, 2014 10:02 am

  • 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.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

User avatar
onli
Regular
Posts: 2254
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: New Plugin: Autosave in Browsercache

Post by onli » Wed Jun 04, 2014 10:44 am

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.

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: New Plugin: Autosave in Browsercache

Post by Timbalu » Wed Jun 04, 2014 11:01 am

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!
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

Post Reply