Wiki Programming

I wrote this page because I'd like to develop my own wiki code, doing "the simplest thing that might possibly work", and it wasn't clear to me from the existing discussion just what that might be without a wholesale import of Ward's code. My hope is that this will be a useful reference/tutorial for other programmers.

Wiki source code

The WikiBase topic leads to WardCunningham's source code (in Perl) for this site. It can be browsed with commentary explaining each section, which is a good way to get an overview of how it works. Once this is understood, it can be downloaded as straight Perl code for further review, suggesting changes to Ward, or installing into another Web server to create a new wiki.

It may be useful to have some comments from Ward here about how best to submit a proposed change to the wiki code.

WikiBase is very obsolete, but cross your fingers. -- SunirShah

Wiki functionality - Ward's minimal version

Here's a discussion of the features of wiki without including the specific code. It's my hope that this discussion will be useful to wiki developers, regardless of their favorite language:

Browsing

For browsing the site, the server displays a page containing:

The header includes the title of the page as the Title element inside the HTML HEAD section. It also has the standard logo and the title of the page as the topmost text of the page.

In the body text, the server performs formatting conversion between the stored text - for example, three single quotes in a row for bold - to HTML tags for display by the client browser.

The footer has a link to the Edit page to modify the page being browsed; to the backup copy if available; and to the Find functionality.

Editing

The edit page shows the body text of the page in a text box, allowing it to be edited. When the form is submitted, a script does some processing to the text and updates the RecentChanges list. The Thanks For Editing page is sent to the user with a link back to the as-edited page.

Find

A discussion of the Links and Search pages should go here.


"Blue sky" discussion of other wiki features

I don't know if a code review would be of any use, but after perusing the code, I have some questions about why it works the way it does.

in Handle-Browse:
 use Wiki::HTMLHandler;
 &GenerateHTMLHead($Title,$LogoImageURL);
 &GenerateHTMLBody($Body-Text);
 &GenerateHTMLFoot;
This would make it a breeze for other wikis to change their headers & footers, e.g. maybe some would prefer the Search link to be at the top of the page.


Why not just have the edit script write a new static HTML page? (instead of dynamically generating the page at read time)

Benefits:

Drawbacks: Gotchas: That's easily solved. Store with each page (as invisible meta info in the file or as columns in the db) the incoming and outgoing links. When you edit a page, you have to update all the pages in your incoming and outgoing links. Again, the number of pages affected should be a tiny fraction of the total. The delay in the editing shouldn't be much greater then in viewing. Just that it happens only once instead of hundreds of times. I've implemented that in my own wiki and it works great.


Features Ward has already rejected

-- ChrisBaugh

I am working on coding up a wiki in PythonLanguage. All but the wikicode/HTML parser-converter are done. It has a simple config file to let you define the pagebgcolor, header and footer background color, and domain name - so it can properly code the links. Although tradition MIGHT be to use white, and I respect Ward's choices for himself, I would never make such a decision on another person's behalf. -- KirkBailey

If you haven't already done so, you might want to have a look at WikiWikiSuggestions for ideas. -- FalkBruegmann

Or http://wikifeatures.wiki.taoriver.net/ [BrokenLink] for even more ideas.

ReverseIndex

How is ReverseIndex implemented? I'm writing my own wiki and, since it seems to be the most expensive operation, I'd like to explore good ways of implementing it.

My thoughts are here:

http://urchin.earth.li/cgi-bin/twic/wiki/view.pl?page=BackLinksImplementation

But I'd like to keep the discussion here on WardsOriginalWiki.

-- TomAnderson

How about updating OTHER pages' BackLinks whenever you edit one page. You'll have to run one big job to bring your existing pages up to date, but then you only have to update the pages on your outgoing links when you save edits to a page. -- SvenNeumann

It's not quite that simple, because you need to handle links disappearing. Since the new version of the page (by definition) doesn't contain those links, you either need to scan the old version of the page, or check the backlink lists of all candidate pages, or something. TrikiWiki? has a cunning solution using zero-length files whose names contain a record of a link: http://triki.publication.org.uk/ThesePagesLeadHere. -- TomAnderson


I would like to open a discussion for the implementation of diff. I've just implemented the WagnerFisherAlgorithm, using lines of text for characters. This seems to work well on showing up edits vs inserts/deletes and unchanged lines. Has anybody else used this algorithm for diff and what weighting for the ops did you use? If this is not an appropriate algorithm for this job, I'd be delighted to hear what others used. -- SvenNeumann

The diff used by MoinMoin http://purl.net/wiki/moin/ looks nice.


EditText of this page (last edited July 10, 2008) or FindPage with title or text search