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:

SQL-query:
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):

change
<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:

change:



to



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:

change:



to:



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.


CategoryUserContributions
Comments
Comment by JavaWoman
2005-01-13 08:53:27
To be honest, Christian, I do not think "UrlBeatify" is a better name. It suggests some sort of Mod_rewrite type of functionality. But you're not actually doing anything to any URL, only to the link descriptions.
Comment by ChristianBarthelemy
2005-01-13 12:47:30
I am not very happy with this name either, particularly the way YOU write it :-))

More seriously I picked the name from various threads using it to describe what Apache's mod_rewrite allows; as a reference for instance: http://meta.wikimedia.org/wiki/Documentation:Configuration
Comment by JavaWoman
2005-01-13 17:04:16
Lol! I'm a terrible yptist...

Yes, exactly that's what mod_rewrite allows: "beautifying" a URL (make it more readable for humans, that is). But your proposal doesn't touch URLs at all so the name is rather confusing.

CamelSplit? :)
Comment by ChristianBarthelemy
2005-01-13 17:28:50
That's perfectly true - Sorry I am so upset because I cannot use properly mod_rewrite that I completely lost my focus. This should better be named WikiWordBeautify.
I feel ashamed to create so many pages for nothing... If I clone it to WikiWordBeautify could you please delete this page then?
Comment by MovieLady
2005-05-18 22:24:07
This is fabulous, Christian! Thanks! :)

The only place it doesn't work is in the category listing columns -- suggestions on how to fix that in action/category.php?

(I'm using the categories as they are from the current 1.1.6.0 download on this intranet installation.)
Comment by 12.38.16.108
2005-05-20 11:26:54
Just had a look at it; solution may not be obvious. I will try to find a way.
Comment by SamuelDr
2005-06-12 00:23:04
it would be cool not to separe WikiNames , My name is not meant to be separated, so I just uninstalled this mod.
It was cool at the beginning, until I saw my name... It was disgustfull...
Thanks anyway :P
Comment by JavaWoman
2005-06-12 14:22:21
SamuelDr, I could imagine this mod being extended with an exception list...
Comment by SamuelDr
2005-06-13 21:21:56
yep, would be cool, and saying disgustfull was full of sarcasm, it was not that bad, at least it was working !
Comment by 194.223.231.3
2005-07-13 15:03:15
did anyone find a way to fix the categories?
Comment by JavaWoman
2005-07-14 09:13:58
The AdvancedCategoryAction (http://wikka.jsnx.com/AdvancedCategoryAction) has the capability to list only categories as a list and in that mode will remove the word "Category" from the start of the category name. This already helps with readability.

It would be easy to extend this action to use the user setting for inserting spaces as presented here.
Comment by MovieLady
2005-09-28 02:13:13
FYI, I added examples showing the changes that have to be made to the AdvancedCategoryAction code on its page to add spaces between CamelCase words using addspaceincamelcase().
Comment by ZombieTuesday
2006-08-07 09:50:02
Hey .. Ok i dunno if im in the right place for this .. im a wikkawiki newb .. ive got both url beautify and the advanced catagory running .. is there anyway to add the space on the PageIndex Page?so ou dont get A
AdamHotrod but you get A
Adam Hotrod , similar to what you have done on the category page ?

mucho appreciated :)
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki