bumped version number, updated URLs
[matthijs/upstream/blosxom.git] / blosxom.cgi
index 642a2bf31cf3cc66c433836eca986755fb22eb27..5bba603ba2b0876849b02864f9297229efb2de49 100755 (executable)
@@ -2,8 +2,9 @@
 
 # Blosxom
 # Author: Rael Dornfest <rael@oreilly.com>
-# 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;
 
@@ -147,6 +148,7 @@ while (<DATA>) {
 # 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);
@@ -236,7 +238,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 +247,17 @@ 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;
+          print $fh_w &generate('static', $p, '', $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;
       }
     }
@@ -375,7 +383,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 = ('<'=>'&lt;', '>'=>'&gt;', '&'=>'&amp;', '"'=>'&quot;');  
         my $escape_re  = join '|' => keys %escape;