summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2011-01-09 16:29:29 +0100
committerYorhel <git@yorhel.nl>2011-01-09 16:50:04 +0100
commit79894c79083005bd98b5ef19edf4966dd4675ada (patch)
tree69e9b20273bc746c5dcac60429759b4e520916b9 /examples
parentd7f850931451bf11538fea70b0dac212be346fc9 (diff)
s/YAWF/TUWF/ and removed examples and some oudated docs
I'll create new examples while making some improvements to the framework.
Diffstat (limited to 'examples')
-rw-r--r--examples/VNDB/DB/Misc.pm24
-rw-r--r--examples/VNDB/Handler/Example.pm87
-rw-r--r--examples/VNDB/Handler/Forms.pm60
-rwxr-xr-xexamples/vndb.pl47
4 files changed, 0 insertions, 218 deletions
diff --git a/examples/VNDB/DB/Misc.pm b/examples/VNDB/DB/Misc.pm
deleted file mode 100644
index b83a66d..0000000
--- a/examples/VNDB/DB/Misc.pm
+++ /dev/null
@@ -1,24 +0,0 @@
-
-package VNDB::DB::Misc;
-
-use strict;
-use warnings;
-use Exporter 'import';
-
-our @EXPORT = ('dbVNInfo');
-
-
-# small example showing how execute an SQL query and return the results
-sub dbVNInfo {
- my($s, $id) = @_;
- return $s->dbRow(q|
- SELECT vr.id, vr.title, vr.original
- FROM vn v
- JOIN vn_rev vr ON vr.id = v.latest
- WHERE v.id = ?
- LIMIT 1|,
- $id);
-}
-
-
-1;
diff --git a/examples/VNDB/Handler/Example.pm b/examples/VNDB/Handler/Example.pm
deleted file mode 100644
index 0fdc788..0000000
--- a/examples/VNDB/Handler/Example.pm
+++ /dev/null
@@ -1,87 +0,0 @@
-
-package VNDB::Handler::Example;
-
-use strict;
-use warnings;
-use YAWF ':html', ':xml';
-
-
-YAWF::register(
- qr/envdump/, \&envdump,
- qr/error/, \&error,
- qr/html/, \&htmlexample,
- qr{v([1-9]\d*)/xml}, \&vnxml,
-);
-
-
-sub envdump {
- my $self = shift;
- $self->resHeader('Content-Type', 'text/plain');
- my $fd = $self->resFd;
-
- # normally you'd use req* methods to fetch
- # environment-specific information...
- print $fd "ENV-Dump:\n";
- printf $fd " %s: %s\n", $_, $ENV{$_} for (sort keys %ENV);
-
- # ...like this
- print $fd "\n";
- print $fd "Header dump:\n";
- printf $fd " %s: %s\n", $_, $self->reqHeader($_) for ($self->reqHeader());
-
- # ..and this
- print $fd "\n";
- print $fd "Param dump:\n";
- printf $fd " %s: %s\n", $_, $self->reqParam($_) for ($self->reqParam());
-}
-
-
-sub error {
- # this handler demonstrates a function that fails, YAWF
- # should display a 500 error page and write a detailed
- # report to the log file
- warn "A random warning message before the error actually occurs";
- die "Some descriptive error message here";
-}
-
-
-sub htmlexample {
- html;
- head;
- title 'HTML Output Example';
- end;
- body;
- h1 'HTML Output Example';
- p 'This is a way to output HTML...';
- end;
- end;
-}
-
-
-# this function will get a number as argument, this number was parsed
-# from the pattern match above (/v+/xml, we get the + here as argument)
-sub vnxml {
- my($self, $id) = @_;
-
- # Let's actually serve XML as text/xml
- $self->resHeader('Content-Type' => 'text/xml');
-
- # fetch some information about that VN,
- # defined in VNDB::DB::Misc
- my $v = $self->dbVNInfo($id);
-
- # no results found, return a 404
- return 404 if !$v->{id};
-
- # XML output
- xml;
- tag 'vn', id => $id;
- tag 'title', $v->{title};
- tag 'original', $v->{original};
- end;
-}
-
-
-1;
-
-
diff --git a/examples/VNDB/Handler/Forms.pm b/examples/VNDB/Handler/Forms.pm
deleted file mode 100644
index 11a5735..0000000
--- a/examples/VNDB/Handler/Forms.pm
+++ /dev/null
@@ -1,60 +0,0 @@
-
-package VNDB::Handler::Forms;
-
-use strict;
-use warnings;
-use YAWF ':html';
-use Data::Dumper 'Dumper';
-
-
-$Data::Dumper::Sortkeys++;
-$Data::Dumper::Terse++;
-
-
-# an alternative way of writing handlers (TIMTOWTDI)
-YAWF::register(
-qr/formtest/, sub {
- my $self = shift;
-
- my @rules;
- my $rules = q{ (
- { name => 'string1', required => 1, maxlength => 20, minlength => 10, enum => [qw|50 hundred only-valid-value|] },
- { name => 'string2', required => 0, regex => [ qr/default/, 'fail message' ], default => 'this is a default (and matches)' },
- { name => 'string3', required => 1, func => [ sub {
- if(length $_[0] > 5) { $_[0] = uc($_[0]); return $_[0] } else { return undef }
- }, 'another fail message' ] },
- { name => 'string4', required => 1, template => 'int' },
- )};
- eval '@rules = '.$rules;
-
- my $frm = $self->formValidate(@rules);
-
- html;
- head;
- title 'Form Validation Test';
- end;
- body;
- h1 'Form Validation Test';
- h2 'A Random Form...';
- form action => '/formtest', method => 'post';
- fieldset;
- for (1..4) {
- label for => 'string'.$_, '#'.$_;
- input type => 'text', id => 'string'.$_, name => 'string'.$_,
- value => $frm->{"string$_"}, size => 50;
- br;
- }
- input type => 'submit', value => 'Submit!';
- end;
- end;
- h2 '@rules = ';
- pre $rules;
- h2 'Dumper($self->formValidate(@rules));';
- pre Dumper $frm;
- end;
- end;
-},
-);
-
-
-1;
diff --git a/examples/vndb.pl b/examples/vndb.pl
deleted file mode 100755
index fb4aebd..0000000
--- a/examples/vndb.pl
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/perl
-
-# this script should be able to be used as both a CGI
-# and a FastCGI script.
-
-
-package VNDB;
-
-use strict;
-use warnings;
-
-# determine root directory
-use Cwd 'abs_path';
-our $ROOT;
-BEGIN {
- ($ROOT = abs_path $0) =~ s{/examples/vndb\.pl$}{};
-}
-
-# make sure YAWF is findable
-use lib $ROOT.'/lib';
-# and make sure our own example modules are, too
-use lib $ROOT.'/examples';
-
-
-use YAWF;
-
-
-YAWF::init(
-
- # required
- namespace => 'VNDB',
- db_login => [ 'dbi:Pg:dbname=vndb', 'vndb', 'passwd' ],
-
- # optional
- debug => 1,
- logfile => $ROOT.'/data/logs/err.log',
-
- error_404_handler => \&page_404,
-);
-
-
-sub page_404 {
- my $self = shift;
- my $fd = $self->resFd;
- print $fd "This is our custom 404 error page!\n";
-}
-