You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axkit-dev@xml.apache.org by ma...@sergeant.org on 2006/08/02 21:44:39 UTC
[SVN] [29] Clean up the demo tree a lot
Revision: 29
Author: matt
Date: 2006-08-02 19:44:20 +0000 (Wed, 02 Aug 2006)
Log Message:
-----------
Clean up the demo tree a lot
Make sure Config modules don't use a global default array/hash
Stop using HTTP::Date - we only need a simple date sub (put in Utils)
Modified Paths:
--------------
trunk/etc/axkit.conf
trunk/lib/AxKit2/Config/Global.pm
trunk/lib/AxKit2/Config/Location.pm
trunk/lib/AxKit2/Config/Server.pm
trunk/lib/AxKit2/Connection.pm
trunk/lib/AxKit2/Utils.pm
Added Paths:
-----------
trunk/demo/xslt/
trunk/demo/xslt/01.xml
trunk/demo/xslt/02_include.xml
trunk/demo/xslt/03_document_1arg.xml
trunk/demo/xslt/04_document.xml
trunk/demo/xslt/04_document_2args.xml
trunk/demo/xslt/05_params.xml
trunk/demo/xslt/stylesheet.xsl
trunk/demo/xslt/stylesheets/
trunk/plugins/demo/serve_xslt
Removed Paths:
-------------
trunk/plugins/serve_xslt
Added: trunk/demo/xslt/01.xml
===================================================================
--- trunk/demo/xslt/01.xml 2006-08-02 19:24:16 UTC (rev 28)
+++ trunk/demo/xslt/01.xml 2006-08-02 19:44:20 UTC (rev 29)
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<root/>
Added: trunk/demo/xslt/02_include.xml
===================================================================
--- trunk/demo/xslt/02_include.xml 2006-08-02 19:24:16 UTC (rev 28)
+++ trunk/demo/xslt/02_include.xml 2006-08-02 19:44:20 UTC (rev 29)
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<root/>
Added: trunk/demo/xslt/03_document_1arg.xml
===================================================================
--- trunk/demo/xslt/03_document_1arg.xml 2006-08-02 19:24:16 UTC (rev 28)
+++ trunk/demo/xslt/03_document_1arg.xml 2006-08-02 19:44:20 UTC (rev 29)
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<root/>
Added: trunk/demo/xslt/04_document.xml
===================================================================
--- trunk/demo/xslt/04_document.xml 2006-08-02 19:24:16 UTC (rev 28)
+++ trunk/demo/xslt/04_document.xml 2006-08-02 19:44:20 UTC (rev 29)
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<root>
+Included relative to source
+</root>
Added: trunk/demo/xslt/04_document_2args.xml
===================================================================
--- trunk/demo/xslt/04_document_2args.xml 2006-08-02 19:24:16 UTC (rev 28)
+++ trunk/demo/xslt/04_document_2args.xml 2006-08-02 19:44:20 UTC (rev 29)
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<root/>
Added: trunk/demo/xslt/05_params.xml
===================================================================
--- trunk/demo/xslt/05_params.xml 2006-08-02 19:24:16 UTC (rev 28)
+++ trunk/demo/xslt/05_params.xml 2006-08-02 19:44:20 UTC (rev 29)
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<root/>
Added: trunk/demo/xslt/stylesheet.xsl
===================================================================
--- trunk/demo/xslt/stylesheet.xsl 2006-08-02 19:24:16 UTC (rev 28)
+++ trunk/demo/xslt/stylesheet.xsl 2006-08-02 19:44:20 UTC (rev 29)
@@ -0,0 +1,39 @@
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+<xsl:output method="html"/>
+
+<xsl:template match="/">
+ <html>
+ <xsl:apply-templates/>
+ </html>
+</xsl:template>
+
+<xsl:template match="head">
+<head><xsl:apply-templates/></head>
+</xsl:template>
+
+<xsl:template match="head/title">
+<title><xsl:apply-templates/></title>
+</xsl:template>
+
+<xsl:template match="body">
+<body><xsl:apply-templates/></body>
+</xsl:template>
+
+<xsl:template match="section">
+ <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="section/title">
+ <h1><xsl:apply-templates/></h1>
+</xsl:template>
+
+<xsl:template match="para">
+ <p>
+ <xsl:apply-templates/>
+ </p>
+</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
Modified: trunk/etc/axkit.conf
===================================================================
--- trunk/etc/axkit.conf 2006-08-02 19:24:16 UTC (rev 28)
+++ trunk/etc/axkit.conf 2006-08-02 19:44:20 UTC (rev 29)
@@ -14,31 +14,27 @@
DirectoryIndex index.xml
Plugin uri_to_file
- Plugin serve_xslt
Plugin serve_cgi
Plugin serve_file
- XSLT_Match .*\.xml
- XSLT_Style /Users/matt/Perl/xml-axkit/demo/xslt/stylesheet.xsl
+ CGI_Match .*\.(pl|cgi)$
- CGI_Match .*\.pl
-
- <Location /test>
-
+ <Location /xslt>
+ Plugin demo/serve_xslt
DirectoryIndex 01.xml
- DocumentRoot /Users/matt/Perl/xml-axkit/t/htdocs/xslt-basic
- XSLT_Style /Users/matt/Perl/xml-axkit/t/htdocs/style/xslt-basic/01.xsl
-
+ DocumentRoot demo/xslt
+ XSLT_Match .*\.xml$
+ XSLT_Style demo/xslt/stylesheets/01.xsl
</Location>
<Location /xsp>
- DocumentRoot /Users/matt/Perl/AxKit2/trunk/demo
- Plugin serve_xsp
- XSP_Match .*\.xsp
+ DocumentRoot demo/xsp
+ Plugin demo/serve_xsp
+ XSP_Match .*\.xsp$
</Location>
<Location /tal>
- DocumentRoot /Users/matt/Perl/AxKit2/trunk/demo/tal
+ DocumentRoot demo/tal
Plugin demo/serve_tal
</Location>
Modified: trunk/lib/AxKit2/Config/Global.pm
===================================================================
--- trunk/lib/AxKit2/Config/Global.pm 2006-08-02 19:24:16 UTC (rev 28)
+++ trunk/lib/AxKit2/Config/Global.pm 2006-08-02 19:44:20 UTC (rev 29)
@@ -5,14 +5,14 @@
use strict;
use warnings;
-our %defaults = (
- Plugins => [],
- Notes => {},
- );
-
sub new {
my $class = shift;
+ my %defaults = (
+ Plugins => [],
+ Notes => {},
+ );
+
return bless { %defaults, @_ }, $class;
}
Modified: trunk/lib/AxKit2/Config/Location.pm
===================================================================
--- trunk/lib/AxKit2/Config/Location.pm 2006-08-02 19:24:16 UTC (rev 28)
+++ trunk/lib/AxKit2/Config/Location.pm 2006-08-02 19:44:20 UTC (rev 29)
@@ -5,16 +5,16 @@
use strict;
use warnings;
-our %defaults = (
- Plugins => [],
- Notes => {},
- );
-
sub new {
my $class = shift;
my $server = shift;
my $path = shift;
+ my %defaults = (
+ Plugins => [],
+ Notes => {},
+ );
+
my %args = ( __server => $server, __path => $path, %defaults, @_ );
return bless \%args, $class;
Modified: trunk/lib/AxKit2/Config/Server.pm
===================================================================
--- trunk/lib/AxKit2/Config/Server.pm 2006-08-02 19:24:16 UTC (rev 28)
+++ trunk/lib/AxKit2/Config/Server.pm 2006-08-02 19:44:20 UTC (rev 29)
@@ -9,18 +9,18 @@
# this use() is here to show the dependency
use AxKit2::Config::Location;
-our %defaults = (
- Port => 8000,
- Plugins => [],
- Locations => [],
- Notes => {},
- );
-
sub new {
my $class = shift;
my $global = shift;
my $name = shift;
+ my %defaults = (
+ Port => 8000,
+ Plugins => [],
+ Locations => [],
+ Notes => {},
+ );
+
my %args = ( __global => $global, %defaults, @_ );
return bless \%args, $class;
Modified: trunk/lib/AxKit2/Connection.pm
===================================================================
--- trunk/lib/AxKit2/Connection.pm 2006-08-02 19:24:16 UTC (rev 28)
+++ trunk/lib/AxKit2/Connection.pm 2006-08-02 19:44:20 UTC (rev 29)
@@ -7,7 +7,7 @@
use AxKit2::HTTPHeaders;
use AxKit2::Constants;
use AxKit2::Processor;
-use HTTP::Date ();
+use AxKit2::Utils qw(http_date);
use fields qw(
alive_time
@@ -155,7 +155,7 @@
my $conf = $self->{server_config};
$self->{headers_out} = AxKit2::HTTPHeaders->new_response;
- $self->{headers_out}->header(Date => HTTP::Date::time2str());
+ $self->{headers_out}->header(Date => http_date());
$self->{headers_out}->header(Server => "AxKit-2/v$AxKit2::VERSION");
$self->hook_uri_to_file($hd, $hd->request_uri)
Modified: trunk/lib/AxKit2/Utils.pm
===================================================================
--- trunk/lib/AxKit2/Utils.pm 2006-08-02 19:24:16 UTC (rev 28)
+++ trunk/lib/AxKit2/Utils.pm 2006-08-02 19:44:20 UTC (rev 29)
@@ -5,7 +5,8 @@
use Exporter ();
-our @EXPORT_OK = qw(uri_decode);
+our @EXPORT_OK = qw(uri_decode http_date);
+our @ISA = ('Exporter');
sub uri_decode {
my $uri = shift;
@@ -15,4 +16,14 @@
return $uri;
}
+sub http_date {
+ my $time = shift;
+ $time = time unless defined $time;
+ my ($sec, $min, $hour, $mday, $mon, $year, $wday) = gmtime($time);
+ my $day = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat')[$wday];
+ my $month = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')[$mon];
+ return sprintf("%s, %02d %s %04d %02d:%02d:%02d GMT",
+ $day, $mday, $month, $year+1900, $hour, $min, $sec);
+}
+
1;
\ No newline at end of file
Copied: trunk/plugins/demo/serve_xslt (from rev 26, trunk/plugins/serve_xslt)
Deleted: trunk/plugins/serve_xslt
===================================================================
--- trunk/plugins/serve_xslt 2006-08-02 19:24:16 UTC (rev 28)
+++ trunk/plugins/serve_xslt 2006-08-02 19:44:20 UTC (rev 29)
@@ -1,42 +0,0 @@
-#!/usr/bin/perl -w
-
-sub init {
- my $self = shift;
-
- $self->register_config('XSLT_Match', sub { $self->matchfiles(@_) });
- $self->register_config('XSLT_Style', sub { $self->xslt_stylesheet(@_) });
-}
-
-sub xslt_stylesheet {
- my ($self, $conf) = (shift, shift);
-
- my $key = $self->plugin_name . '::stylesheet';
- @_ and $conf->notes($key, shift);
- $conf->notes($key);
-}
-
-sub matchfiles {
- my ($self, $conf) = (shift, shift);
-
- my $key = $self->plugin_name . '::matchfiles';
- @_ and $conf->notes($key, shift);
- $conf->notes($key);
-}
-
-sub hook_xmlresponse {
- my ($self, $input) = @_;
-
- $self->log(LOGDEBUG, "XSLT Transform");
-
- my $match = $self->matchfiles($self->config);
-
- $self->log(LOGDEBUG, "Does ", $self->client->headers_in->filename, " match $match?");
- return DECLINED unless $self->client->headers_in->filename =~ /$match/;
-
-
- my $stylefile = $self->xslt_stylesheet($self->config);
-
- my $out = $input->transform(XSLT($stylefile));
-
- return OK, $out;
-}
\ No newline at end of file