PrettyCategory Action


This gentle rewrite of the Category which ships with WikkaWiki 1.1.6.4 was created for use in a translucent website, where I want to show a list of categories and hide some of the CamelCase wiki-ness of the site.

In contrast to PrettyRecentChanges, there are very few deletions necessary and this is essentially about including the uncamel function (used there) here to break up category names into constituent words.

I have many pages which are listed as Readings4June2008 which this code presents as Readings 4 June 2008.

Installation


In your actions directory, copy category.php to prettycategory.php

In the new file, insert the following code immediately after the header comments:

if ( !function_exists('uncamel'))
  {
    function uncamel($intext)
    {
      // Following codes based on a blog posting by Trenton Davies
      // at http://ad.hominem.org/log/2004/12/camelcase.php
      $text = join( ' ', preg_split("{(?<=[a-z])(?=[A-Z0-9])}x", $intext ) );
      // Following line breaks out numbers as separate words as well
      $text = join( ' ', preg_split("{(?<=[0-9])(?=[A-Z])}x", $text ) );
      return "$text";
    }
  }


Replace the line that reads
$str = " pages belong to ".$page.":";

with
$str = " pages belong to ".uncamel($page).":";


Also replace the line that reads
if (!$compact) $str .= '<td>'.$this->Format('[['.$val.']]').'</td>';

with
if (!$compact) $str .= '<td>'.$this->Format('[['.$val.' | '.uncamel($val).']]').'</td>';


Your whitespace may vary.

Usage


This code is essentially used as a drop-in replacement for the existing Category action.

Possible criticisms


This could have just been another option passed to recent changes. I'm building a site to be edited and updated by novice users. There is the danger that this code will hide too much of the wiki from them, but I'd rather be keeping it from our public audience, as well.

The uncamel function does not break apart AWikiNameWithAnIndefiniteArticle properly. I try to avoid such WikiNames.

The uncamel function, since it's shared with PrettyRecentChanges, should probably be put into a common file. I admit I don't know a good place to put it. As it is, it is bundled with the code that uses it, for ease of installation and removal.

CategoryUserContributions
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki