Changeset 8159
- Timestamp:
- 07/13/10 12:24:35 (23 months ago)
- Location:
- trunk/InterwikiPlugin
- Files:
-
- 3 edited
-
lib/Foswiki/Plugins/InterwikiPlugin.pm (modified) (2 diffs)
-
lib/Foswiki/Plugins/InterwikiPlugin/build.pl (modified) (2 diffs)
-
test/unit/InterwikiPlugin/InterwikiPluginTests.pm (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/InterwikiPlugin/lib/Foswiki/Plugins/InterwikiPlugin.pm
r8145 r8159 55 55 my $ua = $Foswiki::regex{upperAlpha}; 56 56 %interSiteTable = (); 57 $sitePattern = "([$ua][$man]+)"; 58 $pagePattern = "([${man}_\/][$man" . '"\'\.\/\+\_\,\&\;\:\=\!\?\%\#\@\-]*?)'; 57 $sitePattern = "([$ua][$man]+)"; 58 $pagePattern = 59 "([${man}_\/][$man" . '"\'\.\/\+\_\,\&\;\:\=\!\?\%\#\@\-]*?)'; 59 60 60 61 # Get plugin preferences from InterwikiPlugin topic … … 69 70 ); 70 71 71 if(! Foswiki::Func::checkAccessPermission( 'VIEW', $user, undef, $interTopic, $interWeb ) ){ 72 Foswiki::Func::writeWarning("InterwikiPlugin: user '$user' did not have permission to read the rules topic at '$interWeb.$interTopic'"); 72 if ( 73 !Foswiki::Func::checkAccessPermission( 74 'VIEW', $user, undef, $interTopic, $interWeb 75 ) 76 ) 77 { 78 Foswiki::Func::writeWarning( 79 "InterwikiPlugin: user '$user' did not have permission to read the rules topic at '$interWeb.$interTopic'" 80 ); 73 81 return 1; 74 82 } -
trunk/InterwikiPlugin/lib/Foswiki/Plugins/InterwikiPlugin/build.pl
r3959 r8159 6 6 7 7 BEGIN { 8 foreach my $pc (split(/:/, $ENV{FOSWIKI_LIBS})) {9 unshift @INC, $pc;10 }8 foreach my $pc ( split( /:/, $ENV{FOSWIKI_LIBS} ) ) { 9 unshift @INC, $pc; 10 } 11 11 } 12 12 … … 14 14 15 15 # Create the build object 16 my $build = new Foswiki::Contrib::Build( 'InterwikiPlugin');16 my $build = new Foswiki::Contrib::Build('InterwikiPlugin'); 17 17 18 18 # Build the target on the command line, or the default target 19 $build->build( $build->{target});19 $build->build( $build->{target} ); 20 20 -
trunk/InterwikiPlugin/test/unit/InterwikiPlugin/InterwikiPluginTests.pm
r8145 r8159 23 23 24 24 sub tear_down { 25 my $this = shift;26 $this->SUPER::tear_down();25 my $this = shift; 26 $this->SUPER::tear_down(); 27 27 } 28 28 … … 30 30 31 31 sub test_link_from_default_rules_topic { 32 my $this = shift;33 $this->assert_html_equals(34 '<a class="interwikiLink" href="http://en.wikipedia.org/wiki/Perl" title="\'Perl\' on \'Wikipedia\'"><noautolink>Wikipedia:Perl</noautolink></a>',35 Foswiki::Func::renderText("Wikipedia:Perl", $this->{test_web})36 );32 my $this = shift; 33 $this->assert_html_equals( 34 '<a class="interwikiLink" href="http://en.wikipedia.org/wiki/Perl" title="\'Perl\' on \'Wikipedia\'"><noautolink>Wikipedia:Perl</noautolink></a>', 35 Foswiki::Func::renderText( "Wikipedia:Perl", $this->{test_web} ) 36 ); 37 37 } 38 38 39 39 sub test_link_from_local_rules_topic { 40 my $this = shift;40 my $this = shift; 41 41 my $localRulesTopic = "LocalInterWikis"; 42 42 … … 51 51 HERE 52 52 53 Foswiki::Func::setPreferencesValue("INTERWIKIPLUGIN_RULESTOPIC", "$this->{test_web}.$localRulesTopic"); 54 Foswiki::Plugins::InterwikiPlugin::initPlugin($this->{test_web}, $this->{test_topic}, $this->{test_user}, $Foswiki::cfg{SystemWebName}); 53 Foswiki::Func::setPreferencesValue( "INTERWIKIPLUGIN_RULESTOPIC", 54 "$this->{test_web}.$localRulesTopic" ); 55 Foswiki::Plugins::InterwikiPlugin::initPlugin( 56 $this->{test_web}, $this->{test_topic}, 57 $this->{test_user}, $Foswiki::cfg{SystemWebName} 58 ); 55 59 56 $this->assert_html_equals(57 '<a class="interwikiLink" href="http://rule.invalid.url?page=Topage" title="Local rule"><noautolink>Localrule:Topage</noautolink></a>',58 Foswiki::Func::renderText("Localrule:Topage", $this->{test_web})59 );60 $this->assert_html_equals( 61 '<a class="interwikiLink" href="http://rule.invalid.url?page=Topage" title="Local rule"><noautolink>Localrule:Topage</noautolink></a>', 62 Foswiki::Func::renderText( "Localrule:Topage", $this->{test_web} ) 63 ); 60 64 } 61 65 66 sub test_cant_view_rules_topic { 67 my $this = shift; 68 my $rulesTopic = "CantReadInterWikis"; 62 69 63 sub test_cant_view_rules_topic { 64 my $this = shift; 65 my $rulesTopic = "CantReadInterWikis"; 66 67 Foswiki::Func::saveTopic( $this->{test_web}, $rulesTopic, undef, 68 <<'HERE'); 70 Foswiki::Func::saveTopic( $this->{test_web}, $rulesTopic, undef, <<'HERE'); 69 71 ---+++ Local rules 70 72 <noautolink> … … 77 79 HERE 78 80 79 Foswiki::Func::setPreferencesValue( "INTERWIKIPLUGIN_RULESTOPIC", "$this->{test_web}.$rulesTopic");80 Foswiki::Plugins::InterwikiPlugin::initPlugin($this->{test_web}, $this->{test_topic}, 'guest', $Foswiki::cfg{SystemWebName});81 82 $this->assert_html_equals(83 'Localrule:Topage', 84 Foswiki::Func::renderText("Localrule:Topage", $this->{test_web})85 );81 Foswiki::Func::setPreferencesValue( "INTERWIKIPLUGIN_RULESTOPIC", 82 "$this->{test_web}.$rulesTopic" ); 83 Foswiki::Plugins::InterwikiPlugin::initPlugin( $this->{test_web}, 84 $this->{test_topic}, 'guest', $Foswiki::cfg{SystemWebName} ); 85 86 $this->assert_html_equals( 'Localrule:Topage', 87 Foswiki::Func::renderText( "Localrule:Topage", $this->{test_web} ) ); 86 88 } 87 89 … … 89 91 my $this = shift; 90 92 $this->assert_html_equals( 91 '<a class="interwikiLink" href="http://en.wikipedia.org/wiki/http://www.google.com/search?q=foswiki&foo=bar" title="\'http://www.google.com/search?q=foswiki&foo=bar\' on \'Wikipedia\'"><noautolink>Wikipedia:http://www.google.com/search?q=foswiki&foo=bar</noautolink></a>', 92 Foswiki::Func::renderText("Wikipedia:http://www.google.com/search?q=foswiki&foo=bar", $this->{test_web}) 93 ); 93 '<a class="interwikiLink" href="http://en.wikipedia.org/wiki/http://www.google.com/search?q=foswiki&foo=bar" title="\'http://www.google.com/search?q=foswiki&foo=bar\' on \'Wikipedia\'"><noautolink>Wikipedia:http://www.google.com/search?q=foswiki&foo=bar</noautolink></a>', 94 Foswiki::Func::renderText( 95 "Wikipedia:http://www.google.com/search?q=foswiki&foo=bar", 96 $this->{test_web} 97 ) 98 ); 94 99 } 95 100 … … 99 104 my $this = shift; 100 105 $this->assert_html_equals( 101 '<a class="interwikiLink" href="http://en.wikipedia.org/wiki/http://www.google.com/search?q=foswiki&foo="bar"/\'baz.\'" title="\'http://www.google.com/search?q=foswiki&foo="bar"/\'baz.\'\' on \'Wikipedia\'"><noautolink>Wikipedia:http://www.google.com/search?q=foswiki&foo="bar"/\'baz.\'</noautolink></a>', 102 Foswiki::Func::renderText('Wikipedia:http://www.google.com/search?q=foswiki&foo="bar"/\'baz.\'', $this->{test_web}) 103 ); 106 '<a class="interwikiLink" href="http://en.wikipedia.org/wiki/http://www.google.com/search?q=foswiki&foo="bar"/\'baz.\'" title="\'http://www.google.com/search?q=foswiki&foo="bar"/\'baz.\'\' on \'Wikipedia\'"><noautolink>Wikipedia:http://www.google.com/search?q=foswiki&foo="bar"/\'baz.\'</noautolink></a>', 107 Foswiki::Func::renderText( 108 'Wikipedia:http://www.google.com/search?q=foswiki&foo="bar"/\'baz.\'', 109 $this->{test_web} 110 ) 111 ); 104 112 } 105 113 106 114 sub test_link_with_topic_name { 107 my $this = shift;115 my $this = shift; 108 116 my $localRulesTopic = "LocalInterWikis"; 109 117 … … 117 125 HERE 118 126 119 Foswiki::Func::setPreferencesValue("INTERWIKIPLUGIN_RULESTOPIC", "$this->{test_web}.$localRulesTopic"); 120 Foswiki::Plugins::InterwikiPlugin::initPlugin($this->{test_web}, $this->{test_topic}, $this->{test_user}, $Foswiki::cfg{SystemWebName}); 127 Foswiki::Func::setPreferencesValue( "INTERWIKIPLUGIN_RULESTOPIC", 128 "$this->{test_web}.$localRulesTopic" ); 129 Foswiki::Plugins::InterwikiPlugin::initPlugin( 130 $this->{test_web}, $this->{test_topic}, 131 $this->{test_user}, $Foswiki::cfg{SystemWebName} 132 ); 121 133 122 $this->assert_html_equals(123 '<a class="interwikiLink" href="http://rule.invalid.url?page=Topage" title="Local rule"><noautolink>WebHome:Topage</noautolink></a>',124 Foswiki::Func::renderText("WebHome:Topage", $this->{test_web})125 );134 $this->assert_html_equals( 135 '<a class="interwikiLink" href="http://rule.invalid.url?page=Topage" title="Local rule"><noautolink>WebHome:Topage</noautolink></a>', 136 Foswiki::Func::renderText( "WebHome:Topage", $this->{test_web} ) 137 ); 126 138 } 127 139
Note: See TracChangeset
for help on using the changeset viewer.
