ec2-3-80-4-76.compute-1.amazonaws.com | ToothyWiki | ToothyWikiInternals | RecentChanges | Login | Webcomic

Currently, the Wiki shells to the diff utility to provide a diff.

The Perl script below (written by MoonShadow for a reason entirely unconnected with the Wiki) will do more or less what diff does, with the advantage that MoonShadow understands precisely how it works and can tweak its internals easily. MoonShadow intends to replace the external call, giving better control over exactly what is compared, what is ignored and how it is output. In the short term, people will be able to compare any page revision with any other revision; in the long term, MoonShadow is hoping for some form of automatic colouring for the last 5-6 sets of changes on each page, to make conversation easier to follow, as well as reducing the number of cases where edit conflicts need to be resolved manually.

As a request, if we do have the colouring, can it please not be the ONLY way to view history.  Because I habitually browse in monochrome.  --Vitenka

Indeed. MoonShadow is a habitual Lynx user. MoonShadow was thinking of the history colouring as something that was off by default and people could turn on in their user preferences; if they did turn it on, the (subtle) colouring would be applied to *every* page they browsed, and they could choose how many revisions to vary the colour over.

PeterTaylor notes that if you do go over to using CVS, you could use the cvs annotate command to get the revision in which each line was last changed. In fact, PeterTaylor already uses this, in conjunction with a perl script that adds ANSI control codes, to produce coloured versioning of documents under CVS control.

wiki2.pl is a (somewhat buggy and unsubtle) beta of inline history colouring - the effect may be seen, for instance [here]. There's only one level of colouring at the moment. UseModWiki caches the last revision diff in a rather tangled Perl subroutine that is too much fuss to unpick for now, so don't use wiki2.pl to edit pages, and diff with revisions other than the last major one. To compare with a revision other than the current one, tack a diffrevisionwith=x on the end of the URL, where x is the number of the revision to compare with. I intend to provide dropdown boxes to let the user select two arbitrary revisions to diff between. It currently garbles preformatted text and Go markup.
(PeterTaylor) There seem to be at least two levels of colouring, in point of fact.
Two colours, to highlight text that differs between the two revisions. One level of history - you can only compare the current revision with one other one. I am envisaging being able to compare three or four revisions at once. Sorry, my miswording :)
However, the ability to follow what's going on is hindered by the way the diffing seems to be done in terms of paragraphs rather than lines.
MoonShadow: That is not the case internally. If you look at the HTML source, you will see that the browser does word wrapping - so each rendered paragraph is a line in the original. This is a Good Thing, since people have screens which are different numbers of characters across. However, it means that about the only way to diff by rendered line is using Javascript. A diff by character would mean the whole thing grinds to a halt - the operation is O(mn) in both time and space, where m and n are the element counts of the two sets I am comparing. Ah - maybe I could split on sentence endings?
(PeterTaylor) See [1] - okay, so I probably messed up constructing the URL slightly, but you can see what I mean. It might be that all you need to do is ensure that adding a newline at the end of a line which didn't end with one doesn't count as changing that line.
Ah, I see what's happening - you've added a newline to the end of a previously written line, which the script noticed.
Which brings us to the interesting issue of precisely what should be considered a difference. Is it OK for someone to drop in lots of whitespace, for instance, without the diff script picking it up? What about other formatting? Should I filter all non-alphanumeric characters from the strings the script compares, as I am seriously thinking of doing? What do people think?

(source snipped - it's out of date, anyway. See Revision 11 or earlier if you still want it.)

ec2-3-80-4-76.compute-1.amazonaws.com | ToothyWiki | ToothyWikiInternals | RecentChanges | Login | Webcomic
Edit this page | View other revisions | Recently used referrers
Last edited January 23, 2003 1:08 am (viewing revision 14, which is the newest) (diff)