[RFC] Autosave

Note: We are moving the topics of this forum and it will be deleted at some point

Publish your own request for comments/change or patches for the next version of phpBB. Discuss the contributions and proposals of others. Upcoming releases are 3.2/Rhea and 3.3.
iPollesion
Registered User
Posts: 3
Joined: Mon Oct 29, 2012 1:59 am

Re: [RFC] Autosave

Post by iPollesion »

Instead of going the complicated way, why not have it as a feature based on group permission? Kind of like only allowing administrators or moderators, and contributors set up with the "Yes" permission to have "Autosave drafts" enabled, that way the administrator controls who has this ability and it won't be a major drain, you can implement a client-side autosave draft later on as part of this, depending on what the team would want.

But I would definitely like this feature seeing as I have accidentally closed my browser about 3 times posting long topics, but have since taken kin to hitting the save draft button, it would be nice to have something like what Google does for their e-mails or YouTube video edits, where it automatically saves.

+1 for me.

User avatar
brunoais
Registered User
Posts: 964
Joined: Fri Dec 18, 2009 3:55 pm

Re: [RFC] Autosave

Post by brunoais »

Ooohh This topic has quite some time.
I think saving should be in the client side. We now have the LocaStorage interface, which is a simple key-value to store. We can just store there with a key we can decide to be wildly used in phpBB.
Each key-value table follows the same origin rules. This means that there's a different table available for each sub-domain, and such.
We may use some randomization with the keys to make sure that no clashes happen for multiple forums in the same domain/subdomain, anyway.
+ info:
https://developer.mozilla.org/en-US/doc ... calStorage

User avatar
bantu
3.0 Release Manager
3.0 Release Manager
Posts: 557
Joined: Thu Sep 07, 2006 11:22 am
Location: Karlsruhe, Germany
Contact:

Re: [RFC] Autosave

Post by bantu »

I'd like to see this feature. Not sure whether client side or server side is better. Major exisisting implementations (e.g. Gmail) are probably server side.

User avatar
Pony99CA
Registered User
Posts: 986
Joined: Sun Feb 08, 2009 2:35 am
Location: Hollister, CA
Contact:

Re: [RFC] Autosave

Post by Pony99CA »

Maybe it should be tied to events, not time or changes. For example, autosave when a Preview is done or when a Close Window event is fired.

This should probably also be tied into the Drafts system unless you don't want Autosave to overwrite an existing draft. That would give people a standard place to find autosaved items.

Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.

User avatar
brunoais
Registered User
Posts: 964
Joined: Fri Dec 18, 2009 3:55 pm

Re: [RFC] Autosave

Post by brunoais »

Pony99CA wrote:Maybe it should be tied to events, not time or changes. For example, autosave when a Preview is done or when a Close Window event is fired.
That's not fast enough. The whole DOM may be gone before you can properly send the contents of the post.
I still think that using the LocalStorage interface seem to be one of the best approaches for this problem.

User avatar
Pony99CA
Registered User
Posts: 986
Joined: Sun Feb 08, 2009 2:35 am
Location: Hollister, CA
Contact:

Re: [RFC] Autosave

Post by Pony99CA »

brunoais wrote:
Pony99CA wrote:Maybe it should be tied to events, not time or changes. For example, autosave when a Preview is done or when a Close Window event is fired.
That's not fast enough. The whole DOM may be gone before you can properly send the contents of the post.
If that's the case, then the warn user on closing edtior when text changed wouldn't really have worked, right?

Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] Autosave

Post by callumacrae »

Code: Select all

var timeout;
$('textarea').keyup(function () {
    clearTimeout(timeout);
    timeout = setTimeout(function () {
        //save post here
    }, 2000);
});
Untested, written from phone.
Made by developers, for developers!
My blog

User avatar
brunoais
Registered User
Posts: 964
Joined: Fri Dec 18, 2009 3:55 pm

Re: [RFC] Autosave

Post by brunoais »

Pony99CA wrote:
brunoais wrote:
Pony99CA wrote:Maybe it should be tied to events, not time or changes. For example, autosave when a Preview is done or when a Close Window event is fired.
That's not fast enough. The whole DOM may be gone before you can properly send the contents of the post.
If that's the case, then the warn user on closing edtior when text changed wouldn't really have worked, right?
Right. That code would never work. And doing an alert, prompt or whatever can be ignored by the browser so, also no go.
On that event callback, the only real thing you can do is to manipulate the DOM to give different looks (some companies use it to show a modal window stating that the request is being processed) and to ask for a js popup asking if the user wants to stay or leave the page. Some browsers may allow other interactions but it's just because they wanted to.

User avatar
Fyorl
Google Summer of Code Student
Posts: 27
Joined: Mon Apr 02, 2012 4:51 am
Location: UK
Contact:

Re: [RFC] Autosave

Post by Fyorl »

I started work on this, the PR is here: https://github.com/phpbb/phpbb3/pull/1063

Some questions that have cropped up: Do we need to keep track of more than one post at a time? It seems to me that a user will only be working on one post at a time per board. If we want to distinguish posts, how should they be uniquely identified? Forum and/or topic combo?

When do we clear autosave data? Can we rely on the 'post success' page to reliably delete the data before it redirects?

Update:
Decided on saving post data uniquely with the topic id and/or forum id (in the case of a new topic). Also the window creation time will be used in the case that a user opens multiple tabs in the same topic.

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] Autosave

Post by callumacrae »

Fyorl wrote:I started work on this, the PR is here: https://github.com/phpbb/phpbb3/pull/1063

Some questions that have cropped up: Do we need to keep track of more than one post at a time? It seems to me that a user will only be working on one post at a time per board. If we want to distinguish posts, how should they be uniquely identified? Forum and/or topic combo?

When do we clear autosave data? Can we rely on the 'post success' page to reliably delete the data before it redirects?

Update:
Decided on saving post data uniquely with the topic id and/or forum id (in the case of a new topic). Also the window creation time will be used in the case that a user opens multiple tabs in the same topic.
I feel that it should tell the user as it saves.

Another approach would be to either save it fairly often (like every few seconds), or save it every time the user stops typing for a couple seconds. As you're saving it at the client side, it won't cost much, and the user won't notice.
Made by developers, for developers!
My blog

Post Reply