[SimBot-commits] CVS: simbot/plugins sqlite-logger.pl,1.52,1.53
Status: Abandoned
Brought to you by:
kstange
|
From: Pete P. <fou...@us...> - 2005-08-10 19:27:00
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2970/plugins Modified Files: sqlite-logger.pl Log Message: Links like (http://what.ever/) are now linked with the ()s on the outside. Index: sqlite-logger.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/sqlite-logger.pl,v retrieving revision 1.52 retrieving revision 1.53 diff -u -d -p -r1.52 -r1.53 --- sqlite-logger.pl 10 Aug 2005 18:39:50 -0000 1.52 +++ sqlite-logger.pl 10 Aug 2005 19:26:52 -0000 1.53 @@ -946,15 +946,12 @@ sub linkify { my @words = split(/\s+/, $_[0]); my $curWord; - foreach $curWord (@words) { - my $url = $curWord; - + foreach $curWord (@words) { # remove things that commonly surround URLs - $url =~ s{^\(}{}; - $url =~ s{\)$}{}; - $url =~ s{^<}{}; - $url =~ s{>$}{}; - + my ($word_prefix, $word, $word_suffix) = $curWord + =~ m@^(["'\(<\[]?)(\S*?)(["'\)>\]]?)$@; #' + my $url = $word; + # map some common host names to protocols $url =~ s{^(www|web)\.} {http://$1\.}; $url =~ s{^ftp\.} {ftp://ftp\.}; @@ -966,7 +963,7 @@ sub linkify { } if($url =~ m{^((http|ftp|news|nntp|irc|aim)s?:[\w.?/=\-\&\;]+)}) { - $curWord = qq(<a href="$1">$curWord</a>); + $curWord = qq($word_prefix<a href="$1">$word</a>$word_suffix); next; } @@ -978,7 +975,7 @@ sub linkify { # Yup. Let's assume it's a web site... $host = 'http://' . $host; - $curWord = qq(<a href="${host}/${path}">$curWord</a>); + $curWord = qq($word_prefix<a href="${host}/${path}">$word</a>$word_suffix); } } } |