[development] Use revisions to replace previews

Angela Byron drupal-devel at webchick.net
Fri Jun 8 16:38:35 UTC 2007

On 8-Jun-07, at 12:21 PM, Morbus Iff wrote:

>>> This is pretty much the way I work - I could easily spend 30   
>>> previews before I finish what I consider my first draft of a  
>>> node.  I would hate to waste 30 revisions (and the overhead) for  
>>> stuff
>> That's why it was suggested to automatically delete revisions  
>> that  were used for previews. Not that it would become elegant  
>> code, but  that would at least get rid of the overhead.
> How does that reduce the overhead, or keep the revision counter  
> from ballooning ridiculously? I'm still "wasting" the revisions,  
> whether they're active or not.

new field in node_revisions: preview int 1
all nodes default to status = 0.

When preview is clicked...
- Does a node id exist for this post yet?
   - If so, find the latest revision where preview = 1 and replace  
its contents with the current post's contents. Also store the node ID  
in a cookie value, so if the browser crashes, we can get back here.
   - If not, create a new revision and mark it preview = 1;

When submit is clicked...
- Create a new "normal" revision (preview = 0).
- Publish the node (workflow settings permitting)
- Delete preview revision if it exists.
- Delete node ID cookie value.

- Delete all preview = 1 revisions where updated >= variable_get 
('preview_threshold', 86400);

user comes back after browser crashes:
- Drupal checks for existence of  node ID cookie value, does a  
drupal_goto() to the node "would you like to finish editing this?"  
Since users can see unpublished nodes as long as they've authored  
them, they'd be able to further edit the content.


More information about the development mailing list