Soma Posted December 31, 2013 Share Posted December 31, 2013 AutoSave This module saves the page via ajax when editing in the admin. The interval for saving the page is configurable in the AutoSave module settings. By default it will only be enabled for unpublished pages. So far it seems to work fine for all fields and supports multilanguage. There's a message dialog show on top of page when saving happened with either a success or error. Requirements ProcessWire 2.3+. Haven't really tested with 2.3. Known Issues Nothing really obvious so far. Note that when you have multiple editors editing pages, it would be possible 2 persons editing the same page would overwrite each other, since the page is autosaved! The only solution for this would be to have my PageEditSoftLock module enabled with the complete "Lock" option active, so the page would be locked for editing. Todo Add some checks, if connection is lost. To be defined This module is currently a proof of concept. This module may not be suitable for all instances, but for personal use it may help preventing loss of long edits, most likely blog posts. Not sure this should be used for regular sites with clients editing. Most likely there's some more issues that interferer with what a CMS "page save" has to deal with. So you might find some ugly stuff happening. Thanks to Apeisa and his great Fredi font-end module, from where some logic is borrowed to save the page via ajax. Downloadhttps://github.com/somatonic/AutoSave So, that would be my last stroke for this year! Have a great silvester party and a happy new 2014! 13 Link to comment Share on other sites More sharing options...
Joss Posted December 31, 2013 Share Posted December 31, 2013 Dear Soma I shall rush off and try it immediately A Prosperous new year to you and yours! Joss 1 Link to comment Share on other sites More sharing options...
Joss Posted December 31, 2013 Share Posted December 31, 2013 Okay, not actually doing anything on my test site (2.3.9 - with the new admin template). But it can wait for later in the week (its new year)! An extension to this would also be to optionally save a field onblur. That would be useful for when filling in large numbers of fields, whereas the auto save is good for when working on a single large text field. Link to comment Share on other sites More sharing options...
Soma Posted December 31, 2013 Author Share Posted December 31, 2013 Okay, not actually doing anything on my test site (2.3.9 - with the new admin template). But it can wait for later in the week (its new year)! What do you mean? It doesn't work for you? I'm using latest PW with new admin theme (although shouldn't matter at all). An extension to this would also be to optionally save a field onblur. That would be useful for when filling in large numbers of fields, whereas the auto save is good for when working on a single large text field. I don't think this should go as far, and not something that is easily possible. Link to comment Share on other sites More sharing options...
Joss Posted December 31, 2013 Share Posted December 31, 2013 Well, nothing happened. No saving happened, I mean. Link to comment Share on other sites More sharing options...
Soma Posted December 31, 2013 Author Share Posted December 31, 2013 I think I know what's going on. I'm just updating with some fixes and also with additional feature to check for form errors and show them. Link to comment Share on other sites More sharing options...
Soma Posted December 31, 2013 Author Share Posted December 31, 2013 Just pushed an update to github with some fix. There were some routines for TinyMCE and CKEDITOR to update the changes to the form before sending, which required some additional check for if there's really editor instances. So this most likely was your problem. Added some additional checking for form validation. So it will show errors of the saved form and show them too. Thanks for testing. Link to comment Share on other sites More sharing options...
Joss Posted January 1, 2014 Share Posted January 1, 2014 Hi Soma Happy New Year! Okay, it is now saving, but on my limited test it saved the two text input fields on my page but not the CKeditor (inline). I will do some more tests tomorrow sometime Night! 1 Link to comment Share on other sites More sharing options...
Soma Posted January 1, 2014 Author Share Posted January 1, 2014 Ho Joss, happy new year! Ok that was more helpful than just "it's not saving". Ah, of course ckeditors inline mode need some special treatment. Took me a while to figure it out but it's working now too. Thanks. Link to comment Share on other sites More sharing options...
Joss Posted January 1, 2014 Share Posted January 1, 2014 Okay - I am out and about today, but I will give it a work out a bit later. I need to create a new virgin testbed for these things! Right - out into the rain! Link to comment Share on other sites More sharing options...
Pete Posted January 1, 2014 Share Posted January 1, 2014 I know it's only a Proof of Concept, but I'm 50/50 as to whether this is a good idea or not if it's auto-saving live pages, no offense intended, as it could be updating part-changed content on a live page if you're halfway through typing when it autosaves couldn't it? Some people write/edit loooooooong pages I think it would be better if it autosaved to another part of the site (under your process page for example) and if you leave the page you're editing and go back to it it could do a comparison of modified dates and ask if you want to edit the later, non-live version. Of course, that's quite a lot more code but it's just an idea (it's also leaning towards version control too in that case). 2 Link to comment Share on other sites More sharing options...
Soma Posted January 1, 2014 Author Share Posted January 1, 2014 I know Pete. Exactly, but I didn't ask for it and will not use it cause I can hit save. 1 Link to comment Share on other sites More sharing options...
Joss Posted January 1, 2014 Share Posted January 1, 2014 Its a good start and is showing that this part of it works and with various fields. It does need to be mixed with some sort of draft/versioning system, I agree, to become a full solution, but that also requires some fairly heft complications: To start with, if you lose connection or something, when you return to the page you need to be offered the choice of the draft version or the published live version. This probably means adding an extra link in the page list actions to open a draft (only shown if it exists) If you are looking at the draft version, then you need to have the option of saving the draft as a draft, or publishing, which would overwrite the live version. 1 Link to comment Share on other sites More sharing options...
ryan Posted January 1, 2014 Share Posted January 1, 2014 I know Pete. Exactly, but I didn't ask for it and will not use it cause I can hit save. Most of the instances I've heard of where people lost their work had to do with creating new pages that weren't yet published. For unpublished pages, the issue Pete mentioned is really not an issue at all. Perhaps a setting to limit the auto-saving to unpublished pages would be all that's needed, since that is the time when this module is likely most valuable. I'd suggest this might even be a good default setting. The 3 instances I'm aware of–Mike (cmscritic), Teppo, and Peter–would have all been for an unpublished page (I think) and would have been saved by this module. Nice job btw! 4 Link to comment Share on other sites More sharing options...
Soma Posted January 1, 2014 Author Share Posted January 1, 2014 Yeah that's what I also thought having it only for unpublished pages or also just certain templates. But first wanted to know if it's possible at all to autosave and how.There maybe also a way to save the edits not to the page but to a file and load it on demand after a loss. Im not too keen creating new pages for it. Also I think certain fields like files will not work this way.Speaking of drafts and live version that's something still missing in pw and I would have that on top priority. But Im not in charge of it and it's on the roadmap, though got delayed by a lot. I'm waiting for it since the beginning of using pw two half years ago. ;p Though Im really wondering if with the flexibility pw offers how to use pages and combinations of fields and hooks if a draft system really works out well... if you know what I mean... seeing also things like 'simple' clone feature is not working in all cases. No offend intended, I know Ryan is doing all he can and doing a hell of a job, but he's still "alone" on those stuff. 1 Link to comment Share on other sites More sharing options...
ryan Posted January 1, 2014 Share Posted January 1, 2014 I've actually been putting some thought to drafts and think I've got some good ideas to move forward with a simple drafts system soon. Page status 4096 is reserved for Page::statusDraft. That keeps drafts in the Unpublished territory, excluded from all but "include=all" selectors. Page IDs 500-999 are reserved for drafts (so the IDs will be reusable, unlike other page IDs). I don't imagine many would need more than 500 drafts at a time, but if they do, we can make the ID reuse optional. Drafts will be an optional module, not installed by default (like autocomplete, repeaters, etc.) Versioning will be something different entirely, as I don't want versions filling up the pages tables. But versioning will likely use drafts as a transition point. Link to comment Share on other sites More sharing options...
Joss Posted January 1, 2014 Share Posted January 1, 2014 Aww, Soma - you make him sound so lonely!!! Yes, really this module of yours comes into its own once a draft/versioning/something system is in play. Just about everything I do, especially in music when composing, involves creating a new or alternative version, making a comparison against everything else and the deciding which one to use. On versioning, there is no reason why there cannot be a versions table that hold arrayed data that can be loaded back into a form - or something like that. Though (and you will hate this) there is an argument to say that versioning could apply to an individual field - from the editorial point of view, being able to look through an assortment of bits and then combine them into the perfect version is fun. I do this with Cubase - audio recordings are kept in "Lanes" and you can cut and past bits of each lane to create a whole new version. Mind you, it can get mind bending! Link to comment Share on other sites More sharing options...
Soma Posted January 1, 2014 Author Share Posted January 1, 2014 I pushed an update with default AutoSave only enabled on unpublished pages. Added option to enable it for all pages. On versioning, there is no reason why there cannot be a versions table that hold arrayed data that can be loaded back into a form - or something like that. That might be true for simple text page with no files. Files and images is what makes it not so simple. And to go further there could be all kind of weird situations wehre you have references to pages that doesn't exists anymore. And so on. It's not like in a nice closed predictable environment like in a audio composing tool (I also use) or a design tool. On the other parts I'm not commenting. Link to comment Share on other sites More sharing options...
Soma Posted January 1, 2014 Author Share Posted January 1, 2014 BTW why is there no autosave in this forum... I lost some long written posts several times during the years. Link to comment Share on other sites More sharing options...
Joss Posted January 1, 2014 Share Posted January 1, 2014 Yep, me too. On the files/images front, as far as the form is concerned, they are only location/path references aren't they? Link to comment Share on other sites More sharing options...
Soma Posted January 1, 2014 Author Share Posted January 1, 2014 Your images are only a paths? And where are the pixels? Link to comment Share on other sites More sharing options...
Joss Posted January 1, 2014 Share Posted January 1, 2014 Where I left them ..... I hope! Link to comment Share on other sites More sharing options...
Soma Posted January 1, 2014 Author Share Posted January 1, 2014 Just fixed a bug with status getting cleaned. So a unpublished page would get published. It just ignores the status now, which isn't something you want to autosave anyway. (There would have to be some special treatment as ProcessPageEdit does) 1 Link to comment Share on other sites More sharing options...
apeisa Posted January 2, 2014 Share Posted January 2, 2014 I've actually been putting some thought to drafts and think I've got some good ideas to move forward with a simple drafts system soon. Ryan - any ideas how much work that would be? We have need for this also in next project, so interested in providing some support (=money) for this. 5 Link to comment Share on other sites More sharing options...
Joss Posted January 2, 2014 Share Posted January 2, 2014 Haven't got any money, but happy to talk through possible workflow ideas to help find the most logical for users way of doing this before anyone breaks their backs coding! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now