[dokuwiki] Merging section edits

  • From: Jason Grout <jason-doku@xxxxxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Tue, 10 Nov 2009 19:40:27 -0600

I realized today that though Dokuwiki offers sectional editing, it only has page-level locking, which means that two people can't edit different sections of a page simultaneously. It's been several years since I looked at the Dokuwiki code, but after poking around for a bit, it seemed like this might be an algorithm for intelligently merging edits of different sections simultaneously.


* When a section of a page is edited, a hidden input is created with the original section (in addition to the prefix and suffix hidden inputs).

* Now put the following logic in act_save in actions.php: When an edit is saved, we just need to determine if the section we are editing changed. The "original page" is reconstructed by concatenating the prefix, the original section text, and the suffix. This is compared with the current version of the page. Modify the prefix and suffix to match the current page, based on the diffs that are in the line ranges of the prefix and suffix. Now, if there are any diffs left (i.e., diffs for the lines in the section we edited), then there is a conflict, so have act_save return the 'conflict' action. If there are no differences, then make the new page by taking the (modified) prefix and suffix and combining them with the new section text from our edit and save the page.

* Something more needs to be done with locking. When someone edits the entire page, a page-level lock is created, preventing any edits. When someone edits a section, a sectional lock is created (i.e., just a lock file which signifies that some sort of sectional edit is going on). This sectional lock won't prevent another section from being edited, but it would prevent a page-level edit from happening. If two people happen to edit the same section at the same time, the conflict resolution above will take care of things.

What do people think?

Thanks,

Jason

--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: