Last edited by MovieLady:
Modified links pointing to docs server
Mon, 28 Jan 2008 00:14 UTC

Everyone does not like CamelCase

I like the simplicity of the automatic link creation when I type a new WikiWord. But I hate having to think about it all the time and as I naturally write "the wiki word" I would like the system to understand that for me. This is particularly enerving when typing people names: typing JohnDoe is not natural and it is also a pain for the eyes of a WikiStranger.
The standard solution is then to type [[JohnDoe John Doe]] but it is not really user friendly.

A solution

I picked the ExpandedWikiWords idea from Teamflux which is a commercial Wiki based on zwiki. The idea was already there.
The solution consists in adding a space before any capital letter within a word (not including the first one) when this word isn't enclosed in brackets (we may want to add similar restrictions to double quote).
This solution is easy to implement. The decision whether to use it or not should be taken by the user so it should be a new item in the UserSettings. The anonymous users shoud have it by default and this decision could be part of the ConfigurationOptions.

The code

1) adding field to user table:

ALTER TABLE `wikka_users` ADD `space_camelcase` ENUM( 'Y', 'N' ) DEFAULT 'N' NOT NULL;

2) adding a table row to show the status of the variable (to actions/usersettings.php):

<tr> <td align="right">Show comments by default:</td> <td><input type="hidden" name="show_comments" value="N"><input type="checkbox" name="show_comments" value="Y" <?php echo $user["show_comments"]
"Y" ? "checked=\"checked\ : ?> /></td> </tr> <tr> <td align="right">RecentChanges display limit:</td> <td><input name="changescount" value="<?php echo htmlspecialchars($user["changescount"]) ?>" size="40" /></td> </tr>

3) added the user-table-update in actions/usersettings.php:



4) create the function addspaceincamelcase($camelcase) in formatters/wakka.php:

  • I had to modify the preg_match_all on my installation so it wouldn't drop/ignore numbers that start a page name:

5) last update in formatters/wakka.php:



Moreover the comfort provided by such a functionality, it allows more consistency in the
WikiPages by reformating the content to ensure that the WikiLinks are generated even when the author forgott the NoSpaceInBetweenRule.

There are 13 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki