richter     01/03/16 05:48:39

  Modified:    Embperl  Tag: Embperl2c Syntax.pm
               Embperl/Syntax Tag: Embperl2c SSI.pm
               test/html/SSI Tag: Embperl2c ssibasic.htm
  Log:
  Embperl 2 - SSI Syntax
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.4.22  +37 -1     embperl/Embperl/Attic/Syntax.pm
  
  Index: Syntax.pm
  ===================================================================
  RCS file: /home/cvs/embperl/Embperl/Attic/Syntax.pm,v
  retrieving revision 1.1.4.21
  retrieving revision 1.1.4.22
  diff -u -r1.1.4.21 -r1.1.4.22
  --- Syntax.pm 2001/03/07 08:18:29     1.1.4.21
  +++ Syntax.pm 2001/03/16 13:48:38     1.1.4.22
  @@ -10,7 +10,7 @@
   #   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   #   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   #
  -#   $Id: Syntax.pm,v 1.1.4.21 2001/03/07 08:18:29 richter Exp $
  +#   $Id: Syntax.pm,v 1.1.4.22 2001/03/16 13:48:38 richter Exp $
   #
   ###################################################################################
    
  @@ -121,6 +121,33 @@
   
   # ---------------------------------------------------------------------------------
   #
  +#   Adds code that is execute everytime after the compile of a document
  +#       start and end of the execution of a document
  +#
  +# ---------------------------------------------------------------------------------
  +
  +
  +sub AddInitCode
  +
  +    {
  +    my ($self, $compiletimecode, $initcode, $termcode) = @_ ;
  +    
  +    my $root = $self -> {-root} ;
  +    my $ttref ;
  +    foreach my $tagtype ('Document', 'DocumentFraq')
  +        {
  +        die "'$tagtype' unknown" if (!($ttref = $self -> {-root}{$tagtype})) ;
  +        my $pinfo = ($ttref -> {'procinfo'}{$self -> {-procinfotype}} ||= {}) ;
  +        $pinfo -> {'compiletimeperlcode'} .= $compiletimecode if ($compiletimecode) 
;
  +        $pinfo -> {'perlcode'} .= $initcode if ($initcode) ;
  +        $pinfo -> {'perlcodeend'} .= $termcode if ($termcode) ;
  +        } 
  +    }
  +
  +
  +
  +# ---------------------------------------------------------------------------------
  +#
   #   Get root
   #
   # ---------------------------------------------------------------------------------
  @@ -1085,6 +1112,15 @@
   
   =pod
   
  +=head2 sub new
  +
  +=head2 sub AddToRoot
  +
  +=head2 sub AddInitCode
  +
  +=head2 sub GetRoot
  +
  +=head2 sub GetSyntax
   
   
   =over 4
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.5   +45 -8     embperl/Embperl/Syntax/Attic/SSI.pm
  
  Index: SSI.pm
  ===================================================================
  RCS file: /home/cvs/embperl/Embperl/Syntax/Attic/SSI.pm,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- SSI.pm    2001/03/07 20:43:30     1.1.2.4
  +++ SSI.pm    2001/03/16 13:48:39     1.1.2.5
  @@ -10,7 +10,7 @@
   #   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   #   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   #
  -#   $Id: SSI.pm,v 1.1.2.4 2001/03/07 20:43:30 richter Exp $
  +#   $Id: SSI.pm,v 1.1.2.5 2001/03/16 13:48:39 richter Exp $
   #
   ###################################################################################
    
  @@ -24,7 +24,7 @@
   
   
   use strict ;
  -use vars qw{@ISA} ;
  +use vars qw{@ISA $apreq $epreq} ;
   
   @ISA = qw(HTML::Embperl::Syntax::HTML) ;
   
  @@ -67,8 +67,8 @@
       {
       my ($self) = @_ ;
   
  +    $self -> AddInitCode (undef, 'HTML::Embperl::Syntax::SSI::InitSSI();', undef) ;
   
  -
       $self -> AddComment ('#echo', ['var', 'encoding'], undef, undef, { perlcode => 
'_ep_rp(%$x%, $ENV{%&*\'var%}) ;' } ) ;
       $self -> AddComment ('#printenv', undef, undef, undef, { perlcode => 
'_ep_rp(%$x%, join ("\\\\<br\\\\>\n", map { "$_ = $ENV{$_}" } keys %ENV)) ;' } ) ;
       $self -> AddComment ('#config', ['errmsg', 'sizefmt', 'timefmt'], undef, undef, 
 
  @@ -102,6 +102,22 @@
                               { perlcode   => '$ENV{%&*\'var%} = 
HTML::Embperl::Syntax::SSI::InterpretVars (%&\'value%) ;',
                                 removenode => 1 
                                            } ) ;
  +    $self -> AddComment ('#if', ['expr'], undef, undef, 
  +                            { perlcode   => 'if (%&\'expr%) { ',
  +                              removenode => 1 
  +                            } ) ;
  +    $self -> AddComment ('#elif', ['expr'], undef, undef, 
  +                            { perlcode   => '} elsif (%&\'expr%) { ',
  +                              removenode => 1 
  +                            } ) ;
  +    $self -> AddComment ('#else', undef, undef, undef, 
  +                            { perlcode   => '} else {',
  +                              removenode => 1 
  +                            } ) ;
  +    $self -> AddComment ('#endif', undef, undef, undef, 
  +                            { perlcode   => '} ;',
  +                              removenode => 1 
  +                            } ) ;
       }
   
   
  @@ -113,6 +129,27 @@
   
   # ---------------------------------------------------------------------------------
   #
  +#   Init SSI
  +#
  +# ---------------------------------------------------------------------------------
  +
  +sub InitSSI
  +    {
  +    $epreq = shift ;
  +    $apreq = shift ;
  +
  +    my $fn ;
  +
  +    $ENV{DATE_GMT}      = gmtime ;
  +    $ENV{DATE_LOCAL}    = localtime ;
  +    $ENV{DOCUMENT_NAME} = $fn = $epreq -> ReqFilename ; 
  +    $ENV{DOCUMENT_URI}  = $apreq?$apreq -> uri:'' ;
  +    $ENV{LAST_MODIFIED} = format_time('', (stat (find_file($fn, $virt)))[9])
  +    }
  +     
  +
  +# ---------------------------------------------------------------------------------
  +#
   #   Interpolate vars inside string
   #
   # ---------------------------------------------------------------------------------
  @@ -138,7 +175,7 @@
       my ($fn, $virt) = @_;
       my $req;
   
  -    if (!defined (&Apache::request))
  +    if (!defined ($apreq))
           {
           return $fn if ($fn) ;
           die "Cannot use 'virtual' without mod_perl" if ($virt) ;
  @@ -147,17 +184,17 @@
   
       if ($fn) 
           {
  -        my $req = Apache -> request -> lookup_file (InterpretVars ($fn)) ;
  +        my $req = $apreq -> lookup_file (InterpretVars ($fn)) ;
           return $req -> filename ;
           }
       if ($virt) 
           {
  -        my $req = Apache -> request -> lookup_uri (InterpretVars ($fn)) ;
  +        my $req = $apreq -> lookup_uri (InterpretVars ($fn)) ;
           return $req -> filename ;
           }
       else
           {
  -        return Apache -> request -> filename ;
  +        return $epreq -> ReqFilename ;
           }
       }
   
  @@ -276,7 +313,7 @@
           }
   
   
  -    my $r = Apache -> request ;
  +    my $r = $apreq ;
       my $filename = $r->filename;
   
       
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +36 -7     embperl/test/html/SSI/Attic/ssibasic.htm
  
  Index: ssibasic.htm
  ===================================================================
  RCS file: /home/cvs/embperl/test/html/SSI/Attic/ssibasic.htm,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- ssibasic.htm      2001/03/07 20:43:44     1.1.2.1
  +++ ssibasic.htm      2001/03/16 13:48:39     1.1.2.2
  @@ -38,28 +38,57 @@
   <!--#config sizefmt=bytes -->
   
   fsize self: <!--#fsize -->
  -fsize file plain.htm <!--#fsize file="../plain.htm" -->
  -fsize virtual plain.htm <!--#fsize file="../plain.htm" -->
  +fsize file plain.htm <!--#fsize file="ssiinc.htm" -->
  +fsize virtual plain.htm <!--#fsize file="ssiinc.htm" -->
   
   flastmod self: <!--#flastmod -->
  -flastmod file plain.htm <!--#flastmod file="../plain.htm" -->
  -flastmod virtual plain.htm <!--#flastmod file="../plain.htm" -->
  +flastmod file plain.htm <!--#flastmod file="ssiinc.htm" -->
  +flastmod virtual plain.htm <!--#flastmod file="ssiinc.htm" -->
   
   sizefmt=abbrev
   <!--#config sizefmt=abbrev -->
   
   fsize self: <!--#fsize -->
  -fsize file plain.htm <!--#fsize file="../plain.htm" -->
  -fsize virtual plain.htm <!--#fsize file="../plain.htm" -->
  +fsize file plain.htm <!--#fsize file="ssiinc.htm" -->
  +fsize virtual plain.htm <!--#fsize file="ssiinc.htm" -->
   
   --INCLUDE-->
   
  -<!-- #include file="ssibasic.htm" -->
  +<!-- #include file="ssiinc.htm" -->
   
   <--INCLUDE--
   
   printenv:
   <!--#printenv -->
  +
  +if 1
  +<!--#if expr="1" -->
  +1
  +<!--#endif-->
  +
  +if 2
  +<!--#if expr="$EPSSITEST" -->
  +EPSSITEST
  +<!--#else-->
  +NOT EPSSITEST
  +<!--#endif-->
  +
  +if 3
  +<!--#if expr="! $EPSSITEST" -->
  +! EPSSITEST
  +<!--#else-->
  +! NOT EPSSITEST
  +<!--#endif-->
  +
  +if 4
  +<!--#if expr="0" -->
  +0
  +<!--#elif expr="1"-->
  +1
  +<!--#else-->
  +2
  +<!--#endif-->
  +
   
   </body>
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to