]> git.deb.at Git - pkg/blosxom.git/blobdiff - blosxom.cgi
Change plugin loading to use @INC instead of fixed $plugin_dir.
[pkg/blosxom.git] / blosxom.cgi
index 4005c8c8898759d9f8937ac964507ed9d9d50ed9..2a3665681f79377153139c14bf6050df03024c1a 100755 (executable)
@@ -3,7 +3,7 @@
 # Blosxom
 # Author: Rael Dornfest <rael@oreilly.com>
 # Version: 2.0.2
 # Blosxom
 # Author: Rael Dornfest <rael@oreilly.com>
 # Version: 2.0.2
-# Home/Docs/Licensing: http://www.blosxom.com/
+# Home/Docs/Licensing: http://blosxom.sourceforge.net/
 # Development/Downloads: http://sourceforge.net/projects/blosxom
 
 package blosxom;
 # Development/Downloads: http://sourceforge.net/projects/blosxom
 
 package blosxom;
@@ -163,13 +163,23 @@ while (<DATA>) {
 
 # Plugins: Start
 if ( $plugin_dir and opendir PLUGINS, $plugin_dir ) {
 
 # 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
     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;
     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;
   }
     $plugin_name->start() and ( $plugins{$plugin_name} = $on_off ) and push @plugins, $plugin_name;
   }
+  shift @INC;
   closedir PLUGINS;
 }
 
   closedir PLUGINS;
 }
 
@@ -481,7 +491,7 @@ html date         <h3>$dw, $da $mo $yr</h3>
 html foot
 html foot         <p />
 html foot         <center>
 html foot
 html foot         <p />
 html foot         <center>
-html foot             <a href="http://www.blosxom.com/"><img src="http://www.blosxom.com/images/pb_blosxom.gif" border="0" /></a>
+html foot             <a href="http://blosxom.sourceforge.net/"><img src="http://blosxom.sourceforge.net/images/pb_blosxom.gif" border="0" /></a>
 html foot         </center>
 html foot     </body>
 html foot </html>
 html foot         </center>
 html foot     </body>
 html foot </html>