summaryrefslogtreecommitdiff
path: root/Xerl
diff options
context:
space:
mode:
authorPaul Buetow (pluto.buetow.org) <paul@buetow.org>2013-09-28 13:31:48 +0200
committerPaul Buetow (pluto.buetow.org) <paul@buetow.org>2013-09-28 13:31:48 +0200
commit6460ff71ae10f85d7dc12fae40d4c7f05ea41db7 (patch)
tree814b82eafe1fba8e856d2103023873d64e1fd653 /Xerl
parent82530a1cfefe05e63dd7ff80704dd9ccc4a6bb4c (diff)
not in branch hosts
Diffstat (limited to 'Xerl')
-rw-r--r--Xerl/Base.pm135
-rw-r--r--Xerl/Main/Global.pm96
-rw-r--r--Xerl/Page/Configure.pm171
-rw-r--r--Xerl/Page/Content.pm225
-rw-r--r--Xerl/Page/Document.pm75
-rw-r--r--Xerl/Page/Menu.pm131
-rw-r--r--Xerl/Page/Parameter.pm70
-rw-r--r--Xerl/Page/Request.pm70
-rw-r--r--Xerl/Page/Rules.pm95
-rw-r--r--Xerl/Page/Templates.pm241
-rw-r--r--Xerl/Tools/FileIO.pm188
-rw-r--r--Xerl/XML/Element.pm111
-rw-r--r--Xerl/XML/Reader.pm163
13 files changed, 0 insertions, 1771 deletions
diff --git a/Xerl/Base.pm b/Xerl/Base.pm
deleted file mode 100644
index 589e325..0000000
--- a/Xerl/Base.pm
+++ /dev/null
@@ -1,135 +0,0 @@
-# Xerl (c) 2005-2011,2013 Dipl.-Inform. (FH) Paul C. Buetow
-#
-# E-Mail: xerl@dev.buetow.org WWW: http://xerl.buetow.org
-#
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# * Neither the name of buetow.org nor the names of its contributors may
-# be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED Paul C. Buetow ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT Paul C. Buetow BE LIABLE FOR ANY DIRECT,
-# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-package UNIVERSAL;
-
-use strict;
-use warnings;
-
-sub new ($;) {
- my $self = shift;
-
- bless {@_} => $self;
-}
-
-sub setval($$$) {
- my UNIVERSAL $self = $_[0];
-
- $self->{ $_[1] } = $_[2];
-
- return undef;
-}
-
-sub getval($$) {
- my UNIVERSAL $self = $_[0];
-
- return defined $self->{ $_[1] } ? $self->{ $_[1] } : '';
-}
-
-sub exists($$) {
- my UNIVERSAL $self = $_[0];
-
- return exists $self->{ $_[1] } ? 1 : 0;
-}
-
-sub AUTOLOAD {
- my UNIVERSAL $self = $_[0];
- my $auto = our $AUTOLOAD;
- return $self if $auto =~ /DESTROY/;
-
- if ( $auto =~ /.*::set_(.+)$/ ) {
- $self->{$1} = $_[1];
-
- }
- elsif ( $auto =~ /.*::get_(.+)_ref$/ ) {
- return defined $self->{$1} ? \$self->{$1} : [''];
-
- }
- elsif ( $auto =~ /.*::get_(.+)$/ ) {
- return defined $self->{$1} ? $self->{$1} : '';
-
- }
- elsif ( $auto =~ /.*::undef_(.+)$/ ) {
- return '' unless defined $self->{$1};
-
- my $retval = $self->{$1};
- undef $self->{$1};
- return $retval;
-
- }
- elsif ( $auto =~ /.*::append_(.+)$/ ) {
- if ( defined $self->{$1} ) {
- $self->{$1} .= $_[1];
-
- }
- else {
- $self->{$1} = $_[1];
- }
-
- }
- elsif ( $auto =~ /.*::push_(.+)$/ ) {
- if ( exists $self->{$1} ) {
- push @{ $self->{$1} }, $_[1];
-
- }
- else {
- $self->{$1} = [ $_[1] ];
- }
-
- }
- elsif ( $auto =~ /.*::first_(.+)$/ ) {
- return exists $self->{$1} ? ${ $self->{$1} }[0] : '';
-
- }
- elsif ( $auto =~ /.*::(.+)_exists$/ ) {
- return exists $self->{$1} ? 1 : 0;
-
- }
- elsif ( $auto =~ /.*::(.+)_length$/ ) {
- return ( ref $self->{$1} eq 'ARRAY' ) ? scalar @{ $self->{$1} } : 0;
-
- }
- elsif ( $auto =~ /.*::(.+)_isset$/ ) {
- return exists $self->{$1} ? $self->{ $_[0] } : 0;
-
- }
- elsif ( $auto =~ /.*::debug$/ ) {
- print "DEBUG: @_\n";
- return undef;
-
- }
- else {
- print "$auto is not a method of $self or UNIVERSAL\n";
- }
-
- return $self;
-}
-
-1;
-
diff --git a/Xerl/Main/Global.pm b/Xerl/Main/Global.pm
deleted file mode 100644
index f70ef6d..0000000
--- a/Xerl/Main/Global.pm
+++ /dev/null
@@ -1,96 +0,0 @@
-# Xerl (c) 2005-2011,2013 Dipl.-Inform. (FH) Paul C. Buetow
-#
-# E-Mail: xerl@dev.buetow.org WWW: http://xerl.buetow.org
-#
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# * Neither the name of buetow.org nor the names of its contributors may
-# be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED Paul C. Buetow ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT Paul C. Buetow BE LIABLE FOR ANY DIRECT,
-# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-package Xerl::Main::Global;
-
-sub SHUTDOWN {
- exit 0;
-
- # Never reach this point
- return undef;
-}
-
-sub DEBUG {
- print 'Debug::', @_, "\n";
-
- return undef;
-}
-
-sub ERROR {
- print "Content-Type: text/plain\n\nXerl runtime error: ",
- join( ' ', time, @_ );
-
- Xerl::Main::Global::SHUTDOWN();
-
- # Never reach this point
- return undef;
-}
-
-sub PLAIN {
- print "Content-Type: text/plain\n\n";
-
- DEBUG(@_) if @_;
-
- return undef;
-}
-
-sub REDIRECT ($) {
- my $location = shift;
- print "Status: 301 Moved Permanantly\n";
- print "Location: $location\n\n";
- return undef;
-}
-
-sub _HTTP_DESCR ($;$) {
- my ( $status, $infomsg ) = @_;
-
- $infomsg //= '';
-
- if ( $status == 404 ) {
- "Status: 404 Not Found $infomsg\015\012\n\n"
-
- }
- else {
- "Status: 405 Method not allowed $infomsg\015\012\n\n";
- }
-}
-
-sub HTTP {
- my $descr = _HTTP_DESCR(shift);
- print $descr;
- local $, = ' ';
- print $descr;
-
- Xerl::Main::Global::SHUTDOWN();
-
- # Never reach this point
- return undef;
-}
-
-1;
diff --git a/Xerl/Page/Configure.pm b/Xerl/Page/Configure.pm
deleted file mode 100644
index 1a9ecde..0000000
--- a/Xerl/Page/Configure.pm
+++ /dev/null
@@ -1,171 +0,0 @@
-# Xerl (c) 2005-2011,2013 Dipl.-Inform. (FH) Paul C. Buetow
-#
-# E-Mail: xerl@dev.buetow.org WWW: http://xerl.buetow.org
-#
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# * Neither the name of buetow.org nor the names of its contributors may
-# be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED Paul C. Buetow ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT Paul C. Buetow BE LIABLE FOR ANY DIRECT,
-# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-package Xerl::Page::Configure;
-
-use strict;
-use warnings;
-
-use Xerl::Base;
-use Xerl::Tools::FileIO;
-use Xerl::XML::Element;
-
-sub parse($) {
- my Xerl::Page::Configure $self = $_[0];
-
- my Xerl::Tools::FileIO $file =
- Xerl::Tools::FileIO->new( 'path' => $self->get_config() );
-
- if ( -1 == $file->fslurp() ) {
- $self->set_finish_request(1);
- return undef;
- }
-
- my $re = qr/^(.+?) *=(.+?) *\n?$/;
-
- for ( @{ $file->get_array() } ) {
- next if /^ *#/;
-
- $self->setval( $1, $self->eval($2) ) if $_ =~ $re;
- }
-
- return $self;
-}
-
-sub defaults($) {
- my Xerl::Page::Configure $self = $_[0];
-
- $self->set_proto('https') if exists $ENV{HTTPS};
-
- $self->set_site( $self->get_defaultcontent() )
- unless $self->site_exists();
-
- $self->set_nsite( $self->get_site() =~ /^(?:\d*\.)?(.*)/ );
-
- $self->set_template( $self->get_defaulttemplate() )
- unless $self->template_exists();
-
- $self->set_style( $self->get_defaultstyle() )
- unless $self->style_exists();
-
- $self->set_proto( $self->get_defaultproto() )
- unless $self->proto_exists();
-
- $self->set_host( lc $ENV{HTTP_HOST} )
- unless $self->host_exists();
-
- unless ( -d $self->get_hostroot() . $self->get_host() ) {
- my $redirect = $self->get_hostroot() . 'redirect:' . $self->get_host();
- if ( -f $redirect ) {
- my Xerl::Tools::FileIO $file =
- Xerl::Tools::FileIO->new( 'path' => $redirect );
- $file->fslurp();
- my $location = $file->shift();
- Xerl::Main::Global::REDIRECT($location);
- $self->set_finish_request(1);
- }
- my $alias = $self->get_hostroot() . 'alias:' . $self->get_host();
- if ( -f $alias ) {
- my Xerl::Tools::FileIO $file =
- Xerl::Tools::FileIO->new( 'path' => $alias );
- $file->fslurp();
- $self->set_host( $file->shift() );
- }
- }
-
- $self->set_outputformat( $self->get_defaultoutputformat() )
- unless $self->outputformat_exists();
-
- if ( $self->format_exists() ) {
- $self->set_outputformat( $self->get_format() );
- $self->set_template( $self->get_format() );
- $self->set_site( $self->get_format() );
- $self->set_nocache(1)
- if $self->get_format() =~ /\.feed$/;
- }
-
- $self->set_host( $self->getval( $self->get_host() ) )
- if $self->exists( $self->get_host() );
-
- $self->set_host( $self->getval( $self->get_host() ) )
- if $self->exists( $self->get_host() );
-
- my $request_subdir = $self->get_request_subdir();
- $self->set_hostpath(
- $self->get_hostroot() . $self->get_host() . $request_subdir . "/" );
-
- $self->set_defaulthostpath(
- $self->get_hostroot() . $self->get_defaulthost() . '/' );
-
- $self->set_cachepath(
- $self->get_cacheroot() . $self->get_host() . $request_subdir . '/' );
-
- $self->set_htdocspath( $self->get_hostpath() . 'htdocs/' );
-
- $self->set_templatespath( $self->get_hostpath() . 'templates/' );
-
- $self->set_contentpath( $self->get_hostpath() . 'content/' );
-
- # $self->set_ipv6( $ENV{REMOTE_ADDR} =~ /:/ ? 1 : 0 );
-
- return undef;
-}
-
-sub eval($$) {
- my Xerl::Page::Configure $self = $_[0];
- my $val = $_[1];
-
- $val =~ s/^!(.+)/`$1`/eo;
- return $val;
-}
-
-sub insertxmlvars($$) {
- my Xerl::Page::Configure $self = $_[0];
- my Xerl::XML::Element $element = $_[1];
-
- $element = $element->starttag('variables');
-
- return $self
- unless defined $element
- or $element->get_array() eq 'ARRAY';
-
- my $text;
- for ( @{ $element->get_array() } ) {
- $text = $_->get_text();
- chomp $text;
-
- $text =~ s/%%(.*?)%%/$self->getval($1)/eg;
- $self->setval( $_->get_name(), $text );
- }
-
- return $self;
-}
-
-1;
-
diff --git a/Xerl/Page/Content.pm b/Xerl/Page/Content.pm
deleted file mode 100644
index d9d7d34..0000000
--- a/Xerl/Page/Content.pm
+++ /dev/null
@@ -1,225 +0,0 @@
-# Xerl (c) 2005-2011,2013 Dipl.-Inform. (FH) Paul C. Buetow
-#
-# E-Mail: xerl@dev.buetow.org WWW: http://xerl.buetow.org
-#
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# * Neither the name of buetow.org nor the names of its contributors may
-# be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED Paul C. Buetow ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT Paul C. Buetow BE LIABLE FOR ANY DIRECT,
-# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-package Xerl::Page::Content;
-
-use strict;
-use warnings;
-
-use Xerl::Base;
-
-use Xerl::XML::Reader;
-use Xerl::XML::Element;
-use Xerl::Page::Rules;
-use Xerl::Page::Configure;
-
-sub parse($) {
- my Xerl::Page::Content $self = $_[0];
- my Xerl::Page::Configure $config = $self->get_config();
-
- my Xerl::XML::Reader $xmlcontent = Xerl::XML::Reader->new(
- path => $config->get_templatepath(),
- config => $config
- );
-
- if ( -1 == $xmlcontent->open() ) {
- $config->set_finish_request(1);
- return undef;
- }
-
- $xmlcontent->parse();
-
- my Xerl::Page::Rules $rules = Xerl::Page::Rules->new( config => $config );
- $rules->parse( $config->get_xmlconfigrootobj() )
- unless $config->exists('noparse');
-
- $config->insertxmlvars( $config->get_xmlconfigrootobj() );
- $self->insertrules( $rules, $xmlcontent->get_root() );
-
- return undef;
-}
-
-sub insertrules($$$$) {
- my Xerl::Page::Content $self = $_[0];
- my Xerl::Page::Rules $rules = $_[1];
- my Xerl::XML::Element $element = $_[2];
-
- # Start inserting rules at <content>
- $element = $element->starttag('content');
-
- # If there is no <content>-tag, dont use a rule!
- return unless defined $element;
-
- my @content;
- my $params = $element->get_params();
-
- unshift @content, "Content-Type: $params->{type}\n\n"
- if ref $params eq 'HASH' and exists $params->{type};
-
- push @content, $self->_insertrules( $rules, $element );
- $self->set_content( \@content );
-
- return undef;
-}
-
-sub _insertrules($$$) {
- my Xerl::Page::Content $self = $_[0];
- my Xerl::Page::Rules $rules = $_[1];
- my Xerl::XML::Element $element = $_[2];
- my Xerl::Page::Configure $config = $self->get_config();
- my $nonewlines = 0;
-
- #$element->print();
- #
- # Don't interate through the XML childs if we have a leaf node.
- return () unless ref $element->get_array() eq 'ARRAY';
- my ( $name, $rule, @content, $text, $params );
-
- for my $succ ( @{ $element->get_array() } ) {
- $name = $succ->get_name();
- $text = $succ->get_text();
- $params = $succ->get_params();
-
- # Remove leading and ending whitespaces, also ending newlines.
- $text =~ s/^ *(.*)( |\n)*$/$1/g;
- unless ( ref( $rule = $rules->getval($name) ) eq 'ARRAY' ) {
- if ( lc $name eq 'noop' ) {
- if ( ref $succ->get_array() eq 'ARRAY' ) {
- push @content, $self->_insertrules( $rules, $succ );
-
- }
- else {
- push @content, "$text\n";
- }
-
- }
- elsif ( lc $name eq 'tag' ) {
- push @content, "<$text>\n";
-
- }
- elsif ( lc $name eq 'perl' ) {
-
- # Perl content will be interpreted by Xerl::Page::Templates::print later
- push @content, '<perl>', $text, '</perl>';
-
- }
- elsif ( lc $name eq 'navigation' ) {
- my $menus = $config->get_menuobj()->get_array();
-
- if ( ref $menus eq 'ARRAY' ) {
- push @content, $self->_insertrules( $rules, $_ ) for @$menus;
- }
-
- }
- else {
-
- # No rule available, use the tag unmodified!
- $name =~ s/^=//o; # Remove the leading =
- if ( $succ->get_single() ) {
- push @content, "<$name" . ( $succ->params_str() || '' ) . " />\n"
-
- }
- else {
- push @content,
- "<$name" . ( $succ->params_str() || '' ) . '>',
- $self->_insertrules( $rules, $succ ), $text, "</$name>\n";
- }
- }
-
- }
- else {
-
- # Get a local copy of lrule, because orule may be modified.
- # And then insert special vars if required:
- # @@text@@ => Text content of the current tag.
-
- my $ruleparams = $rule->[2];
- $nonewlines = 1 if exists $ruleparams->{nonewlines};
-
- my ( $orule, $crule ) = ( $rule->[0], $rule->[1] );
-
- $self->_insert_special_vars( $rules, $succ, \$orule );
- $self->_insert_special_vars( $rules, $succ, \$crule );
- chomp $orule;
-
- # Parse for known tag params.
- if ( ref $params eq 'HASH' ) {
- Xerl::Page::Templates::PARSELINE( $config, '%%', \$text );
-
- # <tag basename='yes'>path/to/file.bla</tag> => <tag>file.bla</tag>
- $text =~ s#.*/(.*)$#$1# if lc $params->{basename} eq 'yes';
-
- # <tag cut='?'>foo.bar.tld?options</tag> => <tag>?options</tag>
- if ( exists $params->{cut} ) {
- my $cut = quotemeta $params->{cut};
- $text =~ s/.*$cut(.*)$/$1/o;
- }
-
- $text .= $params->{addback}
- if exists $params->{addback};
- $text = $params->{addfront} . $text
- if exists $params->{addfront};
- }
-
- my $oadd =
- exists $ruleparams->{addfront}
- ? '<' . $ruleparams->{addfront}
- : '';
-
- my $cadd =
- exists $ruleparams->{addback} ? $ruleparams->{addback} . '>' : '';
-
- push @content, $orule, $oadd, $self->_insertrules( $rules, $succ ),
- $text, $cadd, $crule;
- }
- }
-
- return $nonewlines ? map { s/\n/ /go; $_ } @content : @content;
-}
-
-sub _insert_special_vars($$$$) {
- my Xerl::Page::Content $self = $_[0];
- my Xerl::Page::Rules $rules = $_[1];
- my Xerl::XML::Element $element = $_[2];
- my Xerl::Page::Configure $config = $self->get_config();
- my $rtext = $_[3];
-
- $$rtext =~ s/@\@text\@\@/$_=$element->get_text();chomp;$_/geo;
- $$rtext =~ s/@\@ln\@\@//go;
-
- if ( $$rtext =~ /@\@(.*?)\@\@/ ) {
- my $params = $element->get_params();
- return unless ref $params eq 'HASH';
- $$rtext =~ s/@\@(.*?)\@\@/$params->{$1}||''/geo;
- }
-
- return undef;
-}
-
-1;
diff --git a/Xerl/Page/Document.pm b/Xerl/Page/Document.pm
deleted file mode 100644
index afc4da3..0000000
--- a/Xerl/Page/Document.pm
+++ /dev/null
@@ -1,75 +0,0 @@
-# Xerl (c) 2005-2011,2013 Dipl.-Inform. (FH) Paul C. Buetow
-#
-# E-Mail: xerl@dev.buetow.org WWW: http://xerl.buetow.org
-#
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# * Neither the name of buetow.org nor the names of its contributors may
-# be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED Paul C. Buetow ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT Paul C. Buetow BE LIABLE FOR ANY DIRECT,
-# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-package Xerl::Page::Document;
-
-use strict;
-use warnings;
-
-use Xerl::Base;
-use Xerl::Main::Global;
-use Xerl::Page::Configure;
-use Xerl::Tools::FileIO;
-
-sub parse($) {
- my Xerl::Page::Document $self = $_[0];
- my Xerl::Page::Configure $config = $self->get_config();
-
- return undef unless $config->document_exists();
-
- my $document = $config->get_document();
- my ($filename) = $document =~ m#([^/]+)$#;
- my ($postfix) = $document =~ /\.(.+)$/;
- my $path;
-
- print 'Content-Type: ';
- print $config->getval( 'ctype.' . lc($postfix) ), "\n";
- print "Content-Disposition: attachment; filename=\"$filename\"\n\n";
-
- $path = $config->get_hostpath() . "/htdocs/$document";
- unless ( -f $path ) {
- $path =
- $config->get_hostroot()
- . $config->get_defaulthost()
- . "/htdocs/$document";
- }
-
- my Xerl::Tools::FileIO $io = Xerl::Tools::FileIO->new( path => $path );
-
- if ( -1 == $io->fslurp() ) {
- $config->set_finish_request(1);
- }
- else {
- $io->print();
- }
-
- return undef;
-}
-
-1;
diff --git a/Xerl/Page/Menu.pm b/Xerl/Page/Menu.pm
deleted file mode 100644
index 3bd158b..0000000
--- a/Xerl/Page/Menu.pm
+++ /dev/null
@@ -1,131 +0,0 @@
-# Xerl (c) 2005-2011,2013 Dipl.-Inform. (FH) Paul C. Buetow
-#
-# E-Mail: xerl@dev.buetow.org WWW: http://xerl.buetow.org
-#
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# * Neither the name of buetow.org nor the names of its contributors may
-# be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED Paul C. Buetow ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT Paul C. Buetow BE LIABLE FOR ANY DIRECT,
-# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-package Xerl::Page::Menu;
-
-use strict;
-use warnings;
-
-use Xerl::Page::Configure;
-use Xerl::Tools::FileIO;
-use Xerl::XML::Element;
-
-sub generate($;$) {
- my Xerl::Page::Menu $self = $_[0];
- my Xerl::Page::Configure $config = $self->get_config();
-
- my @site = split /\//, $config->get_site();
- my @compare = @site;
- my $site = pop @site;
-
- my ( $content, $siteadd ) = ( 'content/', '' );
-
- my Xerl::XML::Element $menuelem =
- $self->get_menu( $content, $siteadd, shift @compare );
-
- $self->push_array($menuelem)
- if $menuelem->first_array()->array_length() > 1;
-
- for my $s (@site) {
- $content .= "$s.sub/";
- $siteadd .= "$s/";
- $menuelem = $self->get_menu( $content, $siteadd, shift @compare );
- $self->push_array($menuelem)
- if $menuelem->first_array()->array_length() > 1;
- }
-
- return undef;
-}
-
-sub get_menu($$$$) {
- my Xerl::Page::Menu $self = $_[0];
- my Xerl::Page::Configure $config = $self->get_config();
- my ( $content, $siteadd, $compare ) = ( @_[ 1 ... 2 ], lc $_[3] );
- my $issubsection = $content =~ m{\.sub/$};
- my $pattern = qr/\.(?:xml)|(?:sub)$/;
-
- my Xerl::Tools::FileIO $io = Xerl::Tools::FileIO->new(
- path => $config->get_hostpath() . $content,
- basename => 1,
- );
-
- unless ( $io->exists() ) {
- Xerl::Main::Global::REDIRECT( $config->get_404() );
- $config->set_finish_request(1);
- }
-
- $io->dslurp();
- my $dir = $io->get_array();
-
- my ( @prec, @dir );
- map {
- if (/^\d+\..+\./) { push @prec, $_ }
- else { push @dir, $_ }
- }
- grep {
- $_ !~ /^home\.xml$/i
- && $_ !~ /\.feed\.xml$/i
- && $_ !~ /\.hide\.xml$/i
- } @$dir;
-
- my Xerl::XML::Element $root = Xerl::XML::Element->new();
- my Xerl::XML::Element $menu = Xerl::XML::Element->new();
-
- $menu->set_name('menu');
-
- for ( $issubsection ? ( @dir, @prec ) : ( 'home.xml', @dir, @prec ) ) {
- my ($site) = /(.*)$pattern/o;
-
- $site =~ s#\.$#/home#o;
- $site =~ s/^\d+\.//;
-
- my $linkname = $site;
- $linkname =~ s/(?:\d+\.)?(.)/\U$1/o;
- $compare .= '/' if $linkname =~ s#(.*/)[^/]+$#$1#;
-
- my Xerl::XML::Element $item = Xerl::XML::Element->new(
- params => { link => "?site=$siteadd$site" },
- text => $linkname
- );
-
- $compare =~ s/^(\d+\.)//;
- $item->set_name(
- lc $linkname eq lc $compare ? 'activemenuitem' : 'menuitem' );
-
- $item->set_prev($menu);
- $menu->push_array($item);
- }
-
- $root->push_array($menu);
- $menu->set_prev($root);
-
- return $root;
-}
-
-1;
diff --git a/Xerl/Page/Parameter.pm b/Xerl/Page/Parameter.pm
deleted file mode 100644
index ba0a6cd..0000000
--- a/Xerl/Page/Parameter.pm
+++ /dev/null
@@ -1,70 +0,0 @@
-# Xerl (c) 2005-2011,2013 Dipl.-Inform. (FH) Paul C. Buetow
-#
-# E-Mail: xerl@dev.buetow.org WWW: http://xerl.buetow.org
-#
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# * Neither the name of buetow.org nor the names of its contributors may
-# be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED Paul C. Buetow ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT Paul C. Buetow BE LIABLE FOR ANY DIRECT,
-# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-package Xerl::Page::Parameter;
-
-use strict;
-use warnings;
-
-use Xerl::Base;
-use Xerl::Main::Global;
-use Xerl::Page::Configure;
-use Xerl::Tools::FileIO;
-
-sub parse($) {
- my Xerl::Page::Parameter $self = $_[0];
- my Xerl::Page::Configure $config = $self->get_config();
-
- print "Content-Type: text/plain\n\n"
- if $config->plain_exists();
-
- if ( $config->href_exists() ) {
- print "Location: ", $config->get_href(), "\n\n";
- $config->set_finish_request(1);
- }
- elsif ( $config->env_exists() ) {
- print "Content-Type: text/plain\n\n";
- print "$_=", $ENV{$_}, "\n" for keys %ENV;
- $config->set_finish_request(1);
- }
-
- if ( $config->devel_exists() ) {
- $config->set_nocache(1);
- }
-
- if ( $config->conf_exists() ) {
- print "Content-Type: text/plain\n\n";
- print "$_=", $config->{$_}, "\n" for keys %$config;
- $config->set_finish_request(1);
- }
-
- return $self;
-}
-
-1;
diff --git a/Xerl/Page/Request.pm b/Xerl/Page/Request.pm
deleted file mode 100644
index 11106ec..0000000
--- a/Xerl/Page/Request.pm
+++ /dev/null
@@ -1,70 +0,0 @@
-# Xerl (c) 2005-2011,2013 Dipl.-Inform. (FH) Paul C. Buetow
-#
-# E-Mail: xerl@dev.buetow.org WWW: http://xerl.buetow.org
-#
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# * Neither the name of buetow.org nor the names of its contributors may
-# be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED Paul C. Buetow ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT Paul C. Buetow BE LIABLE FOR ANY DIRECT,
-# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-package Xerl::Page::Request;
-
-use strict;
-use warnings;
-
-use Xerl::Base;
-
-sub parse($) {
- my Xerl::Page::Request $self = $_[0];
- my $request = $self->get_request();
-
- # Secure it!
- $request =~ s#/\.\.##g;