initial opensearch implementation
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 7 Jun 2005 18:40:49 +0000 (18:40 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 7 Jun 2005 18:40:49 +0000 (18:40 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@769 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/extras/opensearch.ttk [new file with mode: 0644]
Open-ILS/src/extras/opensearch.xml [new file with mode: 0644]

diff --git a/Open-ILS/src/extras/opensearch.ttk b/Open-ILS/src/extras/opensearch.ttk
new file mode 100644 (file)
index 0000000..db2c1f6
--- /dev/null
@@ -0,0 +1,93 @@
+[%-
+USE CGI;
+USE WebSession;
+WebSession.bootstrap();
+
+rank_threshold = 5000;
+
+itempage = CGI.param('itempage');
+
+#type,string,location,depth
+count_meth = 'open-ils.search.biblio.class.count';
+
+#type,string,location,depth,limit,offset
+search_meth = 'open-ils.search.biblio.class';
+
+session = WebSession.init_app_session('open-ils.search');
+
+type = CGI.param('mr_search_type');
+string = CGI.param('mr_search_query');
+location = CGI.param('mr_search_location');
+depth = CGI.param('mr_search_depth');
+limit = pagesize;
+offset = itempage * pagesize - 1;
+
+pagesize = 10;
+IF CGI.param('pagesize');
+       pagesize = CGI.param('pagesize');
+END;
+
+req = session.request(count_meth, type, string, location, depth);
+req.wait_complete();
+
+count = req.recv();
+req.finish;
+
+IF count > rank_threshold;
+       search_meth = 'open-ils.search.biblio.class.unorded';
+END;
+
+req = session.request(search_meth, type, string, location, depth, limit, offset);
+req.wait_complete();
+
+list = req.recv();
+req.finish;
+
+-%]
+<?xml version="1.0"?>
+<rss version="2.0" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">
+    <channel>
+      <title>Pines Catalogue Search: [% string %] </title>
+      <link>http://http://gapines.org/opensearch.ttk/?target=mr_result&amp;mr_search_type=[% type %]&amp;mr_search_query=[% string %]&amp;itempage=[% itempage %]&amp;mr_search_depth=[% depth %]&amp;mr_search_location=[% location %]</link>
+      <description>Search results for "[% string %]" at gapines.org</description>
+      <language>en-us</language>
+      <copyright>&amp;copy;2004-2005, Georga Public Library Service.</copyright>
+      <openSearch:totalResults>[% count %]</openSearch:totalResults>
+      <openSearch:startIndex>[% offset + 1 %]</openSearch:startIndex>
+      <openSearch:itemsPerPage>[% pagesize %]</openSearch:itemsPerPage>
+[%-
+
+FOREACH mr_id IN list;
+       req = session.request('open-ils.search.biblio.metarecord.mods_slim.retrieve', mr_id);
+       req.wait_complete();
+
+       mods = req.recv();
+       req.finish;
+
+-%]
+      <item>
+        <title>[% mods.title() %]</title>
+        <link>http://gapines.org/opac/?target=record_result&page=0&mrid=[% mr_id %]&hits_per_page=10</link>
+        <description>
+               &lt;b&gt;Author:&lt;/b&gt; [% mods.author() %]&lt;br&gt;
+               &lt;b&gt;Subjects:&lt;/b&gt; 
+[%-
+       FOREACH sub IN mods.subject();
+               IF loop.count() > 5;
+                       ', ...';
+                       LAST;
+               END;
+               IF loop.index;
+                       ', ';
+               END;
+               sub.list.0;
+       END;
+-%]
+        </description>
+      </item>
+[%-
+
+END;
+
+ -%]
+</rss>
diff --git a/Open-ILS/src/extras/opensearch.xml b/Open-ILS/src/extras/opensearch.xml
new file mode 100644 (file)
index 0000000..89835e7
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearchdescription/1.0/">
+  <Url>http://gapines.org/opensearch.ttk/?target=mr_result&amp;mr_search_type=keyword&amp;mr_search_query={searchTerms}&amp;itempage={startPage}&amp;mr_search_depth=0&amp;mr_search_location=1</Url>
+  <Format>http://a9.com/-/spec/opensearchrss/1.0/</Format>
+  <ShortName>Pines</ShortName>
+  <LongName>Pines Consortium Catalogue</LongName>
+  <Description>Search for books in Pines.</Description>
+  <Tags>book library research</Tags>
+  <Image>http://gapines.org/images/small_logo.jpg</Image>
+  <SampleSearch>harry potter</SampleSearch>
+  <Developer>GPLS</Developer>
+  <Contact>mrylander@gmail.com</Contact>
+  <Attribution>Product and search data &amp;copy; 2005, Georgia Public Library Service, All Rights Reserved</Attribution>
+  <SyndicationRight>open</SyndicationRight>
+  <AdultContent>false</AdultContent>
+</OpenSearchDescription>