Skip to content

Commit

Permalink
Item8500: fix plugin under FastCGI. Also fixed unit test
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@8138 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
AndrewJones authored and AndrewJones committed Jul 12, 2010
1 parent 09311c4 commit 79178d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
5 changes: 2 additions & 3 deletions InterwikiPlugin/lib/Foswiki/Plugins/InterwikiPlugin.pm
Expand Up @@ -44,7 +44,6 @@ BEGIN {
require locale;
import locale();
}
%interSiteTable = ();
}

# Read preferences and get all InterWiki Site->URL mappings
Expand Down Expand Up @@ -92,11 +91,11 @@ sub preRenderingHandler {

# ref in [[ref]] or [[ref][
$_[0] =~
s/(\[\[)$sitePattern:$pagePattern(\]\]|\]\[[^\]]+\]\])/_link($1,$2,$3,$4)/geo;
s/(\[\[)$sitePattern:$pagePattern(\]\]|\]\[[^\]]+\]\])/_link($1,$2,$3,$4)/ge;

# ref in text
$_[0] =~
s/(^|[\s\-\*\(])$sitePattern:$pagePattern(?=[\s\.\,\;\:\!\?\)\|]*(\s|$))/_link($1,$2,$3)/geo;
s/(^|[\s\-\*\(])$sitePattern:$pagePattern(?=[\s\.\,\;\:\!\?\)\|]*(\s|$))/_link($1,$2,$3)/ge;

return;
}
Expand Down
22 changes: 12 additions & 10 deletions InterwikiPlugin/test/unit/InterwikiPlugin/InterwikiPluginTests.pm
Expand Up @@ -7,6 +7,7 @@ our @ISA = qw( FoswikiFnTestCase );

use Foswiki;
use Foswiki::Func;
use Foswiki::Plugins::InterwikiPlugin;

my $localRulesTopic = "LocalInterWikis";

Expand Down Expand Up @@ -44,18 +45,19 @@ sub test_link_from_default_rules_topic {
my $this = shift;
$this->assert_html_equals(
'<a class="interwikiLink" href="http://en.wikipedia.org/wiki/Perl" title="\'Perl\' on \'Wikipedia\'"><noautolink>Wikipedia:Perl</noautolink></a>',
Foswiki::Func::renderText("Wikipedia:Perl", $this->{test_topic})
Foswiki::Func::renderText("Wikipedia:Perl", $this->{test_web})
);
}

# No longer working
#sub test_link_from_local_rules_topic {
# my $this = shift;
# Foswiki::Func::setPreferencesValue("INTERWIKIPLUGIN_RULESTOPIC", "$this->{test_web}.$localRulesTopic");
# $this->assert_html_equals(
# '<a class="interwikiLink" href="http://rule.invalid.url?page=Topage" title="Local rule"><noautolink>Localrule:Topage</noautolink></a>',
# Foswiki::Func::renderText("Localrule:Topage", $this->{test_web})
# );
#}
sub test_link_from_local_rules_topic {
my $this = shift;
Foswiki::Func::setPreferencesValue("INTERWIKIPLUGIN_RULESTOPIC", "$this->{test_web}.$localRulesTopic");
Foswiki::Plugins::InterwikiPlugin::initPlugin($this->{test_web}, $this->{test_topic}, $this->{test_user}, $Foswiki::cfg{SystemWebName});

$this->assert_html_equals(
'<a class="interwikiLink" href="http://rule.invalid.url?page=Topage" title="Local rule"><noautolink>Localrule:Topage</noautolink></a>',
Foswiki::Func::renderText("Localrule:Topage", $this->{test_web})
);
}

1;

0 comments on commit 79178d6

Please sign in to comment.