February 24, 2005
CLiki Diff Patch #1

I've packaged up a patch against CLiki to add the ability to compare different revisions of a page, in the style of Aaron Swartz' HTML Diff.

Download: cliki-0.4.3-diff.patch

What it does

The diff changes the “Revisions: 1 2 3 4” links at the bottom of every page to “Revisions: 1 < 2 < 3 < 4”, where each “<” is a link that will bring up a page displaying the differences between the two adjacent revisions. (See this earlier lemonodor post for screenshots.)

Diff urls look like “http://<cliki root>/<page>?diff&va=<version #>&vb=<version #>”. It wouldn't be hard to create an interface that would allow the comparison of arbitrary versions of pages.

How to customize it

CL-HTML-DIFF outputs HTML that wraps changes with <ins> and <del> tags. My browser defaults to displaying these tags like this:

styleless diff

If you want something that looks a little more slick, you can take advantage of CSS by adding a few styles to your CLiki stylesheet:

del.diff {
        color: #f22;
        text-decoration: strikethrough;

ins.diff {
        color: #2f2;
        text-decoration: none;

With these styles applied, you get the following:

styled diff

By default, CL-HTML-DIFF attaches the CSS class “diff” to the <ins> and <del> tags, but this is easy to change using HTML-DIFF:HTML-DIFF's :insert-class, :delete-class and :replace-class arguments if you want greater control (HTML-DIFF:HTML-DIFF is called by the VIEW-PAGE-DIFF function).

What you need to use it

The patch requires that you have CL-DIFFLIB and CL-HTML-DIFF installed. (CL-HTML-DIFF is my quick and dirty translation of Aaron Swartz' Python code to Lisp.) Both libraries are ASDF-INSTALLable.

This patch is against version 0.4.3 of CLiki, which is the only version I know of that is publically accessible right now. I think that the only issue involved in using this code in a newer CLiki is that one might want to change the VIEW-PAGE-DIFF function to handle conditional HTTP GETs. This should be easy to do if you look at the code for VIEW-PAGE (though you'll want to modify PAGE-LAST-MODIFIED so that you can pass it a version argument).

Posted by jjwiseman at February 24, 2005 06:05 PM
Post a comment

Email Address:


Unless you answer this question, your comment will be classified as spam and will not be posted.
(I'll give you a hint: the answer is “lisp”.)


Remember info?