Caleb Maclennan

My personal home page is at http://alerque.com

My Work

I am a geek. I collect programming languages llike some people collect stamps on their passports. PHP, Perl, SH, Python, C, C++, ASP, Cold Fusion, Rebol, and GTK to name a few. I like php syntax, perl regular expressions, and I generally have more fun with interpreted languages than compiled ones.

I do a variety of things with my knowledge -- design websites, build databases, write automation software, do security auditing, statistical analysis, and design user interfaces. I can also take any of the above and find a way to connect them to each other and make them work together.

I am also a freelance architect and am proficient with several CAD packages. I have designed and drawn everything from starter homes to multi-million dollar resort homes as well as day care centers, retail spaces, industrial buildings, cabins and out-houses.

My Faith

For God demonstrated his love for us in this, that while we were still sinners, Christ died for us. What a great and precious gift that was! He has died as a ransom to set us free from sin.


God bless you, bro! "NO JESUS, NO PEACE. Know Jesus, Know Peace." BrucePennington


Links

WikiEngines


Check out the (new) UserfiedWiki? project at http://userfied.wiki.devel.org


Eventually I'ld like to post some examples of my work here, but for now there is just one of interest.

I am currently working on a new PHP wiki engine called IWiki designed to be embeded in any existing page template system. It isn't designed to be the most advanced Wiki around, but to be one of the simplest to use and install in an already implemented site structure. It is all built inside a class and each method can be called independently of the others. Simply include the library in your scripts, then call each function at the appropriate places, for example $iwiki->toolbar(); and $iwiki->body(); and $iwiki->title();

See http://alerque.com/IWiki for more information

For right now I'd love comments on the parseing engine!


     /* Code Copyright 2003 Caleb Maclennan         */
     /* Please contact me for permission to use it! */
     /* Full source at http://alerque.com/source.php?file=/usr/local/lib/php/iwiki.inc */

function para ($block) { return trim(htmlspecialchars($block)); }

function render ($page) {

$paras = preg_split('!^\s*$!m', $page);

$page=array();

foreach ($paras as $block) { $block = <B style="color:black;background-color:#A0FFFF">preg_replace</B>('!^\s*$!', '', $block); switch (true) { // horizontal rule case preg_match('!^-{4,}!m', $block): $block = "<hr />\n"; break;

// headings case preg_match('!^=.*=$!m', $block): $block = trim($block); $block = <B style="color:black;background-color:#A0FFFF">preg_replace</B>('!=!', '', $block); $block = $this->para($block); $block = $this->parse_text($block); $block = "<h3>$block</h3>\n"; break;

// lists case preg_match('!^\s*[*#]!m', $block, $m): unset($list, $nlist); $block = $this->para($block); $block = split("\n", $block); foreach ($block as $line) { $line = <B style="color:black;background-color:#A0FFFF">preg_replace</B>('!([#*]+)!', '\1jjj', $line); $list[] = preg_split('!jjj!', $line); } foreach ($list as $key=> $line) { $list[$key]['d'] = trim(strlen($list[$key][0])); (preg_match('!\*+!', trim($line[0]))) ? $lt = 'ul' : $lt = 'ol'; $list[$key][0] = $lt; //foreach ($line as $key2 => $val) // $list[$key][$key2] = trim($val); } foreach ($list as $key=> $line) { $next = $key + 1; $tlt = $line[0]; $nlt = $list[$next][0]; $listtext = $this->parse_text($line[1]);

// If next item is indented farther if ($list[$next]['d'] > $line['d']) { $nlist .= "\t<li>$listtext\n<$nlt>\n"; // If next item is indented less but does exit } else if ($list[$next]['d'] < $line['d'] && $list[$next]) { $numdown = $line['d'] - $list[$next]['d']; $close = str_repeat("</$tlt></li>", $numdown); $nlist .= "\t<li>$listtext</li>\n$close\n"; // If next item is the same indentation } else { $nlist .= "\t<li>$listtext</li>\n"; } } $last = $list; $last = array_pop($last); $last = $last['d'] - 1; $close = str_repeat("</$tlt></li>", $last); $block = "<{$list[0][0]}>\n$nlist\n$close</{$list[0][0]}>"; break;

// blockquote case preg_match('!^>!', trim($block)): $block = <B style="color:black;background-color:#A0FFFF">preg_replace</B>('!^>\s*!', '', $block); $block = <B style="color:black;background-color:#A0FFFF">preg_replace</B>('!\n>!', "\n", $block); $block = trim($block); $block = $this->para($block); $block = <B style="color:black;background-color:#A0FFFF">preg_replace</B>("!\n!m", "<br />\n", $block); $block = $this->parse_text($block); $block = "<blockquote>\n$block\n</blockquote>"; break;

// pre case preg_match('!\n[ \t][^ \t]!', $block): $block = htmlspecialchars($block); $block = "<pre>$block</pre>"; break;

// else make it a generic paragraph default: $block = $this->para($block); $block = <B style="color:black;background-color:#A0FFFF">preg_replace</B>('!^\s*(\w*:) !Um', '<b>\1</b>&nbsp;&nbsp; ', $block); $block = <B style="color:black;background-color:#A0FFFF">preg_replace</B>('!^\s*:([\w\s]*:) !Um', '<b>\1</b>&nbsp;&nbsp; ', $block); $block = <B style="color:black;background-color:#A0FFFF">preg_replace</B>("!\n!m", "<br />\n", $block); $block = <B style="color:black;background-color:#A0FFFF">preg_replace</B>('!^!m', "\t", $block); $block = $this->parse_text($block); $block = "<p>\n$block\n</p>"; break; } $page[] = $block; }

$page = join("\n\n", $page);

return "$page\n\n"; }

function parse_text ($text) { // bold & italic & underline $text = <B style="color:black;background-color:#A0FFFF">preg_replace</B>("![\s\n>]/([\w].*)/!Um", ' <i>\1</i>', $text); $text = <B style="color:black;background-color:#A0FFFF">preg_replace</B>("![\s\n>]\+([\w].*)\+!Um", ' <b>\1</b>', $text); $text = <B style="color:black;background-color:#A0FFFF">preg_replace</B>("![\s\n>]_([\w].*)_!Um", ' <u>\1</u>', $text);

// links $text = preg_replace_callback('!(([\s=+/>]|^)[<B style="color:black;background-color:#ffff66">A-Z</B>]+[<B style="color:black;background-color:#ffff66">a-z</B>]*([<B style="color:black;background-color:#ffff66">A-Z</B>][<B style="color:black;background-color:#ffff66">a-z</B>]{1,})([<B style="color:black;background-color:#ffff66">A-Z</B>][<B style="color:black;background-color:#ffff66">a-z</B>]*)*\d*)!', array($this, 'link'), $text); $text = <B style="color:black;background-color:#A0FFFF">preg_replace</B>("!([^|])((http|ftp|news)://([^ <]+))!", '\1 <a href="\2">\2</a>', $text); $text = <B style="color:black;background-color:#A0FFFF">preg_replace</B>("!\[(.*)\|(.*)]!U", ' <a href="\2">\1</a>', $text); $text = <B style="color:black;background-color:#A0FFFF">preg_replace</B>("!(\s[^\s]*@[^\s]*\.\w{1,6})!", ' <a href="mailto:\1">\1</a>', $text);

return $text; }

function link ($loc) {

if ( !empty($loc[2]) ) { preg_match('!^(.)(.*)!', $loc[0], $loc); } else { $loc[2] = $loc[1].$loc[2]; $loc[1] = ''; }

$loc[1] = <B style="color:black;background-color:#A0FFFF">preg_replace</B>('/!/', '', $loc[1]); $desc = <B style="color:black;background-color:#A0FFFF">preg_replace</B>('!([<B style="color:black;background-color:#ffff66">a-z</B>])([A-Z0-9])!', '\1 \2', $loc[2]); if ($this->file->is(IWIKI_DATA.$loc[2])) return "$loc[1]<a href=\"{$_SERVER['SCRIPT_NAME']}/$loc[2]\">$desc</a>"; return "$loc[1]$loc[2]<a href=\"{$_SERVER['SCRIPT_NAME']}/$loc[2]\">?</a>"; }


EditText of this page (last edited May 7, 2005) or FindPage with title or text search