[dokuwiki] Plugin: ShowChanges since last login

  • From: Robert Rackl <dokuwiki@xxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sun, 5 Apr 2009 17:58:37 +0200

Hello Dokuwiki Developers,

What happend so far?
I want to implement a plugin that "marks" changes in the HTML version of a wikipage that have happend since a given date. This date could for example be the date of last login of the currently logged in user. For a start I thought about only marking whole paragraphs as new/ changed/deleted with a background color.

Of course there is already a history functin in Dokuwiki that can compare raw wikitext of a page. But I want to mark paragraphs in the current HTML view, that have changed in the past. The Dokuwiki codebase already offers quite some usefull utilities for this task, e.g. the DifferenceEngine.

My problem is now: Should I compare raw wikitext or HTML?

1) Compare HTML
I can quite simple get the old and new version of the page in xHTML (the new version I already get for free in my RENDERER_CONTENT_POSTPROCESS action plugin. And the old version I can get get via Plugin->render($oldRawWikiText) ). Now I feed this into the DifferenceEngine and as a result I get a set of 'edits'. But now I cannot simply surround the text of these edits with <span class="changed">foobar</span> tags in the xHTML. The original "foobar" part in the HTML page might contain unballanced HTML tags.

2) Compare raw wiki text
So the other way round. This is what the DifferenceEngine normally does anyway. But now I get a set of edits in the raw wiki text. How do I match these edits to paragraphs in my rendered xHTML page?

My Ideas:
- write my own DifferenceEngine thats more clever? :-)
- compare HTML: and wrap only changed lines with <span> tags that do not contain unballanced html tags - compare raw wikitext. "somehow" pass the flag: "This (rawwikitext-)part has changed since last login" on to the Parser. Then the Parser creates new instructions for the Renderer, e.g. 'p_open' with parameter "changed". Of course this would not be a plugin anymore. It would require code changes in the Parser and Renderer. - my favorite idea: do not compare HTML as characters, but compare the DOM-tree

... comparing trees as datastructures ... didn't I have a book about this somewhere back from university .... ?? :-) ... to be continued ....

c'Ya
 Doogie

P.S.: I really learned a lot about the Dokuwiki internals in the last week. And this was really great fun!

+---------------------------->
| mobil: 0151-23035421
| ICQ:   7753573
| http://www.doogie.de
+---------------------------->

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

Other related posts: