PageDrafts

Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.


Goal

Page drafts address the following needs:

  • the internet connection breaks during a long edit and you lose your changes
  • your computer stops working and you lose your changes
  • you want to check a proposed change with others before saving it
  • you want to keep working on a new page before releasing it
  • you just forget to press Save

Solution

Add support for page drafts with Attach:pagedraft-0.1.1.tar.gz. For installation, see the README instructions. When editing a page, each time you press Preview it saves the page as a draft. If a draft exists and you are editing it, you see an extra Edit Original button on the edit form, letting you restore the original version.

Discussion

There is a demonstration at http://intranet.affinity.co.nz/wiki/DraftWP/Purpose

Follow the trail link (-->) at the bottom of the page.

On an Edit Page, the Preview button changes to Preview and Save Draft. When you press the button, the wiki writes the changed page to a temporary location. When you press Save, it saves the page and deletes the draft. If you don't press Save, the next time you Edit, the wiki gives you the draft (if a draft exists, the link changes to Edit Page Draft). If there is no draft to edit, it gives you the original.

A page can be in one of 4 states: - page exists - page and page draft exist - page draft exists, page doesn't exist - page doesn't exist

The demonstration includes examples of each. If both a page and a draft exist, you can toggle between views.

When editing a draft, you can revert to the original page version by clicking the Edit Original button. The next time you press Preview this will over-write the newer draft.

For demonstration purposes, links to pages that also have a draft include a link to the draft. This can be turned off.

See Also

If available, provide links to cookbooks or pages based on similar ideas.

History

Describe the changes of this cookbook if changes to the cookbook have been made (primarily changes in usage or code soundness, solutions for bugs, ...)

Comments & Bugs

If you have redefined $PageEditFmt, this recipe may not work correctly.

Currently, the Cookbook.WikiFarm doesn't work with the page draft script.

If you use the PageTableOfContents recipe, you must update one of the scripts with the replacement included with the PageDrafts script.

The script does not support multiple drafts of the same page -- just the original and one draft.

It puts drafts into a separate directory called wiki.draft. You can call it something else; do not call it wiki.d -- doing so will cause PmWiki to over-write the original! This would be a bad thing and there is no way to recover.

Contributors

John Rankin wrote the code.

Credit to Mirko Froehlich for the initial suggestion. And thanks to all those who contributed ideas to the thread along the way, especially Christian Ridderström and Jan Meijer for testing.

Copyright

Released under the GNU GPL. pmwiki-2.2.115 -- Last modified by {{}}?

from IP: 85.171.160.186 ip should be disabled by default for security reasons