Initial checkin of the first PLIF test application.

git-svn-id: svn://10.0.0.236/trunk@107532 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
ian%hixie.ch 2001-11-07 01:42:05 +00:00
parent f4593f1a78
commit 76d8c32a10
11 changed files with 421 additions and 0 deletions

View File

@ -0,0 +1,53 @@
# -*- Mode: perl; tab-width: 4; indent-tabs-mode: nil; -*-
#
# This file is MPL/GPL dual-licensed under the following terms:
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and
# limitations under the License.
#
# The Original Code is PLIF 1.0.
# The Initial Developer of the Original Code is Ian Hickson.
#
# Alternatively, the contents of this file may be used under the terms
# of the GNU General Public License Version 2 or later (the "GPL"), in
# which case the provisions of the GPL are applicable instead of those
# above. If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the MPL, indicate your decision by
# deleting the provisions above and replace them with the notice and
# other provisions required by the GPL. If you do not delete the
# provisions above, a recipient may use your version of this file
# under either the MPL or the GPL.
package DataSource::ConsoleStrings;
use strict;
use vars qw(@ISA);
use PLIF::DataSource;
@ISA = qw(PLIF::DataSource);
1;
sub provides {
my $class = shift;
my($service) = @_;
return ($service eq 'dataSource.strings.default' or $class->SUPER::provides($service));
}
sub getDefaultString {
my $self = shift;
my($app, $protocol, $string) = @_;
if ($protocol ne 'stdout') {
return; # ``we don't do duvets!!!''
}
if ($string eq 'hello') {
return ('COSES', '<text xmlns="http://bugzilla.mozilla.org/coses">Hello <if lvalue="(data.session)" condition="ne" rvalue="">user #<text value="(data.session.userID)"/></if><else>World</else>!<br/></text>');
} else {
return ('COSES', '<text xmlns="http://bugzilla.mozilla.org/coses">Er. <include href="debug.dumpVars"/></text>');
}
}

View File

@ -0,0 +1,53 @@
# -*- Mode: perl; tab-width: 4; indent-tabs-mode: nil; -*-
#
# This file is MPL/GPL dual-licensed under the following terms:
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and
# limitations under the License.
#
# The Original Code is PLIF 1.0.
# The Initial Developer of the Original Code is Ian Hickson.
#
# Alternatively, the contents of this file may be used under the terms
# of the GNU General Public License Version 2 or later (the "GPL"), in
# which case the provisions of the GPL are applicable instead of those
# above. If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the MPL, indicate your decision by
# deleting the provisions above and replace them with the notice and
# other provisions required by the GPL. If you do not delete the
# provisions above, a recipient may use your version of this file
# under either the MPL or the GPL.
package DataSource::HTTPStrings;
use strict;
use vars qw(@ISA);
use PLIF::DataSource;
@ISA = qw(PLIF::DataSource);
1;
sub provides {
my $class = shift;
my($service) = @_;
return ($service eq 'dataSource.strings.default' or $class->SUPER::provides($service));
}
sub getDefaultString {
my $self = shift;
my($app, $protocol, $string) = @_;
if ($protocol ne 'http') {
return; # ``we don't do CDs!!!''
}
if ($string eq 'hello') {
return ('COSES', '<text xmlns="http://bugzilla.mozilla.org/coses">HTTP/1.1 200 OK<br/>Content-Type: text/plain<br/><br/>Hello <if lvalue="(data.session)" condition="ne" rvalue="">user #<text value="(data.session.userID)"/></if><else>World</else>!<br/><br/>visit nph-Main?command=Login to log in if you haven\'t already.<br/>At the moment to create a username and password, you have to ask Hixie to edit the database... :-/ (use open/sesame to test)<br/><br/><include href="debug.dumpVars"/><br/><br/><shrink source="(data.input.arguments)" target="shrunken"><include href="debug.dumpVars"/><br/><br/><expand source="(shrunken)" target="expanded"><include href="debug.dumpVars"/></expand></shrink><br/><br/><text escape="uri">Welcome To The URI World</text><br/><text escape="html">Welcome To The &lt;HTML&gt; World</text><br/><text escape="html"><text escape="uri"><text escape="xml">Welcome To &gt; The HTML+URI+XML+foo World</text></text></text></text>');
} else {
return ('COSES', '<text xmlns="http://bugzilla.mozilla.org/coses">HTTP/1.1 200 OK<br/>Content-Type: text/plain<br/><br/>Er. <include href="debug.dumpVars"/></text>');
}
}

View File

@ -0,0 +1,89 @@
#!/usr/local/bin/perl -wT
# -*- Mode: perl; tab-width: 4; indent-tabs-mode: nil; -*-
#
# This file is MPL/GPL dual-licensed under the following terms:
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and
# limitations under the License.
#
# The Original Code is PLIF 1.0.
# The Initial Developer of the Original Code is Ian Hickson.
#
# Alternatively, the contents of this file may be used under the terms
# of the GNU General Public License Version 2 or later (the "GPL"), in
# which case the provisions of the GPL are applicable instead of those
# above. If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the MPL, indicate your decision by
# deleting the provisions above and replace them with the notice and
# other provisions required by the GPL. If you do not delete the
# provisions above, a recipient may use your version of this file
# under either the MPL or the GPL.
use strict; # enable stricter Perl syntax rules
use diagnostics; # enable fuller diagnostics
use lib "."; # this is required to use the app's modules
use lib "../../PLIF"; # this is required to use PLIF
use vars qw(@ISA);
@ISA = qw(PLIF::Application);
require PLIF::Application; # engage!
1;
# register all the components of this app
sub registerServices {
my $self = shift;
$self->SUPER::registerServices(@_);
# somehow add in all the components
$self->register(qw(
PLIF::Input::CGI
PLIF::Input::CommandLine
PLIF::Input::Default
PLIF::DataSource::FileStrings
PLIF::DataSource::DebugStrings
PLIF::DataSource::Strings::MySQL
PLIF::DataSource::User::MySQL
PLIF::Database::DBI
PLIF::DatabaseHelper::DBI
PLIF::Output::Generic
PLIF::Output::Generic::StdOut
PLIF::Service::Coses
PLIF::Service::XML
PLIF::Service::GenericOutputs
PLIF::Service::User
PLIF::Service::Passwords
PLIF::Service::UserField::String
PLIF::Service::UserFieldFactory
PLIF::Service::Components::AdminCommands
PLIF::Service::Components::Login
PLIF::Service::Components::CosesEditor
PLIF::Service::ContactMethod::Email
Output
DataSource::ConsoleStrings
DataSource::HTTPStrings
));
}
sub unknownCommand {
my $self = shift;
$self->output->hello({});
}
sub cmdLogin {
my $self = shift;
my $user = $self->getService('user.login')->hasRight($self, 'hello');
if (defined($user)) {
my %strings = @{$self->getCollectingServiceList('dispatcher.output')->strings};
$self->output->hello(\%strings);
} # else, user has been notified
}
sub name {
return 'Main Test';
}

View File

@ -0,0 +1,58 @@
# -*- Mode: perl; tab-width: 4; indent-tabs-mode: nil; -*-
#
# This file is MPL/GPL dual-licensed under the following terms:
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and
# limitations under the License.
#
# The Original Code is PLIF 1.0.
# The Initial Developer of the Original Code is Ian Hickson.
#
# Alternatively, the contents of this file may be used under the terms
# of the GNU General Public License Version 2 or later (the "GPL"), in
# which case the provisions of the GPL are applicable instead of those
# above. If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the MPL, indicate your decision by
# deleting the provisions above and replace them with the notice and
# other provisions required by the GPL. If you do not delete the
# provisions above, a recipient may use your version of this file
# under either the MPL or the GPL.
package Output;
use strict;
use vars qw(@ISA);
use PLIF::Output::Generic;
@ISA = qw(PLIF::Service);
1;
sub provides {
my $class = shift;
my($service) = @_;
return ($service eq 'dispatcher.output.generic' or
$service eq 'dispatcher.output' or
$class->SUPER::provides($service));
}
# this requires you to be logged in
sub outputHello {
my $self = shift;
my($app, $output, $strings) = @_;
$output->output('hello', {
'strings' => $strings,
});
}
# dispatcher.output
sub strings {
return (
'hello' => 'Say hello to the user',
);
}

View File

@ -0,0 +1,27 @@
The files in this directory are part of the PLIF test appliaction, the
precursor to Bugzilla3.
Note: To test this on Apache, make a symlink called "nph-Main" and
point it to the file "Main".
You will also then want to create a .htaccess file containing
something like the following:
# set up the CGI scripts without .cgi extensions
<files nph-Main>
SetHandler cgi-script
</files>
# set up the stylesheets without .css extensions
<files style>
ForceType text/css
</files>
# describe the files
AddDescription "The main part of the PLIF test app" nph-Main
# SECURITY_HOLE_PASS_AUTHORIZATION
RewriteEngine on
RewriteBase /libraries/perl/PLIF/tests/
ReWriteRule .? - [E=HTTP_AUTHORIZATION:%{HTTP:AUTHORIZATION},PT]

View File

@ -0,0 +1,14 @@
COSES
<text xml:space="default" xmlns="http://bugzilla.mozilla.org/coses">
<text>
To: <text value="(data.session.fields.contact:e-mail)"/><br/>
From: XXX@spam.hixie.ch<br/>
Subject: Test From PLIF<br/>
</text>
Hi.
Here's what I know:
<include href="debug.dumpVars"/>
</text>

View File

@ -0,0 +1,25 @@
COSES
<text xml:space="default" xmlns="http://bugzilla.mozilla.org/coses">
<set variable="title" value="Hello World">
<include href="template.html.header"/>
</set>
<text><![CDATA[
<p>This is the main page of the test PLIF project. It is being generated from an XML text file!</p>
<p>From here you may: <a href="nph-Main?command=login">Say Hello</a> or <a href="nph-Main?command=cosesEditor">Edit The Strings</a>.</p>
<p>If prompted for a username/password, use "open"/"sesame".</p>
<pre>
]]></text>
<text escape="html">
<include href="debug.dumpVars"/>
</text>
<text><![CDATA[
</pre>
]]></text>
<include href="template.html.footer"/>
</text>

View File

@ -0,0 +1,47 @@
COSES
<text xml:space="default" xmlns="http://bugzilla.mozilla.org/coses">
<set variable="title" value="Login">
<set variable="response" value="401 Authentication Required">
<set variable="headers" value="WWW-Authenticate: Basic realm=&quot;(data.app.name)&quot;&#13;">
<include href="template.html.header"/>
</set></set></set>
<text><![CDATA[
<form action="nph-Main" method="GET"> <!-- XXX POST -->
<p>
]]></text>
<if lvalue="(data.tried)" condition="=" rvalue="1"> The password or username you used is incorrect. </if>
<text> If you would like to create a new account, </text>
<if lvalue="(data.tried)" condition="=" rvalue="1"> or to have your password sent to you, </if>
<text> fill in your e-mail address or other means of contact: </text>
<text><![CDATA[
</p>
<p>
<input type="hidden" name="command" value="SendPassword">
<select name="protocol">
<!-- XXX -->
<option name="e-mail">email</option>
</select>
<input type="text" name="address" value="">
<input type="hidden" name="pendingCommands" value="
]]></text>
<flatten source="(data.input.arguments)" target="flatArguments">
<text value="(flatArguments)"/>
</flatten>
<text><![CDATA[">
<input type="submit" value="Get Password">
</p>
</form>
]]><br/></text>
<text><![CDATA[ <pre>]]><br/></text>
<text escape="html"><include href="debug.dumpVars"/><br/></text>
<text><![CDATA[ </pre>]]></text>
<include href="template.html.footer"/>
</text>

View File

@ -0,0 +1,14 @@
COSES
<text xml:space="default" xmlns="http://bugzilla.mozilla.org/coses">
<!-- - - - - - - -+
| FOOTER TEMPLATE |
+ - - - - - - - -->
<!-- End of HTML Document -->
<text xml:space="preserve"><![CDATA[
</body>
</html>
]]></text>
</text>

View File

@ -0,0 +1,40 @@
COSES
<text xml:space="default" xmlns="http://bugzilla.mozilla.org/coses">
<!-- - - - - - - -+
| HEADER TEMPLATE |
+ - - - - - - - -->
<!-- HTTP Header -->
<text>
HTTP/1.1 <if lvalue="response" condition="ne" rvalue=""><text value="(response)"/></if><else>200 OK</else><br/>
<if lvalue="headers" condition="ne" rvalue=""><text value="(headers)"/></if>Content-Type: text/html
</text>
<!-- Separator -->
<br/><br/>
<!-- HTML Header -->
<text><![CDATA[
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<title>]]><text escape="html" value="(data.app.name): (title)"/><![CDATA[</title>
<link rel="stylesheet" href="style">
]]></text>
<!-- User's stylesheet, if any
<if lvalue="(data.session.fields.settings:stylesheet)" condition="ne" rvalue="">
&lt;link rel="stylesheet" href="<text escape="html" value="(data.session.fields.settings:stylesheet)"/>"&gt;
</if>-->
<!-- End of HTML Header -->
<text xml:space="preserve"><![CDATA[
</head>
<body>
<h1>]]><text escape="html" value="(title)"/><![CDATA[</h1>
]]></text>
<!-- See also the footer template. -->
</text>

View File

@ -0,0 +1 @@
/* plif.css */