X-Git-Url: https://git.deb.at/?p=pkg%2Fblosxom.git;a=blobdiff_plain;f=blosxom.cgi;h=2a3665681f79377153139c14bf6050df03024c1a;hp=920a7835db7c4e215d4046adbae2d835c808d02c;hb=0019751b63e72de049e624534f69570ca8b22e6a;hpb=8b0659156fafd39059d8e3e4a617eafa320a3b68 diff --git a/blosxom.cgi b/blosxom.cgi index 920a783..2a36656 100755 --- a/blosxom.cgi +++ b/blosxom.cgi @@ -2,8 +2,8 @@ # Blosxom # Author: Rael Dornfest -# Version: 2.0.1 -# Home/Docs/Licensing: http://www.blosxom.com/ +# Version: 2.0.2 +# Home/Docs/Licensing: http://blosxom.sourceforge.net/ # Development/Downloads: http://sourceforge.net/projects/blosxom package blosxom; @@ -76,7 +76,7 @@ use File::stat; use Time::localtime; use CGI qw/:standard :netscape/; -$version = "2.0"; +$version = "2.0.2"; my $fh = new FileHandle; @@ -84,8 +84,17 @@ my $fh = new FileHandle; @num2month = sort { $month2num{$a} <=> $month2num{$b} } keys %month2num; # Use the stated preferred URL or figure it out automatically -$url ||= url(); -$url =~ s/^included:/http:/; # Fix for Server Side Includes (SSI) +$url ||= url(-path_info => 1); +$url =~ s/^included:/http:/ if $ENV{SERVER_PROTOCOL} eq 'INCLUDED'; + +# NOTE: Since v3.12, it looks as if CGI.pm misbehaves for SSIs and +# always appends path_info to the url. To fix this, we always +# request an url with path_info, and always remove it from the end of the +# string. +my $pi_len = length $ENV{PATH_INFO}; +my $might_be_pi = substr($url, -$pi_len); +substr($url, -length $ENV{PATH_INFO}) = '' if $might_be_pi eq $ENV{PATH_INFO}; + $url =~ s!/$!!; # Drop ending any / from dir settings @@ -134,26 +143,43 @@ $template = return join '', <$fh> if $fh->open("< $datadir/$path/$chunk.$flavour"); } while ($path =~ s/(\/*[^\/]*)$// and $1); - return join '', ($template{$flavour}{$chunk} || $template{error}{$chunk} || ''); + # Check for definedness, since flavour can be the empty string + if (defined $template{$flavour}{$chunk}) { + return $template{$flavour}{$chunk}; + } elsif (defined $template{error}{$chunk}) { + return $template{error}{$chunk} + } else { + return ''; + } }; # Bring in the templates %template = (); while () { - last if /^(__END__)?$/; - my($ct, $comp, $txt) = /^(\S+)\s(\S+)\s(.*)$/; + last if /^(__END__)$/; + my($ct, $comp, $txt) = /^(\S+)\s(\S+)(?:\s(.*))?$/ or next; $txt =~ s/\\n/\n/mg; - $template{$ct}{$comp} = $txt; + $template{$ct}{$comp} .= $txt . "\n"; } # Plugins: Start if ( $plugin_dir and opendir PLUGINS, $plugin_dir ) { - foreach my $plugin ( grep { /^\w+$/ && -f "$plugin_dir/$_" } sort readdir(PLUGINS) ) { + unshift @INC, $plugin_dir; + foreach my $plugin ( grep { /^[\w:]+$/ && -f "$plugin_dir/$_" } sort readdir(PLUGINS) ) { next if ($plugin =~ /~$/); # Ignore emacs backups - my($plugin_name, $off) = $plugin =~ /^\d*(\w+?)(_?)$/; + my($plugin_name, $off) = $plugin =~ /^\d*([\w:]+?)(_?)$/; my $on_off = $off eq '_' ? -1 : 1; - require "$plugin_dir/$plugin"; + # Allow perl module plugins + if ($plugin =~ m/::/ && -z "$plugin_dir/$plugin") { + # For Blosxom::Plugin::Foo style plugins, we need to use a string require + eval "require $plugin_name"; + } + else { + eval { require $plugin }; + } + $@ 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; closedir PLUGINS; } @@ -439,18 +465,73 @@ sub nice_date { # Default HTML and RSS template bits __DATA__ html content_type text/html -html head $blog_title $path_info_da $path_info_mo $path_info_yr
$blog_title
$path_info_da $path_info_mo $path_info_yr

-html story

$title
$body

posted at: $ti | path: $path | permanent link to this entry

\n -html date

$dw, $da $mo $yr

\n -html foot

+ +html head +html head +html head +html head $blog_title $path_info_da $path_info_mo $path_info_yr +html head +html head +html head +html head
+html head $blog_title
+html head $path_info_da $path_info_mo $path_info_yr +html head
+html head

+ +html story

+html story $title
+html story $body
+html story
+html story posted at: $ti | path: $path | permanent link to this entry +html story

+ +html date

$dw, $da $mo $yr

+ +html foot +html foot

+html foot

+html foot +html foot
+html foot +html foot + rss content_type text/xml -rss head \n\n\n\n\n \n $blog_title $path_info_da $path_info_mo $path_info_yr\n $url\n $blog_description\n $blog_language\n -rss story \n $title\n $url/$yr/$mo_num/$da#$fn\n $body\n \n -rss date \n -rss foot \n + +rss head +rss head +rss head +rss head +rss head +rss head +rss head $blog_title $path_info_da $path_info_mo $path_info_yr +rss head $url +rss head $blog_description +rss head $blog_language + +rss story +rss story $title +rss story $url/$yr/$mo_num/$da#$fn +rss story $body +rss story + +rss date + +rss foot +rss foot + error content_type text/html -error head

Error: I'm afraid this is the first I've heard of a "$flavour" flavoured Blosxom. Try dropping the "/+$flavour" bit from the end of the URL.\n\n -error story

$title
$body #

\n -error date

$dw, $da $mo $yr

\n -error foot + +error head +error head +error head

Error: I'm afraid this is the first I've heard of a "$flavour" flavoured Blosxom. Try dropping the "/+$flavour" bit from the end of the URL. + + +error story

$title
+error story $body #

+ +error date

$dw, $da $mo $yr

+ +error foot +error foot __END__