diff options
author | yorhel <yorhel@1fe2e327-d9db-4752-bcf7-ef0cb4a1748b> | 2008-05-01 08:44:25 +0000 |
---|---|---|
committer | yorhel <yorhel@1fe2e327-d9db-4752-bcf7-ef0cb4a1748b> | 2008-05-01 08:44:25 +0000 |
commit | 59f6e2061ab2c19a626813e99b59d416f730180c (patch) | |
tree | dc080dd22ce4578cb9b9b893cf74ea9ccb53bba1 /lib/VNDB | |
parent | 2e533bd16346ec74216415c01a57c7276d608cf8 (diff) |
Another batch of changes... see the ChangeLog!
git-svn-id: svn://vndb.org/vndb@10 1fe2e327-d9db-4752-bcf7-ef0cb4a1748b
Diffstat (limited to 'lib/VNDB')
-rw-r--r-- | lib/VNDB/HomePages.pm | 34 | ||||
-rw-r--r-- | lib/VNDB/Util/DB.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/Util/Response.pm | 34 |
3 files changed, 37 insertions, 33 deletions
diff --git a/lib/VNDB/HomePages.pm b/lib/VNDB/HomePages.pm index eb0f9e0b..0e99f517 100644 --- a/lib/VNDB/HomePages.pm +++ b/lib/VNDB/HomePages.pm @@ -7,7 +7,7 @@ use Exporter 'import'; use vars ('$VERSION', '@EXPORT'); $VERSION = $VNDB::VERSION; -@EXPORT = qw| HomePage FAQ DocPage History HistRevert HistDelete |; +@EXPORT = qw| HomePage DocPage History HistRevert HistDelete |; sub HomePage { @@ -31,12 +31,34 @@ sub HomePage { } -sub FAQ { - shift->ResAddTpl(faq => {}); -} - sub DocPage { - shift->ResAddTpl(docs => { p => shift }); + my($s,$p) = @_; + + open my $F, '<', sprintf('%s/%d', $s->{docpath}, $p) or return $s->ResNotFound(); + my @c = <$F>; + close $F; + + (my $title = shift @c) =~ s/^:TITLE://; + chomp $title; + + my $sec = 0; + for (@c) { + s{^:SUB:(.+)\r?\n$}{ + $sec++; + qq|<h3><a href="#$sec" name="$sec">$sec. $1</a></h3>\n| + }eg; + s{^:INC:(.+)\r?\n$}{ + open $F, '<', sprintf('%s/%s', $s->{docpath}, $1) or die $!; + my $ii = join('', <$F>); + close $F; + $ii; + }eg; + } + + $s->ResAddTpl(docs => { + title => $title, + content => join('', @c), + }); } diff --git a/lib/VNDB/Util/DB.pm b/lib/VNDB/Util/DB.pm index f10f7b67..e5eba14f 100644 --- a/lib/VNDB/Util/DB.pm +++ b/lib/VNDB/Util/DB.pm @@ -1274,7 +1274,7 @@ sub qs { # ISO SQL2-quoting, with some PgSQL-specific stuff # depends on the standard_conforming_strings configuration option of PgSQL, # while E'' will always behave the same regardless of the server configuration. for (@r) { - (!defined $_ or $_ eq '_NULL_') && ($_ = 'NULL') && next; + (!defined $_ or $_ eq '_NULL_') && next; s/'/''/g; s/\\/\\\\/g; $_ = "E'$_'"; diff --git a/lib/VNDB/Util/Response.pm b/lib/VNDB/Util/Response.pm index 619429ae..8d3f33b8 100644 --- a/lib/VNDB/Util/Response.pm +++ b/lib/VNDB/Util/Response.pm @@ -13,7 +13,7 @@ require bytes; use vars ('$VERSION', '@EXPORT'); $VERSION = $NTL::VERSION; -@EXPORT = qw| ResRedirect ResNotFound ResDown ResDenied ResFile +@EXPORT = qw| ResRedirect ResNotFound ResDenied ResFile ResForceBody ResSetContentType ResAddHeader ResAddTpl ResAddDefaultStuff ResStartXML ResGetXML ResGetBody ResGet ResGetCGI ResSetModPerl |; @@ -31,7 +31,6 @@ sub new { xmlobj => undef, xmldata => undef, whattouse => 1, - rc => 0, }, $type; return $me; @@ -54,40 +53,23 @@ sub ResRedirect { my $code = !$type ? 301 : $type eq 'temp' ? 307 : $type eq 'post' ? 303 : 301; + $info->{body} = 'Redirecting...'; $info->{code} = $code; - $info->{tpl} = { - error => { - url => $url, - code => $code, - } - }; $info->{headers} = [ 'Location', "$self->{root_url}$url" ]; $info->{contenttype} = 'text/html; charset=UTF-8'; - $info->{whattouse} = 2; + $info->{whattouse} = 1; } sub ResNotFound { my $s = shift; my $i = $s->{_Res}; $i->{code} = 404; - $i->{whattouse} = 4; - push @{$i->{headers}}, 'X-Sendfile' => '/www/vndb/www/files/notfound.html'; -} - -sub ResDown { - my $self = shift; - my $msg = shift || ''; - my $info = $self->{_Res} || $self; - - $info->{code} = 200; - $info->{tpl} = { - error => { - code => 1, - msg => $msg, # specifies which message should be displayed - } + $i->{whattouse} = 2; + $i->{tpl} = { + page => { error => { + err => 'notfound' + }}, }; - $info->{contenttype} = 'text/html; charset=UTF-8'; - $info->{whattouse} = 2; } sub ResDenied { |