Changeset 8159


Ignore:
Timestamp:
07/13/10 12:24:35 (23 months ago)
Author:
AndrewJones
Message:

Item8500: perltidy

Location:
trunk/InterwikiPlugin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/InterwikiPlugin/lib/Foswiki/Plugins/InterwikiPlugin.pm

    r8145 r8159  
    5555    my $ua  = $Foswiki::regex{upperAlpha}; 
    5656    %interSiteTable = (); 
    57     $sitePattern = "([$ua][$man]+)"; 
    58     $pagePattern = "([${man}_\/][$man" . '"\'\.\/\+\_\,\&\;\:\=\!\?\%\#\@\-]*?)'; 
     57    $sitePattern    = "([$ua][$man]+)"; 
     58    $pagePattern = 
     59      "([${man}_\/][$man" . '"\'\.\/\+\_\,\&\;\:\=\!\?\%\#\@\-]*?)'; 
    5960 
    6061    # Get plugin preferences from InterwikiPlugin topic 
     
    6970    ); 
    7071 
    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        ); 
    7381        return 1; 
    7482    } 
  • trunk/InterwikiPlugin/lib/Foswiki/Plugins/InterwikiPlugin/build.pl

    r3959 r8159  
    66 
    77BEGIN { 
    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    } 
    1111} 
    1212 
     
    1414 
    1515# Create the build object 
    16 my $build = new Foswiki::Contrib::Build( 'InterwikiPlugin' ); 
     16my $build = new Foswiki::Contrib::Build('InterwikiPlugin'); 
    1717 
    1818# Build the target on the command line, or the default target 
    19 $build->build($build->{target}); 
     19$build->build( $build->{target} ); 
    2020 
  • trunk/InterwikiPlugin/test/unit/InterwikiPlugin/InterwikiPluginTests.pm

    r8145 r8159  
    2323 
    2424sub tear_down { 
    25    my $this = shift; 
    26    $this->SUPER::tear_down(); 
     25    my $this = shift; 
     26    $this->SUPER::tear_down(); 
    2727} 
    2828 
     
    3030 
    3131sub 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    ); 
    3737} 
    3838 
    3939sub test_link_from_local_rules_topic { 
    40     my $this = shift; 
     40    my $this            = shift; 
    4141    my $localRulesTopic = "LocalInterWikis"; 
    4242 
     
    5151HERE 
    5252 
    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    ); 
    5559 
    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    ); 
    6064} 
    6165 
     66sub test_cant_view_rules_topic { 
     67    my $this       = shift; 
     68    my $rulesTopic = "CantReadInterWikis"; 
    6269 
    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'); 
    6971---+++ Local rules 
    7072<noautolink> 
     
    7779HERE 
    7880 
    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} ) ); 
    8688} 
    8789 
     
    8991    my $this = shift; 
    9092    $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    ); 
    9499} 
    95100 
     
    99104    my $this = shift; 
    100105    $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    ); 
    104112} 
    105113 
    106114sub test_link_with_topic_name { 
    107     my $this = shift; 
     115    my $this            = shift; 
    108116    my $localRulesTopic = "LocalInterWikis"; 
    109117 
     
    117125HERE 
    118126 
    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    ); 
    121133 
    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    ); 
    126138} 
    127139 
Note: See TracChangeset for help on using the changeset viewer.