
package Embperl::Recipe::EmbperlWeb ;

use Embperl::Recipe::XSLT ;
use Embperl::Recipe::Embperl  ;
use Embperl::Recipe::EmbperlXSLT  ;
use Embperl::Recipe::EmbperlPODXSLT  ;
use Embperl::Constant ;

sub get_recipe

    {
    my ($class, $r, $recipe) = @_ ;

    my $self ;
    my $param  = $r -> component -> param  ;
    my $config = $r -> component -> config  ;
    my ($src)  = $param -> inputfile =~ /^.*\.(.*?)$/ ;
    my ($dest) = $r -> param -> uri =~ /^.*\.(.*?)$/ ;

   

    if ($src eq 'pl')
        {
        $config -> syntax('Perl') ;
        return Embperl::Recipe::Embperl -> get_recipe ($r, $recipe) ;
        }

    if ($src eq 'pod' || $src eq 'pm')
        {
        $config -> escmode(0) ;
        if ($dest eq 'pod')
            {
            $config -> syntax('Text') ;
            return Embperl::Recipe::Embperl -> get_recipe ($r, $recipe) ;
            }

        $config -> syntax('POD') ;
        if ($dest eq 'xml')
            {
            return Embperl::Recipe::Embperl -> get_recipe ($r, $recipe) ;
            }

        $config -> xsltstylesheet('pod.xsl') ;
        #$config -> xsltstylesheet($r -> {root} . $r -> {baseuri} . 'xml/pod.xsl') ;
        $r -> param -> uri =~ /^.*\/(.*)(\..*?)$/ ;
        $param -> xsltparam({page => $r -> thread -> form_hash -> {page} || 0, basename => "'$1'", extension => "'$2'"}) ;
        return Embperl::Recipe::EmbperlXSLT -> get_recipe ($r, $recipe) ;
        }
    
    if ($src eq 'epd')
        {
        $config -> escmode(0) ;
        $config -> options($config -> options | &Embperl::Constant::optKeepSpaces) ;

        if ($dest eq 'pod')
            {
            $config -> syntax('EmbperlBlocks') ;
            return Embperl::Recipe::Embperl -> get_recipe ($r, $recipe) ;
            }


        $config -> xsltstylesheet('pod.xsl') ;
        $r -> param -> uri =~ /^.*\/(.*)(\..*?)$/ ;
        my $fdat = $r -> thread -> form_hash ;
        $fdat->{page} ||= 0 ;
        $fdat->{basename} = "'$1'" ;
        $fdat->{extension} = "'$2'" ;
        return Embperl::Recipe::EmbperlPODXSLT -> get_recipe ($r, $recipe) ;
        }
    
    if ($src eq 'epl' || $src eq 'htm')
        {
        $config -> syntax('Embperl') ;
        return Embperl::Recipe::Embperl -> get_recipe ($r, $recipe) ;
        }

    $config -> syntax('Text') ;
    return Embperl::Recipe::Embperl -> get_recipe ($r, $recipe) ;
    }

1 ;
