--- /dev/null
+%# $Id: all.html,v 1.1 2006-09-15 16:51:50 mike Exp $
+<& /chrome/layout.mc, %ARGS, title => "Test all databases",
+ component => "/details/all.mc" &>
--- /dev/null
+%# $Id: all.mc,v 1.1 2006-09-15 16:51:51 mike Exp $
+<%perl>
+print "IRSpy version $ZOOM::IRSpy::VERSION<br/>\n";
+my $spy = new ZOOM::IRSpy("localhost:1313/IR-Explain---1");
+if (1) {
+ # Testing all databases would take much too long for testing
+ my @targets = qw(bagel.indexdata.dk/gils z3950.loc.gov:7090/Voyager);
+ $spy->targets(join(" ", @targets));
+}
+$spy->initialise();
+my $res = $spy->check();
+if ($res == 0) {
+ print "All tests were run\n";
+} else {
+ print "Some tests were skipped\n";
+}
+</%perl>
--- /dev/null
+%# $Id: find.mc,v 1.1 2006-09-15 16:51:51 mike Exp $
+% if ($r->param("_search")) {
+% $m->comp("found.mc");
+% } else {
+ <p>
+ Choose one or more critera by which to search for registered
+ databases, then press the <b>Search</b> button.
+ </p>
+ <form>
+ <table class="searchform">
+ <tr>
+ <th>(Anywhere)</th>
+ <td><input type="text" name="cql.anywhere" size="40"/></td>
+ </tr>
+ <tr><td colspan="2"> </td></tr>
+ <tr>
+ <th>Protocol</th>
+ <td>
+ <select name="net.protocol" size="1">
+ <option value="">[No preference]</option>
+ <option value="z39.50">Z39.50</option>
+ <option value="sru">SRU</option>
+ <option value="srw">SRW</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th>Version</th>
+ <td><input type="text" name="net.version" size="5"/></td>
+ </tr>
+ <tr>
+ <th>Method</th>
+ <td>
+ <select name="net.method" size="1">
+ <option value="">[No preference]</option>
+ <option value="get">GET</option>
+ <option value="post">POST</option>
+ </select>
+ </td>
+ </tr>
+ <tr><td colspan="2"> </td></tr>
+ <tr>
+ <th>Host</th>
+ <td><input type="text" name="net.host" size="40"/></td>
+ </tr>
+ <tr>
+ <th>Port</th>
+ <td><input type="text" name="net.port" size="5"/></td>
+ </tr>
+ <tr>
+ <th>Database</th>
+ <td><input type="text" name="net.path" size="20"/></td>
+ </tr>
+ <tr><td colspan="2"> </td></tr>
+ <tr>
+ <th>Title</th>
+ <td><input type="text" name="dc.title" size="40"/></td>
+ </tr>
+ <tr>
+ <th>Creator</th>
+ <td><input type="text" name="dc.creator" size="40"/></td>
+ </tr>
+ <tr><td colspan="2"> </td></tr>
+ <tr>
+ <th/>
+ <th><input type="submit" name="_search" value="Search"/></th>
+ </tr>
+ </table>
+ <p>
+ <small>
+ Show
+ <input type="text" name="_count" size="4" value="10"/>
+ records, skipping the first
+ <input type="text" name="_skip" size="4" value="0"/>
+ </small>
+ </p>
+ </form>
+% }
--- /dev/null
+%# $Id: found.mc,v 1.1 2006-09-15 16:51:51 mike Exp $
+<%once>
+use XML::LibXML;
+use XML::LibXML::XPathContext;
+</%once>
+<%perl>
+my $query = "";
+foreach my $key ($r->param()) {
+ next if $key =~ /^_/;
+ my $val = $r->param($key);
+ next if $val eq "";
+ $query .= " and " if $query ne "";
+ $query .= "$key = ($val)";
+}
+
+### We can think about keeping the Connection object open to re-use
+# for multiple requests, but that may not get us much. Same applies
+# for the XML parser.
+my $conn = new ZOOM::Connection("localhost:1313/IR-Explain---1");
+$conn->option(elementSetName => "zeerex");
+my $parser = new XML::LibXML();
+
+my $rs = $conn->search(new ZOOM::Query::CQL($query));
+my $n = $rs->size();
+
+my $skip = $r->param("_skip") || 0;
+my $count = $r->param("_count") || 10;
+
+my $first = $skip+1;
+my $last = $first+$count-1;
+$last = $n if $last > $n;
+</%perl>
+ <p>
+ <b><% $query %></b>
+ <br/>
+% if ($n == 0) {
+ No matches
+% } elsif ($first > $n) {
+ Past end of <% $n %> records
+% } else {
+ Records <% $first %> to <% $last %> of <% $n %>
+% }
+ </p>
+% if ($n > 0 && $first <= $n) {
+ <table width="100%">
+ <tr class="thleft">
+ <th>#</th>
+ <th>Host</th>
+ <th>Port</th>
+ <th>DB</th>
+ </tr>
+% foreach my $i ($first .. $last) {
+<%perl>
+my $rec = $rs->record($i-1);
+my $xml = $rec->render();
+my $doc = $parser->parse_string($xml);
+my $root = $doc->getDocumentElement();
+my $xc = XML::LibXML::XPathContext->new($root);
+$xc->registerNs(e => 'http://explain.z3950.org/dtd/2.0/');
+my $host = $xc->find("e:serverInfo/e:host");
+my $port = $xc->find("e:serverInfo/e:port");
+my $db = $xc->find("e:serverInfo/e:database");
+</%perl>
+ <tr style="background: <% ($i % 2) ? '#ffffc0' : 'white' %>">
+ <td><% $i %></td>
+ <td><% $host %></td>
+ <td><% $port %></td>
+ <td><% $db %></td>
+ </tr>
+%}
+ </table>
+% }
--- /dev/null
+%# $Id: find.html,v 1.1 2006-09-15 16:51:50 mike Exp $
+<& /chrome/layout.mc, %ARGS, title => "Find a database",
+ component => "/details/find.mc" &>