X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=lib%2FPackages%2FCGI.pm;h=34d7a5f341636414d0175e089561fd241c9c5823;hb=0d889974c877abc74f68cf5b6a5173dae9b55d7c;hp=9a8584fe6bd51b4cf784ad1dc37d522215ab4e33;hpb=2ec757bb58907b15c43548be5601d4f2b8c7caac;p=deb%2Fpackages.git diff --git a/lib/Packages/CGI.pm b/lib/Packages/CGI.pm index 9a8584f..34d7a5f 100644 --- a/lib/Packages/CGI.pm +++ b/lib/Packages/CGI.pm @@ -7,15 +7,25 @@ use Exporter; use Packages::Config; our @ISA = qw( Exporter ); -our @EXPORT = qw( DEBUG debug fatal_error ); +our @EXPORT = qw( DEBUG debug fatal_error get_mime ); our @EXPORT_OK = qw( error hint msg note get_all_messages make_url make_search_url ); - # define this to 0 in production mode use constant DEBUG => 1; our $debug = 0; +my %mime_types = ( + txt => 'text/plain', + 'txt.gz' => 'text/plain', + html => 'text/html', + rss => 'application/rss+xml', + ); + +sub get_mime { + return $mime_types{$_[0]} || $_[1] || 'text/html'; +} + our (@fatal_errors, @errors, @debug, @msgs, @hints, @notes); sub reset { @@ -333,6 +343,13 @@ sub printindexline { # return ( $start, $end ); #} +sub string2id { + my $string = "@_"; + + $string =~ s/[^\w]/_/g; + return $string; +} + our ( %url_params, %query_params ); sub init_url {