So JohnV wanted a more MS-Word like looking diff; this is the result.

ReplacementForDifferenceEngine/TestOfContextualDiffProvider.png

The needed source files are in ReplacementForDifferenceEngine.zip(info) The WikiEngine class is from 2.1.127, unless you are using that version you'll need to diff & patch you own.

NOTES:#

(Assuming 2.1.127) Unzip to your jspwiki source directoryWill repalce WikiEngine and DifferenceEngine, and add a new package diff.


Add a property to jspwiki.properties
jspwiki.diffProviderClass

Defaults to com.ecyrd.jspwiki.diff.TraditionalDiffProvider, the other two possible values are:

Yeah you got to use the fully qualified names for now, I did not do much serious property handling.


Traditional and External are the two legacy diff mechanisms, traditional seems to still work, I did not try External, but it should be okay.

Contextual is the new diff, it currently spits back the entire text of the wiki-page with word level differences highlighted (via css classes), a word limit on preceeding and succeeding context can be added (later) The code as written doesn't check for properties it's just using the hardcoded defaults for now.

For long documents with sparse changes next/previous links are near each change, you can hide them via the css if you don't want them.


The ContextualDiffProvider uses the following styles; add to the .css file, modify as desired.
.diff-wikitext 
    { margin: 10px; 
      padding: 5px; 
      border-width: thin; border-style:inset; 
      font-family: courier new , monospace;  }


.diff-insertion 
    { background: yellow; text-decoration:  underline; color: blue; } 

.diff-deletion 
    { background: yellow; text-decoration: strike-through; color: red; } 

.diff-nextprev 
    { font-size: 50%; vertical-align: super; }


BUGS:#

In the source for ContextualDiffProvider.java, line 152 (start of createMarkup) add:
    if (null == changeNode)
        return "No changes.";
When I upload a new version of the zip it will have the above bugs incorporated.


Any Versions for 2.4.100 or newer?

--MartinU, 04-Jun-2007


ContextualDiffProvider is already in 2.4.100. Just turn it on with

jspwiki.diffProvider=ContextualDiffProvider
in your jspwiki.properties.

--JanneJalkanen, 04-Jun-2007

Thanks for this great hint!

-- MartinU

Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
zip
ReplacementForDifferenceEngine... 24.3 kB 1 06-Jan-2005 15:09 JohnVolkar
png
TestOfContextualDiffProvider.p... 18.5 kB 3 24-Feb-2005 15:03 JohnVolkar
« This page (revision-8) was last changed on 05-Jun-2007 16:10 by 193.27.50.75