chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.web-live.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Invokes "routetrade" component to get answers
[ypp-sc-tools.web-live.git]
/
yarrg
/
web
/
routetextstring
diff --git
a/yarrg/web/routetextstring
b/yarrg/web/routetextstring
index 4cec5f9d337b1f994f694857ec528887a5c2828a..685b465255325fe566c6ed0f5468b51fa492c711 100644
(file)
--- a/
yarrg/web/routetextstring
+++ b/
yarrg/web/routetextstring
@@
-31,12
+31,16
@@
if ($format =~ 'json') {
success => 1,
show => length $canontext ? encode_entities($canontext)
: ' ',
success => 1,
show => length $canontext ? encode_entities($canontext)
: ' ',
- })};
+
})};
$output_wrong= sub { print to_json({
success => 0,
show => $_[0],
$output_wrong= sub { print to_json({
success => 0,
show => $_[0],
- })};
-}
+ })};
+}
+if ($format =~ 'return') {
+ $output= sub { return { Error => '', Results => \@results }; };
+ $output_wrong= sub { return { Error => $_[0] }; };
+}
foreach my $each (split m#[/|,]#, $string) {
$each =~ s/^\s*//; $each =~ s/\s*$//; $each =~ s/\s+/ /g;
foreach my $each (split m#[/|,]#, $string) {
$each =~ s/^\s*//; $each =~ s/\s*$//; $each =~ s/\s+/ /g;
@@
-57,12
+61,12
@@
foreach my $each (split m#[/|,]#, $string) {
}
if (!$results) {
if (!%m) {
}
if (!$results) {
if (!%m) {
- $err->('no island or arch matches "%s"');
+
return
$err->('no island or arch matches "%s"');
} elsif (%m > 5) {
} elsif (%m > 5) {
- $err->(' ');
+
return
$err->(' ');
} else {
} else {
-
$err->('ambiguous island or arch "%s", could be
'.
- join(', ', sort keys %m));
+
return $err->('ambiguous island or arch "%s",
'.
+
' could be '.
join(', ', sort keys %m));
}
}
push @results, $results->[0];
}
}
push @results, $results->[0];
@@
-70,6
+74,6
@@
foreach my $each (split m#[/|,]#, $string) {
$canontext= join ' | ', map { $_->[2] } @results;
$canontext= join ' | ', map { $_->[2] } @results;
-$output->();
+
return
$output->();
</%perl>
</%perl>