*** /data/tmp/TWiki/lib/TWiki/Plugins/InterwikiPlugin.pm Mon Oct 27 16:04:35 2003
--- /data/twiki/lib/TWiki/Plugins/InterwikiPlugin.pm Tue Oct 28 10:08:37 2003
***************
*** 53,62 ****
# Regexes for the Site:page format InterWiki reference - updated to support
# 8-bit characters in both parts - see Codev.InternationalisationEnhancements
# TODO: Need to update the Plugins API to support export of regexes and regex components
! $prefixPattern = '(^|[\s\-\*\(])';
$sitePattern = "([${TWiki::upperAlpha}][${TWiki::mixedAlphaNum}]+)";
$pagePattern = "([${TWiki::mixedAlphaNum}_\/][${TWiki::mixedAlphaNum}" . '\+\_\.\,\;\:\!\?\/\%\#-]+?)';
! $postfixPattern = '(?=[\s\.\,\;\:\!\?\)]*(\s|$))';
# =========================
# Plugin startup - read preferences and get all InterWiki Site->URL mappings
--- 53,62 ----
# Regexes for the Site:page format InterWiki reference - updated to support
# 8-bit characters in both parts - see Codev.InternationalisationEnhancements
# TODO: Need to update the Plugins API to support export of regexes and regex components
! $prefixPattern = '(^|[\s\-\*\(\[])';
$sitePattern = "([${TWiki::upperAlpha}][${TWiki::mixedAlphaNum}]+)";
$pagePattern = "([${TWiki::mixedAlphaNum}_\/][${TWiki::mixedAlphaNum}" . '\+\_\.\,\;\:\!\?\/\%\#-]+?)';
! $postfixPattern = '(?=[\s\.\,\;\:\!\?\)]*([\]\s]|$))';
# =========================
# Plugin startup - read preferences and get all InterWiki Site->URL mappings
***************
*** 122,136 ****
}
# =========================
! sub DISABLE_startRenderingHandler
{
### my ( $text, $web ) = @_; # do not uncomment, use $_[0], $_[1] instead
&TWiki::Func::writeDebug( "- InterwikiPlugin::startRenderingHandler( $_[1] )" ) if $debug;
}
# =========================
# Expand the Site:page references, called once per line of text
! sub outsidePREHandler
{
### my ( $text ) = @_; # do not uncomment, use $_[0] instead
--- 122,138 ----
}
# =========================
! sub startRenderingHandler
{
### my ( $text, $web ) = @_; # do not uncomment, use $_[0], $_[1] instead
&TWiki::Func::writeDebug( "- InterwikiPlugin::startRenderingHandler( $_[1] )" ) if $debug;
+ $_[0] =~ s/$prefixPattern(\s+)$sitePattern:$pagePattern$postfixPattern/&handleInterwiki("$1$2", "$3", "$4")/geo;
+ $_[0] =~ s/$prefixPattern$sitePattern:$pagePattern$postfixPattern/&handleInterwiki($1, $2,$3)/geo;
}
# =========================
# Expand the Site:page references, called once per line of text
! sub DISABLE_outsidePREHandler
{
### my ( $text ) = @_; # do not uncomment, use $_[0] instead
***************
*** 146,156 ****
# =========================
sub handleInterwiki
{
! my( $theSite, $theTopic ) = @_;
! &TWiki::Func::writeDebug( "- InterwikiPlugin::handleInterwikiSiteLink: (site: $theSite), (topic: $theTopic)" ) if $debug;
! my $text = "";
if( defined( $interSiteTable{ $theSite } ) ) {
my( $url, $help ) = split( /\s+/, $interSiteTable{ $theSite }, 2 );
my $title = "";
--- 148,158 ----
# =========================
sub handleInterwiki
{
! my( $thePrefix, $theSite, $theTopic ) = @_;
! &TWiki::Func::writeDebug( "- InterwikiPlugin::handleInterwikiSiteLink: (prefix: $thePrefix), (site: $theSite), (topic: $theTopic)" );
! my $text = "$thePrefix";
if( defined( $interSiteTable{ $theSite } ) ) {
my( $url, $help ) = split( /\s+/, $interSiteTable{ $theSite }, 2 );
my $title = "";
***************
*** 161,170 ****
$title = " title=\"$help\"";
}
&TWiki::Func::writeDebug( " (url: $url), (help: $help)" ) if $debug;
! if( $url =~ s/\$page/$theTopic/go ) {
! $text = "$theSite\:$theTopic";
! } else {
! $text = "$theSite\:$theTopic";
}
} else {
$text = "$theSite\:$theTopic";
--- 163,183 ----
$title = " title=\"$help\"";
}
&TWiki::Func::writeDebug( " (url: $url), (help: $help)" ) if $debug;
! if ( $thePrefix =~ /\[/ )
! {
! if( $url =~ s/\$page/$theTopic/go ) {
! $text .= "$url";
! } else {
! $text .= "$url$theTopic";
! }
! }
! else
! {
! if( $url =~ s/\$page/$theTopic/go ) {
! $text .= "$theSite\:$theTopic";
! } else {
! $text .= "$theSite\:$theTopic";
! }
}
} else {
$text = "$theSite\:$theTopic";