From: Gavin Carr Date: Wed, 29 Aug 2007 12:52:59 +0000 (+0000) Subject: Change plugin loading to use @INC instead of fixed $plugin_dir. X-Git-Tag: debian/2.1.2-2~113 X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=0019751b63e72de049e624534f69570ca8b22e6a;p=pkg%2Fblosxom.git Change plugin loading to use @INC instead of fixed $plugin_dir. --- diff --git a/blosxom.cgi b/blosxom.cgi index 3202388..2a36656 100755 --- a/blosxom.cgi +++ b/blosxom.cgi @@ -163,13 +163,23 @@ while () { # 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; }