cvsuser 02/03/10 09:26:02
Added: P5EEx/Blue/cgi-bin demo_report.conf demo_report.pl p5x.PL
ttx.PL
Removed: P5EEx/Blue/cgi-bin config.pl.sample p5ee.PL p5ee.conf.sample
Log:
renamed files and reorganized the cgi-bin directory
Revision Changes Path
1.1 p5ee/P5EEx/Blue/cgi-bin/demo_report.conf
Index: demo_report.conf
===================================================================
#############################################################################
# $Id: demo_report.conf,v 1.1 2002/03/10 17:26:02 spadkins Exp $
#############################################################################
perlinc = /usr/ov/acoc/dev/src/P5EEx-Blue, /usr/ov/acoc/dev/lib/perl5/5.6.0
debugmode = record
showsession = 1
gzip = 1
configFile = config.pl
#sessionClass = P5EEx::Blue::Session::Cookie
defaultWname = app
scriptUrlDir = /cgi-bin/pub/p5ee
scriptDir = /usr/ov/acoc/dev/p5ee/P5EEx/Blue/cgi-bin
htmlUrlDir = /pub/p5ee/software/htdocs
htmlDir = /usr/ov/acoc/dev/p5ee/P5EEx/Blue/htdocs
1.1 p5ee/P5EEx/Blue/cgi-bin/demo_report.pl
Index: demo_report.pl
===================================================================
$data = {
#########################################################################
# $Id: demo_report.pl,v 1.1 2002/03/10 17:26:02 spadkins Exp $
# NOTE: this is after the "$data = {" line for a reason
#########################################################################
WidgetType => {
date => {
widgetClass => 'P5EEx::Blue::Widget::HTML::Element',
tag => 'input',
type => 'text',
maxlength => '99',
size => '14',
},
date3 => {
widgetClass => 'P5EEx::Blue::Widget::HTML::DateDropDowns',
},
gender => {
widgetClass => 'P5EEx::Blue::Widget::HTML::Select',
domain => 'gender',
},
year => {
widgetClass => 'P5EEx::Blue::Widget::HTML::Select',
domain => 'year',
},
month => {
widgetClass => 'P5EEx::Blue::Widget::HTML::Select',
domain => 'month',
},
day => {
widgetClass => 'P5EEx::Blue::Widget::HTML::Select',
domain => 'day',
},
table => {
widgetClass => 'P5EEx::Blue::Widget::HTML::DataTable',
repository => 'db',
table => 'person',
headings => [ "ID", "Last Name", "First Name", "Address", "City", "State",
"Home Phone", "Sex", "Birth Date" ],
columns => [ "person_id", "last_name", "first_name", "address", "city",
"state", "home_phone", "gender", "birth_dt" ],
keycolidx => [ 0 ],
scrollable => 1,
sortable => 1,
filterable => 1,
editable => 1,
},
check_anniv_dt => {
label => 'Check Date',
widgetClass => 'P5EEx::Blue::Widget::HTML::Button',
},
button => {
widgetClass => 'P5EEx::Blue::Widget::HTML::ImageButton',
height => '17',
width => '100',
bevel => '2',
},
'button.min' => {
widgetClass => 'P5EEx::Blue::Widget::HTML::ImageButton',
height => '17',
width => '100',
bevel => '2',
},
'repedit.button' => {
widgetClass => 'P5EEx::Blue::Widget::HTML::ImageButton',
height => '17',
width => '70',
bevel => '2',
},
app => {
widgetClass => 'P5EEx::Blue::Widget::HTML::AppFrame',
title => "P5EE Reporting and Data Maintenance",
bgcolor => "#cccccc",
text => "#000000",
link => "#996600",
vlink => "#996600",
alink => "#996600",
leftmargin => "0",
topmargin => "0",
rightmargin => "0",
bottommargin => "0",
},
'selector.button' => {
widgetClass => 'P5EEx::Blue::Widget::HTML::ImageButton',
height => '19',
width => '98',
bevel => '2',
},
},
Domain => {
gender => {
values => [ 'M', 'F', ],
labels => { M => 'Male', F => 'Female', },
},
year => {
values => [
'1980', '1981', '1982', '1983', '1984', '1985', '1986', '1987', '1988',
'1989',
'1990', '1991', '1992', '1993', '1994', '1995', '1996', '1997', '1998',
'1999',
'2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008',
'2009',
],
labels => {},
},
month => {
values => [ '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11',
'12', ],
labels => {
'01' => 'Jan', '02' => 'Feb', '03' => 'Mar', '04' => 'Apr',
'05' => 'May', '06' => 'Jun', '07' => 'Jul', '08' => 'Aug',
'09' => 'Sep', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec',
},
},
day => {
values => [
'01', '02', '03', '04', '05', '06', '07', '08', '09', '10',
'11', '12', '13', '14', '15', '16', '17', '18', '19', '20',
'21', '22', '23', '24', '25', '26', '27', '28', '29', '30',
'31',
],
labels => {},
},
name => {
repository => 'db',
time_to_live => '', # never expire this domain (default)
getmethod => 'selectall_arrayref', # method to refresh name/label pairs
(default "get")
# args to pass when refreshing name/label pairs (default is key of this hash,
i.e. "name")
getmethod_args => [ "select person_id, concat(last_name, ', ', first_name)
from Widget.person" ],
},
},
Repository => {
db => {
repositoryClass => 'P5EEx::Blue::Repository::DBI',
dbidriver => "mysql",
dbname => "p5ee_demo",
dbuser => "dbuser",
dbpass => "dbuser7",
},
},
Widget => {
default => {
widgetClass => 'P5EEx::Blue::Widget::HTML::Label',
},
global => {
lang => 'fr_ca',
dict => {
en => {
Male => 'Male',
Female => 'Female',
},
fr => {
Male => 'Homme',
Female => 'Dame',
},
fr_ca => {
Female => 'Fille',
},
},
},
hello => {
widgetClass => 'P5EEx::Blue::Widget::HTML::Element',
tag => 'input',
type => 'text',
maxlength => '99',
size => '14',
},
first_name => {
widgetClass => 'P5EEx::Blue::Widget::HTML::Element',
tag => 'input',
type => 'text',
maxlength => '99',
size => '14',
},
last_name => {
widgetClass => 'P5EEx::Blue::Widget::HTML::Element',
tag => 'input',
type => 'text',
maxlength => '99',
size => '14',
},
birth_dt => { widgetType => 'date', },
anniv_dt => { widgetType => 'date3', },
'anniv_dt.year' => { widgetType => 'year', },
'anniv_dt.month' => { widgetType => 'month', },
'anniv_dt.day' => { widgetType => 'day', },
gender => { widgetType => 'gender', },
check_it => { widgetType => 'check_anniv_dt', },
table => { widgetType => 'table', },
name => {
widgetClass => 'P5EEx::Blue::Widget::HTML::Select',
domain => 'name',
},
hello_button => {
widgetType => 'button',
label => 'Hello, world',
},
tree => {
widgetClass => 'P5EEx::Blue::Widget::HTML::TreeView',
node => {
1 => { open => 1, value => 'Data', },
1.1 => { open => 1, value => 'Development', },
1.1.1 => { open => 0, value => 'Argo UML', },
1.1.2 => { open => 0, value => 'c', },
1.1.3 => { open => 1, value => 'icons', },
1.1.3.1 => { open => 1, value => 'icons', },
1.2 => { open => 0, value => 'Marcia', },
2 => { open => 1, value => 'Data', },
2.1 => { open => 0, value => 'Development', },
2.1.1 => { open => 0, value => 'Argo UML', },
2.1.2 => { open => 0, value => 'c', },
2.1.3 => { open => 1, value => 'icons', },
2.1.3.1 => { open => 1, value => 'icons', },
2.2 => { open => 0, value => 'Marcia', },
3 => { open => 0, value => 'Data', },
3.1 => { open => 0, value => 'Development', },
3.1.1 => { open => 0, value => 'Argo UML', },
3.1.2 => { open => 0, value => 'c', },
3.1.3 => { open => 1, value => 'icons', },
3.1.3.1 => { open => 1, value => 'icons', },
3.2 => { open => 0, value => 'Marcia', },
},
},
app => {
widgetType => 'app',
},
'app.menu' => {
widgetClass => 'P5EEx::Blue::Widget::HTML::Menu',
},
'app.toolbar' => {
widgetClass => 'P5EEx::Blue::Widget::HTML::Toolbar',
},
'app.screentitle' => {
widgetClass => 'P5EEx::Blue::Widget::HTML::Label',
bgcolor => '#888888',
},
'app.screentoolbar' => {
widgetClass => 'P5EEx::Blue::Widget::HTML::Toolbar',
},
'app.selector' => {
widgetClass => 'P5EEx::Blue::Widget::HTML::SelectorView',
selected => "1.1",
node => {
1 => { open => 1, value => 'Reports',
icon => 'calendar.gif' },
1.1 => { open => 1, value => 'Dates', wname => 'table',
},
1.1.1 => { open => 0, value => 'Arrival Date', wname => 'tree',
},
1.1.2 => { open => 0, value => 'Departure Date', wname => 'table',
},
1.1.3 => { open => 0, value => 'Booking Date', wname => 'tree',
},
1.1.3.1 => { open => 0, value => 'Booking Time', wname => 'table',
},
1.2 => { open => 0, value => 'Locations', wname => 'tree',
},
2 => { open => 0, value => 'Maintenance',
},
2.1 => { open => 0, value => 'Inventory', wname => 'tree',
icon => 'home.gif' },
2.1.1 => { open => 0, value => 'Current Inventory', wname => 'table',
icon => 'calendar.gif' },
2.1.2 => { open => 0, value => 'Future Inventory', wname => 'tree',
icon => 'notes.gif' },
2.1.3 => { open => 0, value => 'Historical Inventory', wname => 'table',
icon => 'tasks.gif' },
2.2 => { open => 0, value => 'Payables', wname => 'tree',
icon => 'contacts.gif' },
2.3 => { open => 0, value => 'Sales', wname => 'tree',
icon => 'home.gif' },
2.3.1 => { open => 0, value => 'Current Sales', wname => 'table',
icon => 'calendar.gif' },
2.3.2 => { open => 0, value => 'Future Sales', wname => 'tree',
icon => 'notes.gif' },
2.3.3 => { open => 0, value => 'Historical Sales', wname => 'table',
icon => 'tasks.gif' },
2.4 => { open => 0, value => 'Receivables', wname => 'tree',
icon => 'contacts.gif' },
3 => { open => 0, value => 'Settings',
icon => 'trash2.gif' },
3.1 => { open => 0, value => 'Users', wname => 'tree',
},
3.2 => { open => 0, value => 'Locations', wname => 'tree',
icon => 'tasks.gif' },
4 => { open => 0, value => 'Security',
icon => 'trash2.gif' },
4.1 => { open => 0, value => 'Users', wname => 'tree',
},
4.2 => { open => 0, value => 'Locations', wname => 'tree',
icon => 'tasks.gif' },
5 => { open => 0, value => 'Customization',
icon => 'trash2.gif' },
5.1 => { open => 0, value => 'Users', wname => 'tree',
},
5.2 => { open => 0, value => 'Locations', wname => 'tree',
icon => 'tasks.gif' },
},
},
'app.selector.button1' => {
widgetType => 'selector.button',
},
'app.selector.button2' => {
widgetType => 'selector.button',
},
'app.selector.button3' => {
widgetType => 'selector.button',
},
dbapp => { widgetType => 'app', },
'dbapp.menu' => { widgetClass => 'P5EEx::Blue::Widget::HTML::Menu', },
'dbapp.toolbar' => { widgetClass => 'P5EEx::Blue::Widget::HTML::Toolbar', },
'dbapp.screentitle' => { widgetClass => 'P5EEx::Blue::Widget::HTML::Label',
bgcolor => '#888888', },
'dbapp.screentoolbar' => { widgetClass => 'P5EEx::Blue::Widget::HTML::Toolbar',
},
'dbapp.selector' => {
widgetClass => 'P5EEx::Blue::Widget::HTML::SelectorView',
node => {
1 => { open => 1, value => 'Screens', },
1.1 => { open => 1, value => 'View/Edit Database', wname => 'repedit', },
},
},
'dbapp.selector.button1' => { widgetType => 'selector.button', },
repedit => { widgetClass => 'P5EEx::Blue::Widget::HTML::RepositoryEditor',
repository => 'db', },
},
};
1.1 p5ee/P5EEx/Blue/cgi-bin/p5x.PL
Index: p5x.PL
===================================================================
use Config;
use File::Basename qw(basename dirname);
chdir(dirname($0));
($file = basename($0)) =~ s/\.PL$//;
$file =~ s/\.pl$//
if ($Config{'osname'} eq 'VMS' or
$Config{'osname'} eq 'OS2'); # "case-forgiving"
open OUT,">$file" or die "Can't create $file: $!";
chmod(0755, $file);
print "Extracting $file (with variable substitutions)\n";
print OUT <<"!SUBSTITUTIONS!OK!";
$Config{'startperl'} -wT
!SUBSTITUTIONS!OK!
print OUT <<'!NO!SUBSTITUTIONS!';
#############################################################################
# $Id: p5x.PL,v 1.1 2002/03/10 17:26:02 spadkins Exp $
#############################################################################
BEGIN {
my ($var, $value, $open, $file);
local(*FILE);
%main::conf = ();
$open = 0; # assume we cannot find an openable config file ...
if (defined $ENV{PATH_INFO}) {
$file = $ENV{PATH_INFO} . ".conf"; # default config file based on PATH_INFO
$file =~ s!^/!!; # with no leading "/"
$file =~ s!/!_!g; # and internal "/"s changed to "_"s
$open = open(main::FILE, "< $file") if (-r $file);
}
$open = open(main::FILE, "< $0.conf") if (!$open && -r "$0.conf");
$open = open(main::FILE, "< p5ee.conf") if (!$open && -r "p5ee.conf");
if ($open) {
while (<main::FILE>) {
chomp;
s/#.*$//; # delete comments
s/^ +//; # delete leading spaces
s/ +$//; # delete trailing spaces
next if (/^$/); # skip blank lines
# look for "var = value" (ignore other lines)
if (/^([a-zA-Z_.-]+) *= *(.*)/) { # untainting also happens
$var = $1;
$value = $2;
$main::conf{$var} = $value; # save all in %main::conf
}
}
close(main::FILE);
if (defined $main::conf{perlinc}) { # add perlinc entries
unshift(@INC, split(/ *, */,$main::conf{perlinc}));
}
}
}
#################################################################
# read command-line configuration variables
# (anything starting with one or two dashes is a config var, not a CGI var)
# i.e. --debugmode=record -debugmode=replay
# an option without an "=" (i.e. --help) acts as --help=1
#################################################################
while ($#ARGV >= 0 && $ARGV[0] =~ /^--?([^=-][^=]*)(=?)(.*)/) {
$var = $1;
$value = ($2 eq "") ? 1 : $3;
shift @ARGV;
$main::conf{$var} = $value;
}
use P5EEx::Blue::P5EE;
#################################################################
# NOTE: some Context classes (e.g. Context::CGI) also read in
# the environment and store it in the %main::conf.
#################################################################
my $context = P5EEx::Blue::P5EE->context(\%main::conf);
$context->dispatch_events();
!NO!SUBSTITUTIONS!
1.1 p5ee/P5EEx/Blue/cgi-bin/ttx.PL
Index: ttx.PL
===================================================================
use Config;
use File::Basename qw(basename dirname);
chdir(dirname($0));
($file = basename($0)) =~ s/\.PL$//;
$file =~ s/\.pl$//
if ($Config{'osname'} eq 'VMS' or
$Config{'osname'} eq 'OS2'); # "case-forgiving"
open OUT,">$file" or die "Can't create $file: $!";
chmod(0755, $file);
print "Extracting $file (with variable substitutions)\n";
print OUT <<"!SUBSTITUTIONS!OK!";
$Config{'startperl'} -wT
!SUBSTITUTIONS!OK!
print OUT <<'!NO!SUBSTITUTIONS!';
######################################################################
## $Id: ttx.PL,v 1.1 2002/03/10 17:26:02 spadkins Exp $
######################################################################
BEGIN {
my ($var, $value, $open, $file);
local(*FILE);
%main::conf = ();
$open = 0; # assume we cannot find an openable config file ...
if (defined $ENV{PATH_INFO}) {
$file = $ENV{PATH_INFO} . ".conf"; # default config file based on PATH_INFO
$file =~ s!^/!!; # with no leading "/"
$file =~ s!/!_!g; # and internal "/"s changed to "_"s
$open = open(main::FILE, "< $file") if (-r $file);
}
$open = open(main::FILE, "< $0.conf") if (!$open && -r "$0.conf");
$open = open(main::FILE, "< p5ee.conf") if (!$open && -r "p5ee.conf");
if ($open) {
while (<main::FILE>) {
chomp;
s/#.*$//; # delete comments
s/^ +//; # delete leading spaces
s/ +$//; # delete trailing spaces
next if (/^$/); # skip blank lines
# look for "var = value" (ignore other lines)
if (/^([a-zA-Z_.-]+) *= *(.*)/) { # untainting also happens
$var = $1;
$value = $2;
$main::conf{$var} = $value; # save all in %main::conf
}
}
close(main::FILE);
if (defined $main::conf{perlinc}) { # add perlinc entries
unshift(@INC, split(/ *, */,$main::conf{perlinc}));
}
}
}
use CGI;
use CGI::Carp;
use Template;
my $cgi = new CGI;
{
my $cgidebug;
$cgidebug = $cgi->param("cgidebug");
$cgidebug = $main::conf{"cgidebug"} if (! defined $cgidebug);
$cgidebug = "" if (! defined $cgidebug);
if ($cgidebug eq "save") {
&save_cgistate();
}
elsif ($cgidebug eq "restore") {
&restore_cgistate();
}
}
use strict;
my ($template);
$template = $cgi->param("template");
$template = $ENV{PATH_INFO} if (! defined $template);
$template = "/index.html" if (! defined $template || $template eq "/");
$template =~ s!^/!!;
&show_template($cgi, $template);
exit(0);
###################################################################
# Support Routines
###################################################################
sub show_template {
my ($cgi, $template) = @_;
my ($var, $value, $vars, %vars);
my ($tproc, %tconfig, $templatedir, @templatedirs);
if ($main::conf{"templatedir"}) {
$templatedir = $main::conf{"templatedir"};
@templatedirs = split(/ *, */,$templatedir);
}
elsif ($main::conf{"prefix"}) {
$templatedir = $main::conf{"prefix"} . "/templates";
@templatedirs = ( $templatedir );
}
elsif ($ENV{"PREFIX"}) {
$templatedir = $ENV{"PREFIX"} . "/templates";
@templatedirs = ( $templatedir );
}
else {
$templatedir = $0;
$templatedir =~ s!/[^/]+$!!; # remove command, leave directory
$templatedir =~ s!/cgi-bin.*!!; # if in cgi-bin, go to dir above
$templatedir .= "/templates"; # "templates" dir next to "cgi-bin"
@templatedirs = ( $templatedir );
}
my $widget_debug = $cgi->param("widget_debug");
if (defined $widget_debug && $widget_debug ne "") {
$Widget::DEBUG = $widget_debug;
$Widget::DEBUG += 0; # use a second time to get rid of a warning
}
# TODO: add config file options to turn these on and off individually
%tconfig = (
INCLUDE_PATH => \@templatedirs, # list ref of template search path
INTERPOLATE => 1, # expand "$var" in plain text
#PRE_CHOMP => 1, # cleanup whitespace
POST_CHOMP => 1, # cleanup whitespace
EVAL_PERL => 1, # evaluate Perl code blocks
LOAD_PERL => 1, # enable regular perl modules as plugins
# NOTE: LOAD_PERL is necessary for Widget to be loaded as a plugin
# I probably ought to get around to writing a real plugin
);
$tproc = Template->new(\%tconfig);
%vars = %{$cgi->Vars()}; # use all CGI variables in template
$vars{cgi} = $cgi; # add the CGI object itself to the stash
if ($template =~ /\.html$/) { # if it ends in ".html" ...
print "Content-type: text/html\n\n"; # print out the necessary header
} # (otherwise, the template needs to put out
header)
$tproc->process($template, \%vars) || die $tproc->error(), "\n"; # go!
}
sub restore_cgistate {
my ($var);
local(*FILE);
foreach $var (keys %ENV) {
delete $ENV{$var};
}
open (main::FILE, "< ttx.env") || die "Unable to open ttx.env: $!\n";
while (<main::FILE>) {
chomp;
if (/^([^=]+)=(.*)/) {
$ENV{$1} = $2;
}
}
close(main::FILE);
open (main::FILE, "< ttx.vars") || die "Unable to open ttx.vars: $!\n";
$cgi = new CGI(*main::FILE);
close(main::FILE);
}
sub save_cgistate {
my ($var);
local(*FILE);
open (main::FILE, "> ttx.env") || die "Unable to open ttx.env: $!\n";
foreach $var (keys %ENV) {
print main::FILE "$var=$ENV{$var}\n";
}
close(main::FILE);
open (main::FILE, "> ttx.vars") || die "Unable to open ttx.vars: $!\n";
$cgi->save(*main::FILE);
close(main::FILE);
}
!NO!SUBSTITUTIONS!