From: Gavin Carr Date: Sun, 9 Sep 2007 22:35:22 +0000 (+0000) Subject: Add external config support via BLOSXOM_CONFIG_DIR and BLOSXOM_CONFIG_FILE env variables. X-Git-Tag: v2_1_0~82 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=cceecf184d578e9e55db7e6439aa73320299aa29;p=matthijs%2Fupstream%2Fblosxom.git Add external config support via BLOSXOM_CONFIG_DIR and BLOSXOM_CONFIG_FILE env variables. --- diff --git a/ChangeLog b/ChangeLog index 172bbd8..5a027af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +v2.0.3 + * changed plugin loading to use @INC instead of hardcoded + $plugin_dir + * added support for external config file via BLOSXOM_CONFIG_DIR + and/or BLOSXOM_CONFIG_FILE environment variables + v2.0.2 * fixed path_info to have correct extension in static mode (bug 1368882) @@ -5,6 +11,7 @@ v2.0.2 * changed DATA section template parsing to allow newlines for greater readability, and to allow empty templates. * work-around for bug in CGI::url() when using SSI + v2.0.1 * Fixed XML escaping of RSS feeds * Ignore editor backup files in the plugin directory diff --git a/blosxom.cgi b/blosxom.cgi index 2a36656..6c51d07 100755 --- a/blosxom.cgi +++ b/blosxom.cgi @@ -67,7 +67,7 @@ $static_entries = 0; # -------------------------------- -use vars qw! $version $blog_title $blog_description $blog_language $datadir $url %template $template $depth $num_entries $file_extension $default_flavour $static_or_dynamic $plugin_dir $plugin_state_dir @plugins %plugins $static_dir $static_password @static_flavours $static_entries $path_info $path_info_yr $path_info_mo $path_info_da $path_info_mo_num $flavour $static_or_dynamic %month2num @num2month $interpolate $entries $output $header $show_future_entries %files %indexes %others !; +use vars qw! $version $blog_title $blog_description $blog_language $datadir $url %template $template $depth $num_entries $file_extension $default_flavour $static_or_dynamic $config_dir $plugin_dir $plugin_state_dir @plugins %plugins $static_dir $static_password @static_flavours $static_entries $path_info $path_info_yr $path_info_mo $path_info_da $path_info_mo_num $flavour $static_or_dynamic %month2num @num2month $interpolate $entries $output $header $show_future_entries %files %indexes %others !; use strict; use FileHandle; @@ -78,6 +78,32 @@ use CGI qw/:standard :netscape/; $version = "2.0.2"; +# Load configuration from $ENV{BLOSXOM_CONFIG_DIR}/blosxom.conf, if it exists +my $blosxom_config; +if ($ENV{BLOSXOM_CONFIG_FILE} && -r $ENV{BLOSXOM_CONFIG_FILE}) { + $blosxom_config = $ENV{BLOSXOM_CONFIG_FILE}; + ($config_dir = $blosxom_config) =~ s! / [^/]* $ !!x; +} +else { + for my $blosxom_config_dir ($ENV{BLOSXOM_CONFIG_DIR}, '/etc/blosxom', '/etc') { + if (-r "$blosxom_config_dir/blosxom.conf") { + $config_dir = $blosxom_config_dir; + $blosxom_config = "$blosxom_config_dir/blosxom.conf"; + last; + } + } +} +# Load $blosxom_config +if ($blosxom_config) { + if (-r $blosxom_config) { + eval { require $blosxom_config } or + warn "Error reading blosxom config file '$blosxom_config'" . ($@ ? ": $@" : ''); + } + else { + warn "Cannot find or read blosxom config file '$blosxom_config'"; + } +} + my $fh = new FileHandle; %month2num = (nil=>'00', Jan=>'01', Feb=>'02', Mar=>'03', Apr=>'04', May=>'05', Jun=>'06', Jul=>'07', Aug=>'08', Sep=>'09', Oct=>'10', Nov=>'11', Dec=>'12');