X-Git-Url: https://git.deb.at/?p=pkg%2Fblosxom.git;a=blobdiff_plain;f=blosxom.cgi;h=7fff46341709f41d608f3e0a8650911322c4adc2;hp=02230245f3c086c61dd0f0135cb8e4f26aa11c70;hb=ed43f9cbb775f818ea14ed642f9f386a6283c000;hpb=c73392f240218cc9480aa672afb632a70e64311f diff --git a/blosxom.cgi b/blosxom.cgi index 0223024..7fff463 100755 --- a/blosxom.cgi +++ b/blosxom.cgi @@ -137,7 +137,7 @@ $url =~ s!/$!!; $datadir =~ s!/$!!; $plugin_dir =~ s!/$!!; $static_dir =~ s!/$!!; # Fix depth to take into account datadir's path -$depth and $depth += ($datadir =~ tr[/][]) - 1; +$depth += ($datadir =~ tr[/][]) - 1 if $depth; # Global variable to be used in head/foot.{flavour} templates $path_info = ''; @@ -157,7 +157,7 @@ $flavour = ''; if ( $path_info[$#path_info] =~ /(.+)\.(.+)$/ ) { $flavour = $2; - $1 ne 'index' and $path_info .= "/$1.$2"; + $path_info .= "/$1.$2" if $1 ne 'index'; pop @path_info; } else { $flavour = param('flav') || $default_flavour; @@ -241,7 +241,7 @@ foreach my $plugin ( @plugin_list ) { else { eval { require $plugin }; } - $@ and warn "error finding or loading blosxom plugin $plugin_name - skipping\n" and next; + $@ and warn "$@ error finding or loading blosxom plugin $plugin_name - skipping\n" and next; $plugin_name->start() and ( $plugins{$plugin_name} = $on_off ) and push @plugins, $plugin_name; } shift @INC foreach @plugin_dirs; @@ -324,8 +324,8 @@ if (!$ENV{GATEWAY_INTERFACE} and param('-password') and $static_password and par foreach ( ('', split /\//, $path) ) { $p .= "/$_"; $p =~ s!^/!!; - $done{$p}++ and next; - (-d "$static_dir/$p" or $p =~ /\.$file_extension$/) or mkdir "$static_dir/$p", 0755; + next if $done{$p}++; + mkdir "$static_dir/$p", 0755 unless (-d "$static_dir/$p" or $p =~ /\.$file_extension$/); foreach $flavour ( @static_flavours ) { my $content_type = (&$template($p,'content_type',$flavour)); $content_type =~ s!\n.*!!s; @@ -379,7 +379,16 @@ sub generate { # Plugins: Skip # Allow plugins to decide if we can cut short story generation - my $skip; foreach my $plugin ( @plugins ) { $plugins{$plugin} > 0 and $plugin->can('skip') and defined($tmp = $plugin->skip()) and $skip = $tmp and last; } + my $skip; + foreach my $plugin (@plugins) { + if ( $plugins{$plugin} > 0 and $plugin->can('skip') ) { + if ( my $tmp = $plugin->skip() ) { + $skip = $tmp; + last; + } + } + } + # Define default interpolation subroutine $interpolate = @@ -396,13 +405,24 @@ sub generate { # Plugins: Interpolate # Allow for the first encountered plugin::interpolate subroutine to # override the default built-in interpolate subroutine - my $tmp; foreach my $plugin ( @plugins ) { $plugins{$plugin} > 0 and $plugin->can('interpolate') and defined($tmp = $plugin->interpolate()) and $interpolate = $tmp and last; } + foreach my $plugin (@plugins) { + if ( $plugins{$plugin} > 0 and $plugin->can('interpolate') ) { + if ( my $tmp = $plugin->interpolate() ) { + $interpolate = $tmp; + last; + } + } + } # Head my $head = (&$template($currentdir,'head',$flavour)); # Plugins: Head - foreach my $plugin ( @plugins ) { $plugins{$plugin} > 0 and $plugin->can('head') and $entries = $plugin->head($currentdir, \$head) } + foreach my $plugin (@plugins) { + if ( $plugins{$plugin} > 0 and $plugin->can('head') ) { + $entries = $plugin->head( $currentdir, \$head ); + } + } $head = &$interpolate($head);