summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2008-11-23 14:24:52 +0100
committerYorhel <git@yorhel.nl>2008-11-23 14:24:52 +0100
commitdc68c4e5de3b0df1f57e4b601672917ae532fe29 (patch)
tree2731f6ec386d6713d1b0f4200e59c952d0a4fe1f /lib
parent03b6fc709593c611a319d348469acfef35a1231f (diff)
Adding VN relations using the new interface works
By specifying an ID, we still need a JS-powered search >.>
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/Handler/VNEdit.pm31
1 files changed, 28 insertions, 3 deletions
diff --git a/lib/VNDB/Handler/VNEdit.pm b/lib/VNDB/Handler/VNEdit.pm
index 74885d8d..42689ea7 100644
--- a/lib/VNDB/Handler/VNEdit.pm
+++ b/lib/VNDB/Handler/VNEdit.pm
@@ -3,12 +3,13 @@ package VNDB::Handler::VNEdit;
use strict;
use warnings;
-use YAWF ':html';
+use YAWF ':html', ':xml';
YAWF::register(
qr{v(?:([1-9]\d*)(?:\.([1-9]\d*))?/edit|/new)}
=> \&edit,
+ qr{xml/vn\.xml} => \&vnxml,
);
@@ -180,13 +181,13 @@ sub _form {
h2 'Add relation';
table;
- Tr;
+ Tr id => 'relation_new';
td class => 'tc1';
input type => 'text', class => 'text';
end;
td class => 'tc2';
txt ' is a ';
- Select id => 'relation_sel_new';
+ Select;
option value => $_, $self->{vn_relations}[$_][0] for (0..$#{$self->{vn_relations}});
end;
txt ' of';
@@ -249,5 +250,29 @@ sub _updreverse {
}
+# peforms a (simple) search and returns the results in XML format
+sub vnxml {
+ my $self = shift;
+
+ my $q = $self->formValidate({ name => 'q', maxlength => 500 });
+ return 404 if $q->{_err};
+ $q = $q->{q};
+
+ my($list, $np) = $self->dbVNGet( # / not implemented yet
+ $q =~ /^v([1-9]\d*)/ ? (id => $1) : (search => $q),
+ results => 10,
+ page => 1,
+ );
+
+ $self->resHeader('Content-type' => 'text/xml; charset=UTF-8');
+ xml;
+ tag 'vns', more => $np ? 'yes' : 'no', query => $q;
+ for(@$list) {
+ tag 'vn', id => $_->{id}, $_->{title};
+ }
+ end;
+}
+
+
1;