From 549347a660f4e563955a0a630dbfccf1caf96c14 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Sat, 11 Nov 2006 00:51:47 -0800 Subject: [PATCH] * Support setting the common values from text in /etc/debbugs/config * Allow globals which have been set to influence set_default --- Debbugs/Config.pm | 90 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 78 insertions(+), 12 deletions(-) diff --git a/Debbugs/Config.pm b/Debbugs/Config.pm index 7cdbb30..fe845f5 100644 --- a/Debbugs/Config.pm +++ b/Debbugs/Config.pm @@ -52,10 +52,12 @@ BEGIN { qw(%gSeverityDisplay @gTags @gSeverityList @gStrongSeverities), qw(%gSearchEstraier), ], + text => [qw($gBadEmailPrefix $gHTMLTail $gHTMLExpireNote), + ], config => [qw(%config)], ); @EXPORT_OK = (); - Exporter::export_ok_tags(qw(globals config)); + Exporter::export_ok_tags(qw(globals text config)); $EXPORT_TAGS{all} = [@EXPORT_OK]; } @@ -298,6 +300,62 @@ set_default(\%config,'package_source',$config{config_dir}.'/indices/sources'); set_default(\%config,'version_packages_dir',$config{spool_dir}.'/../versions/pkg'); #set_default(\%config,'version_packages_dir',$config{spool_dir}'/../versions/pkg'); +=head2 Text Fields + +The following are the only text fields in general use in the scripts; +a few additional text fields are defined in text.in, but are only used +in db2html and a few other specialty scripts. + +Earlier versions of debbugs defined these values in /etc/debbugs/text, +but now they are required to be in the configuration file. [Eventually +the longer ones will move out into a fully fledged template system.] + +=cut + +=over + +=item bad_email_prefix + +This prefixes the text of all lines in a bad e-mail message ack. + +=cut + +set_default(\%config,'bad_email_prefix',''); + +=item html_tail + +This shows up at the end of (most) html pages + +=cut + +set_default(\%config,'html_tail',<$config{maintainer} <$config{maintainer_email}>. + Last modified: + + SUBSTITUTE_DTIME + +

+ Debian $config{bug} tracking system
+ Copyright (C) 1999 Darren O. Benham, + 1997,2003 nCipher Corporation Ltd, + 1994-97 Ian Jackson. + +END + + +=item html_expire_note + +This message explains what happens to archive/remove-able bugs + +=cut + +set_default(\%config,'html_expire_note', + "(Closed $config{bugs} are archived $config{remove_age} days after the last related message is received.)"); + +=back + +=cut + sub read_config{ my ($conf_file) = @_; @@ -359,6 +417,7 @@ sub __convert_name{ $hash_name =~ s/^([\$\%\@])g//; my $glob_type = $1; my $glob_name = 'g'.$hash_name; + $hash_name =~ s/(HTML|CGI)/ucfirst(lc($1))/ge; $hash_name =~ s/^([A-Z]+)/lc($1)/e; $hash_name =~ s/([A-Z]+)/'_'.lc($1)/ge; return $hash_name unless wantarray; @@ -373,20 +432,26 @@ sub __convert_name{ sub set_default{ my ($config,$option,$value) = @_; + my $varname; + if ($USING_GLOBALS) { + # fix up the variable name + $varname = 'g'.join('',map {ucfirst $_} split /_/, $option); + # Fix stupid HTML names + $varname =~ s/(Html|Cgi)/uc($1)/ge; + } # update the configuration value if (not $USING_GLOBALS and not exists $config{$option}) { $config{$option} = $value; } - else { + elsif ($USING_GLOBALS) {{ + no strict 'refs'; # Need to check if a value has already been set in a global - } + if (defined *{"Debbugs::Config::${varname}"}) { + $config{$option} = *{"Debbugs::Config::${varname}"}; + } + }} if ($USING_GLOBALS) {{ - # fix up the variable name - my $varname = 'g'.join('',map {ucfirst $_} $option); - # Fix stupid HTML names - $varname =~ s/Html/HTML/; no strict 'refs'; - my $ref = ref $config{$option} || 'SCALAR'; *{"Debbugs::Config::${varname}"} = $config{$option}; }} } @@ -394,13 +459,14 @@ sub set_default{ ### import magick -# All we care about here is whether we've been called with the globals option; -# if so, then we need to export some symbols back up; otherwise we call exporter. +# All we care about here is whether we've been called with the globals or text option; +# if so, then we need to export some symbols back up. +# In any event, we call exporter. sub import { - if (grep $_ eq ':globals', @_) { + if (grep /^:(?:text|globals)$/, @_) { $USING_GLOBALS=1; - for my $variable (@{$EXPORT_TAGS{globals}}) { + for my $variable (map {@$_} @EXPORT_TAGS{map{(/^:(text|globals)$/?($1):())} @_}) { my $tmp = $variable; no strict 'refs'; # Yes, I don't care if these are only used once -- 2.39.2