common: prepare path request in global variable
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 30 Mar 2017 12:31:02 +0000 (14:31 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 24 Apr 2017 18:25:53 +0000 (20:25 +0200)
chars.plp
charset.plp
common.inc.plp
digraphs.plp
font.plp
sc.plp
source.plp
termcol.plp
unicode.plp

index b25c5e2ccb96aad30abf34c7d08f2252ef19daa3..a175f8d136105b45729a77e3223273686c18ff1c 100644 (file)
--- a/chars.plp
+++ b/chars.plp
@@ -33,8 +33,7 @@ for my $fontid (@fontlist) {
 
 my ($title, $parent) = ('Character overview');
 my $query = eval {
 
 my ($title, $parent) = ('Character overview');
 my $query = eval {
-       for ($ENV{PATH_INFO} || ()) {
-               s{^/}{};
+       for ($Request || ()) {
                return $_ if m{^[0-9 +-]+$};
 
                my ($cat, $name) = split m{/}, $_, 2 or die "invalid query\n";
                return $_ if m{^[0-9 +-]+$};
 
                my ($cat, $name) = split m{/}, $_, 2 or die "invalid query\n";
index 85b652bd89889c6c1586882571aea2ec3308cf16..4c01b78d0b6bb45717d7f7e7e35bce8f55d81bf5 100644 (file)
@@ -97,7 +97,7 @@ my @request = map {
                ();
        }
 } map { defined $ALIAS{$_} ? @{ $ALIAS{$_} } : $_ }
                ();
        }
 } map { defined $ALIAS{$_} ? @{ $ALIAS{$_} } : $_ }
-       $ENV{PATH_INFO} =~ /\w/ ? split(m{[/+\s]}, $ENV{PATH_INFO}) : 'default';
+       $Request =~ /\w/ ? split(m{[/+\s]}, $Request) : 'default';
 my $NOCHAR = chr 0xFFFD;
 
 for my $cp437 (grep {$request[$_]->{set} eq 'cp437'} 0 .. $#request) {
 my $NOCHAR = chr 0xFFFD;
 
 for my $cp437 (grep {$request[$_]->{set} eq 'cp437'} 0 .. $#request) {
index 3075e7b5a489b624c6a5555f8630eb2dd7da354a..0a010d24170790cb592b18782c4787144129313f 100644 (file)
@@ -20,6 +20,11 @@ BEGIN {
        our $Time = [Time::HiRes::gettimeofday];
 }
 
        our $Time = [Time::HiRes::gettimeofday];
 }
 
+# user request
+our $Dev = $ENV{HTTP_HOST} =~ /\bdev\./;
+our ($file) = $ENV{SCRIPT_FILENAME} =~ m{ ([^/]+) \.plp$ }x;
+our $Request = $ENV{PATH_INFO} =~ s{^/}{}r;
+
 our $style;
 our $showkeys = !exists $get{keys} ? undef :
        ($get{keys} ne '0' && ($get{keys} || 'always'));
 our $style;
 our $showkeys = !exists $get{keys} ? undef :
        ($get{keys} ne '0' && ($get{keys} || 'always'));
@@ -99,10 +104,6 @@ sub Html {
                '<script type="text/javascript" src="/keys.js?1.6"></script>',
        ) if $meta->{keys};
 
                '<script type="text/javascript" src="/keys.js?1.6"></script>',
        ) if $meta->{keys};
 
-       # other vars
-       my $Dev = $ENV{HTTP_HOST} =~ /\bdev\./;
-       my ($file) = $ENV{SCRIPT_FILENAME} =~ m{ ([^/]+) \.plp$ }x;
-
        # leading output
        $header{content_type} = "text/html; charset=$meta->{charset}";
        say '<!DOCTYPE html>';
        # leading output
        $header{content_type} = "text/html; charset=$meta->{charset}";
        say '<!DOCTYPE html>';
index 950c1b252ea8416a4f8aa1b4b15209e13a7f913e..44f93e67c719c7e06d69f5eecf25dfd7f0bf7f26 100644 (file)
@@ -1,6 +1,6 @@
 <(common.inc.plp)><:
 
 <(common.inc.plp)><:
 
-my $mode = ($ENV{PATH_INFO} // '') eq '/xorg' || exists $get{xorg};
+my $mode = ($Request // '') eq 'xorg' || exists $get{xorg};
 my $modename = $mode ? 'X.Org' : 'RFC-1345';
 
 Html({
 my $modename = $mode ? 'X.Org' : 'RFC-1345';
 
 Html({
index 82aa0c39dd0411c700c49bc95b059bc64d4c297c..cc07c0528344b810a6e1ecc44bf8e7e545f9dd83 100644 (file)
--- a/font.plp
+++ b/font.plp
@@ -1,6 +1,6 @@
 <(common.inc.plp)><:
 
 <(common.inc.plp)><:
 
-my $font = $ENV{PATH_INFO} =~ s{^/}{}r;
+my $font = $Request;
 
 Html({
        title => 'font coverage '.($font ? "for $font" : 'sheet'),
 
 Html({
        title => 'font coverage '.($font ? "for $font" : 'sheet'),
diff --git a/sc.plp b/sc.plp
index edbc4c610f27a6674bc922157205ee924883a544..b5d81ecd47684c90a7bdd64932ebd355e6e4fef9 100644 (file)
--- a/sc.plp
+++ b/sc.plp
@@ -9,7 +9,7 @@ my %scver = (
        major => 1,
 );
 
        major => 1,
 );
 
-if ($ENV{PATH_INFO} and $ENV{PATH_INFO} eq '/2') {
+if ($Request and $Request eq '2') {
        %scver = (
                id => 'hots',
                name => 'Heart of the Swarm',
        %scver = (
                id => 'hots',
                name => 'Heart of the Swarm',
index 097f0ac3f310b103b97cdd68a00fd0dfa5cef2b2..38af1faa1bcd21245b287831c060c22252136b71 100644 (file)
@@ -1,7 +1,6 @@
 <(common.inc.plp)><:
 
 <(common.inc.plp)><:
 
-my $source = $ENV{PATH_INFO};
-$source =~ s{^/}{};
+my $source = $Request;
 
 if ($source =~ s{(?<=\Q.inc.pl\E)/jsonp?$}{} and -r $source) {
        # convert perl include to json construct
 
 if ($source =~ s{(?<=\Q.inc.pl\E)/jsonp?$}{} and -r $source) {
        # convert perl include to json construct
index ddf6eb4f5d5b40b5c644f6e01a645528095a6343..3aece81cf64f052ba6fa37283e854d34788e2891 100644 (file)
@@ -18,7 +18,7 @@ my @draw = map { [$_, s/\W+\z//] } grep { $_ } split m(/),
        $get{img} // exists $get{img} && 'indi.png';
 
 my @termlist;
        $get{img} // exists $get{img} && 'indi.png';
 
 my @termlist;
-push @termlist, split /\W+/, $ENV{PATH_INFO} || 'default';
+push @termlist, split /\W+/, $Request || 'default';
 
 :>
 <h1>Terminal colours</h1>
 
 :>
 <h1>Terminal colours</h1>
index 4d28dbdfc329be08ebe579bdb4303221a111dd7d..0ec6374da5a9474b24f714ad1a8ab90b05fa60fa 100644 (file)
@@ -123,7 +123,7 @@ splice @config, 4, 2, qw(
                        ?easteuro
 ) if exists $get{html};
 
                        ?easteuro
 ) if exists $get{html};
 
-$_ and m{/*+(.+)} and @config = split /[ ]/, $1 for $ENV{PATH_INFO}, $get{q};
+$_ and m{/*+(.+)} and @config = split /[ ]/, $1 for $Request, $get{q};
 
 my $tables = do 'unicode-table.inc.pl' or die $@ || $!;
 
 
 my $tables = do 'unicode-table.inc.pl' or die $@ || $!;