X-Git-Url: https://git.deb.at/?p=pkg%2Fblosxom.git;a=blobdiff_plain;f=blosxom.cgi;h=068b7183d1afb9f85010de247d56f428670346e7;hp=642a2bf31cf3cc66c433836eca986755fb22eb27;hb=364a736f0bce810faa7f809d4eb6cd74c2972d5b;hpb=fae8966333a61c57f4181cd5c6a4d3ffa42774f9 diff --git a/blosxom.cgi b/blosxom.cgi index 642a2bf..068b718 100755 --- a/blosxom.cgi +++ b/blosxom.cgi @@ -2,8 +2,9 @@ # Blosxom # Author: Rael Dornfest -# Version: 2.0 -# Home/Docs/Licensing: http://www.raelity.org/apps/blosxom/ +# Version: 2.0.1 +# Home/Docs/Licensing: http://www.blosxom.com/ +# Development/Downloads: http://sourceforge.net/projects/blosxom package blosxom; @@ -138,15 +139,16 @@ $template = # 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) ) { + next if ($plugin =~ /~$/); # Ignore emacs backups my($plugin_name, $off) = $plugin =~ /^\d*(\w+?)(_?)$/; my $on_off = $off eq '_' ? -1 : 1; require "$plugin_dir/$plugin"; @@ -165,7 +167,7 @@ sub load_template { return &$template(@_); } -# Define default find subroutine +# Define default entries subroutine $entries = sub { my(%files, %indexes, %others); @@ -219,10 +221,7 @@ $entries = my $tmp; foreach my $plugin ( @plugins ) { $plugins{$plugin} > 0 and $plugin->can('entries') and defined($tmp = $plugin->entries()) and $entries = $tmp and last; } my ($files, $indexes, $others) = &$entries(); -%files = %$files; %indexes = %$indexes; %others = ref $others ? %$others : (); - -# Plugins: Filter -foreach my $plugin ( @plugins ) { $plugins{$plugin} > 0 and $plugin->can('filter') and $entries = $plugin->filter(\%files, \%others) } +%indexes = %$indexes; # Static if (!$ENV{GATEWAY_INTERFACE} and param('-password') and $static_password and param('-password') eq $static_password) { @@ -236,7 +235,6 @@ if (!$ENV{GATEWAY_INTERFACE} and param('-password') and $static_password and par foreach ( ('', split /\//, $path) ) { $p .= "/$_"; $p =~ s!^/!!; - $path_info = $p; $done{$p}++ and next; (-d "$static_dir/$p" or $p =~ /\.$file_extension$/) or mkdir "$static_dir/$p", 0755; foreach $flavour ( @static_flavours ) { @@ -246,10 +244,19 @@ if (!$ENV{GATEWAY_INTERFACE} and param('-password') and $static_password and par param('-quiet') or print "$fn.$flavour\n"; my $fh_w = new FileHandle "> $static_dir/$fn.$flavour" or die "Couldn't open $static_dir/$p for writing: $!"; $output = ''; - print $fh_w - $indexes{$path} == 1 - ? &generate('static', $p, '', $flavour, $content_type) - : &generate('static', '', $p, $flavour, $content_type); + if ($indexes{$path} == 1) { + # category + $path_info = $p; + # individual story + $path_info =~ s!\.$file_extension$!\.$flavour!; + print $fh_w &generate('static', $path_info, '', $flavour, $content_type); + } else { + # date + local ($path_info_yr,$path_info_mo,$path_info_da, $path_info) = + split /\//, $p, 4; + unless (defined $path_info) {$path_info = ""}; + print $fh_w &generate('static', '', $p, $flavour, $content_type); + } $fh_w->close; } } @@ -273,6 +280,11 @@ foreach my $plugin ( @plugins ) { $plugins{$plugin} > 0 and $plugin->can('end') sub generate { my($static_or_dynamic, $currentdir, $date, $flavour, $content_type) = @_; + %files = %$files; %others = ref $others ? %$others : (); + + # Plugins: Filter + foreach my $plugin ( @plugins ) { $plugins{$plugin} > 0 and $plugin->can('filter') and $entries = $plugin->filter(\%files, \%others) } + my %f = %files; # Plugins: Skip @@ -375,7 +387,7 @@ sub generate { # Plugins: Story foreach my $plugin ( @plugins ) { $plugins{$plugin} > 0 and $plugin->can('story') and $entries = $plugin->story($path, $fn, \$story, \$title, \$body) } - if ($content_type =~ m{\Wxml$}) { + if ($content_type =~ m{\bxml\b}) { # Escape <, >, and &, and to produce valid RSS my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"'); my $escape_re = join '|' => keys %escape; @@ -427,18 +439,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__