Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Item11808: perltidy them all, so people are not accidentally impacted…
… by the new enforced rule -- Sorry Micha, could not find a way to define specific values within the file

git-svn-id: http://svn.foswiki.org/trunk/PublishPlugin@14686 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
OlivierRaginel authored and OlivierRaginel committed May 4, 2012
1 parent ed415e7 commit b1116d0
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 138 deletions.
27 changes: 15 additions & 12 deletions lib/Foswiki/Plugins/PublishPlugin.pm
Expand Up @@ -7,7 +7,7 @@ package Foswiki::Plugins::PublishPlugin;
use strict;
use warnings;

use Foswiki ();
use Foswiki ();
use Foswiki::Func ();
use Error qw( :try );
use Assert;
Expand Down Expand Up @@ -70,7 +70,7 @@ sub _publishRESTHandler {
$query->delete('web');
$webs =~ m#([\w/.,\s]*)#; # clean up and untaint

$publisher->publish(split(/[,\s]+/, $1));
$publisher->publish( split( /[,\s]+/, $1 ) );
}
$publisher->finish();
}
Expand All @@ -89,7 +89,7 @@ sub _display {

# Allow manipulation of $Foswiki::cfg{PublishPlugin}{Dir}
sub _publishControlCentre {
my ($session, $params, $topic, $web, $topicObject) = @_;
my ( $session, $params, $topic, $web, $topicObject ) = @_;

my $query = Foswiki::Func::getCgiQuery();

Expand All @@ -98,6 +98,7 @@ sub _publishControlCentre {
return CGI::span( { class => 'foswikiAlert' },
"Only admins can access the control interface" );
}

# Old code doesn't have isAnAdmin so will allow access to
# the control UI for everyone. Caveat emptor.

Expand All @@ -115,12 +116,13 @@ HERE

if ( $action eq 'delete' ) {
$file =~ m#([\w./\\]+)#; # untaint
if (-e "$Foswiki::cfg{PublishPlugin}{Dir}/$1") {
File::Path::rmtree("$Foswiki::cfg{PublishPlugin}{Dir}/$1");
$output .= CGI::p("$1 deleted");
} else {
$output .= CGI::p("Cannot delete $1 - no such file");
}
if ( -e "$Foswiki::cfg{PublishPlugin}{Dir}/$1" ) {
File::Path::rmtree("$Foswiki::cfg{PublishPlugin}{Dir}/$1");
$output .= CGI::p("$1 deleted");
}
else {
$output .= CGI::p("Cannot delete $1 - no such file");
}
}
if ( opendir( D, $Foswiki::cfg{PublishPlugin}{Dir} ) ) {
my @files = grep( !/^\./, readdir(D) );
Expand All @@ -132,8 +134,8 @@ HERE
my @cols = ( CGI::th($link) );
my $delcol = CGI::start_form(
{
action => Foswiki::Func::getScriptUrl(
$web, $topic, 'view'),
action =>
Foswiki::Func::getScriptUrl( $web, $topic, 'view' ),
method => 'POST',
name => $file
}
Expand All @@ -145,7 +147,8 @@ HERE
}
);
$delcol .= "<input type='hidden' name='file' value='$file'/>";
$delcol .= "<input type='hidden' name='action' value='delete' />";
$delcol .=
"<input type='hidden' name='action' value='delete' />";
$delcol .= "<input type='hidden' name='control' value='1' />";
$delcol .= CGI::end_form();
push( @cols, $delcol );
Expand Down
17 changes: 9 additions & 8 deletions lib/Foswiki/Plugins/PublishPlugin/BackEnd.pm
Expand Up @@ -38,11 +38,14 @@ Construct a new back end.
sub new {
my ( $class, $params, $path, $logger ) = @_;
$path .= '/' unless $path =~ m#/$#;
my $this = bless( {
path => $path,
params => $params,
logger => $logger
}, $class );
my $this = bless(
{
path => $path,
params => $params,
logger => $logger
},
$class
);
return $this;
}

Expand All @@ -54,9 +57,7 @@ Get schema of query parameters, in the same format as Publisher.pm
=cut

sub param_schema {
return {
relativeurl => { default => '/' },
};
return { relativeurl => { default => '/' }, };
}

=begin TML
Expand Down
66 changes: 30 additions & 36 deletions lib/Foswiki/Plugins/PublishPlugin/PageAssembler.pm
Expand Up @@ -6,27 +6,25 @@ use strict;
use Foswiki;
use Foswiki::Plugins;


# This module assembles a page from the text and the template,
# and does similar processing to that found in
# Foswiki::writeCompletePage - i.e. rendering the "head" and
# "script" zones and inserting them into the right place in
# "script" zones and inserting them into the right place in
# the page. Later versions of Foswiki also render other zones
# at the same time.
#
# The challenge is that the Foswiki core has changed over time.
# Different versions of Foswiki do it differently, and the
# ZonePlugin patches the Foswiki core to do it in another
# ZonePlugin patches the Foswiki core to do it in another
# slightly differently way.
#
# Therefore, this module contains code for each incarnation
# of the core, and chooses the right approach at runtime.


my $Assembler;

sub assemblePage
{
sub assemblePage {

#my $publisher = shift;
#my $tmpl = shift;
#my $text = shift;
Expand All @@ -36,36 +34,35 @@ sub assemblePage
return $Assembler->(@_);
}

sub _chooseMethod
{
if (not $Foswiki::Plugins::VERSION or $Foswiki::Plugins::VERSION < 2.0)
{
# Ancient, or else not Foswiki - use something that is guaranteed to work.
sub _chooseMethod {
if ( not $Foswiki::Plugins::VERSION or $Foswiki::Plugins::VERSION < 2.0 ) {

# Ancient, or else not Foswiki - use something that is guaranteed to work.
return \&_noHeadOrScriptZones;
}
elsif ($Foswiki::Plugins::VERSION < 2.1)
{
elsif ( $Foswiki::Plugins::VERSION < 2.1 ) {

# Foswiki 1.0.x - need to check if ZonePlugin is installed or not
#
# Cannot use the contexts because PublishPlugin "leaves" the
# contexts for disabled plugins, but "leaving" the
# Cannot use the contexts because PublishPlugin "leaves" the
# contexts for disabled plugins, but "leaving" the
# ZonePluginEnabled context does not undo ZonePlugin's
# monkey-patching.
if ($Foswiki::cfg{Plugins}{ZonePlugin}{Enabled})
{
if ( $Foswiki::cfg{Plugins}{ZonePlugin}{Enabled} ) {

# 1.0 with ZonePlugin - use a simple implementation
# because ZonePlugin inserts zones in the completePageHandler
return \&_noHeadOrScriptZones;
}
else
{
else {

# 1.0 without ZonePlugin - mimic the behaviour of the core
return \&_foswiki1x0NoZonePlugin;
}

}
else
{
else {

# Foswiki 1.1 or later - mimic the behaviour of the core
return \&_foswiki1x1;
}
Expand All @@ -75,40 +72,36 @@ sub _chooseMethod
}

# This is the classic PublishPlugin way. The head and script zones are NOT rendered here.
sub _noHeadOrScriptZones
{
sub _noHeadOrScriptZones {
my $publisher = shift;
my $tmpl = shift;
my $tmpl = shift;
return $tmpl;
}

# This is for use with 1.0.x, WITHOUT the ZonePlugin
sub _foswiki1x0NoZonePlugin
{
my $publisher = shift;
my $tmpl = shift;
sub _foswiki1x0NoZonePlugin {
my $publisher = shift;
my $tmpl = shift;
my $addedToHead = $Foswiki::Plugins::SESSION->RENDERHEAD();
$tmpl =~ s/(<\/head>)/$addedToHead$1/;
return $tmpl;
}

sub _foswiki1x1
{
sub _foswiki1x1 {
my $publisher = shift;
my $tmpl = shift;
my $tmpl = shift;

# nasty kludge. backup zone content for plugins which only call
# addToZone during plugin initialization. _renderZones deletes
# the zone content and subsequent published topics will be missing
# that content
my $this = $Foswiki::Plugins::SESSION;
my %zones;
while( my ( $zoneName, $zone ) = each %{ $this->{_zones} } )
{
$zones{$zoneName} = {};
while ( my ( $zoneName, $zone ) = each %{ $this->{_zones} } ) {
$zones{$zoneName} = {};

$zones{$zoneName}{$_} = $zone->{$_}
foreach grep { /^JQUERYPLUGIN::/ } keys %$zone;
$zones{$zoneName}{$_} = $zone->{$_}
foreach grep { /^JQUERYPLUGIN::/ } keys %$zone;
}

my $result = $Foswiki::Plugins::SESSION->_renderZones($tmpl);
Expand All @@ -119,6 +112,7 @@ sub _foswiki1x1
}

1;

# Copyright (C) 2010 Arthur Clemens, http://visiblearea.com
# Copyright (C) 2010 Michael Tempest
#
Expand Down
8 changes: 4 additions & 4 deletions lib/Foswiki/Plugins/PublishPlugin/Publisher.pm
Expand Up @@ -338,14 +338,14 @@ sub publish {
( $header, $footer ) = $this->_getPageTemplate();
}

$this->logInfo( '', "<h1>Publishing Details</h1>" );
$this->logInfo( '', "<h1>Publishing Details</h1>" );
$this->logInfo( "Publisher", $this->{publisher} );
$this->logInfo( "Date", Foswiki::Func::formatTime( time() ) );
$this->logInfo( "Dir",
"$Foswiki::cfg{PublishPlugin}{Dir}$this->{relativedir}" );
$this->logInfo( "URL",
"$Foswiki::cfg{PublishPlugin}{URL}$this->{relativeurl}" );
$this->logInfo( "Web(s)", join( ', ', @webs ) );
$this->logInfo( "Web(s)", join( ', ', @webs ) );
$this->logInfo( "Versions topic", $this->{versions} )
if $this->{versions};
$this->logInfo( "Content Generator", $this->{format} );
Expand Down Expand Up @@ -394,7 +394,7 @@ TEXT
$this->{history} = "$hw.$ht";

foreach my $web (@webs) {
$this->_publishWeb($web);
$this->_publishWeb($web);
}

my ( $meta, $text ) = Foswiki::Func::readTopic( $hw, $ht );
Expand Down Expand Up @@ -435,7 +435,7 @@ TEXT
}

sub _publishWeb {
my ($this, $web) = @_;
my ( $this, $web ) = @_;

$this->{web} = $web;

Expand Down

0 comments on commit b1116d0

Please sign in to comment.