Revision [4565]

This is an old revision of UrlBeautify made by ChristianBarthelemy on 2005-01-12 23:17:13.

 

Last edited by ChristianBarthelemy:
Better name for what I first named AutoReplace
Wed, 12 Jan 2005 23:17 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 [[http://www.teamflux.com/ExpandedWikiWords Teamflux]] which is a commercial Wiki based on [[http://zwiki.org/ zwiki]]. The idea was [[http://zwiki.org/WikiLinkingIdeas 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: %%(sql) 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 %%(html) Show comments by default: : ?> /> RecentChanges display limit: " size="40" /> %% %%(html) Show comments by default: : ?> /> Insert spaces in between WikiWords: : ?> /> RecentChanges display limit: " size="40" /> %% 3) added the user-table-update in ##actions/usersettings.php##: change: %%(php) $this->Query("update ".$this->config["table_prefix"]."users set ". "email = '".mysql_real_escape_string($_POST["email"])."', ". "doubleclickedit = '".mysql_real_escape_string($_POST["doubleclickedit"])."', ". "show_comments = '".mysql_real_escape_string($_POST["show_comments"])."', ". "revisioncount = '".mysql_real_escape_string($_POST["revisioncount"])."', ". "changescount = '".mysql_real_escape_string($_POST["changescount"])."' ". "where name = '".$user["name"]."' limit 1"); %% to %%(php) $this->Query("update ".$this->config['table_prefix']."users set ". "email = '".mysql_real_escape_string($_POST['email'])."', ". "doubleclickedit = '".mysql_real_escape_string($_POST['doubleclickedit'])."', ". "show_comments = '".mysql_real_escape_string($_POST['show_comments'])."', ". "space_camelcase = '".mysql_real_escape_string($_POST['space_camelcase'])."', ". "revisioncount = '".mysql_real_escape_string($_POST['revisioncount'])."', ". "changescount = '".mysql_real_escape_string($_POST['changescount'])."' ". "where name = '".$user['name']."' limit 1"); %% 4) create the function addspaceincamelcase($camelcase) in ##formatters/wakka.php##: %%(php) if (!function_exists("wakka2callback")) { function addspaceincamelcase($camelcase) { $result = ;
preg_match_all('/[A-Z,ÄÖÜ]+[a-z,ßäöü,0-9]*/', $camelcase, $matches);
for ($i=0; $i<count($matches[0]); $i) {
if ($i>0) $result .=" ";
$result .= $matches[0][$i];
}
return $result;
}

function wakka2callback($things)
5) last update in ##formatters/wakka.php##:

change:
(php)
wiki links!
else if (preg_match("/^[A-Z,ÄÖÜ]+[a-z,ßäöü]+[A-Z,0-9,ÄÖÜ][A-Z,a-z,0-9,ÄÖÜ,ßäöü]*$/s", $thing))
{
return $wakka->Link($thing);
}
to:
(php)
wiki links!
else if (preg_match("/^[A-Z,ÄÖÜ]+[a-z,ßäöü]+[A-Z,0-9,ÄÖÜ][A-Z,a-z,0-9,ÄÖÜ,ßäöü]*$/s", $thing))
{
$user=$_SESSION['user'];
$addspace = $user['space_camelcase'];
if ($addspace
return $wakka->Link($thing);
}


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