Probably about 1/2 way through now ...
[cocanwiki.git] / scripts / search.ml
index 456c0e9..2d449b8 100644 (file)
@@ -1,7 +1,7 @@
 (* COCANWIKI - a wiki written in Objective CAML.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * Copyright (C) 2004 Merjis Ltd.
- * $Id: search.ml,v 1.8 2004/11/02 22:26:36 rich Exp $
+ * $Id: search.ml,v 1.9 2006/03/27 18:09:46 rich Exp $
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@ open Cocanwiki_date
 
 let split_words = Pcre.regexp "\\W+"
 
-let run r (q : cgi) (dbh : Dbi.connection) hostid host user =
+let run r (q : cgi) dbh hostid host user =
   let template = get_template dbh hostid "search.html" in
 
   template#set "canonical_hostname" host.canonical_hostname;
@@ -78,15 +78,15 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid host user =
               and redirect is null
                and title_description_fti @@ to_tsquery (?, ?)
              order by exact desc, last_modified_date desc, title") in
-      sth#execute [`String query;
-                  `Int hostid; `String "default"; `String tsquery];
+      sth#execute [Some query;
+                  Some hostid; Some "default"; Some tsquery];
 
       let titles =
        sth#map (function
-                  | [_; `String url; `Null; `String title;
+                  | [_; Some url; None; Some title;
                      `Timestamp last_modified; _] ->
                       url, title, None, last_modified
-                  | [`Int version; `Null; `String url; `String title;
+                  | [Some version; None; Some url; Some title;
                      `Timestamp last_modified; _] ->
                       url, title, Some version, last_modified
                   | _ -> assert false) in
@@ -107,15 +107,15 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid host user =
                and c.content_fti @@ to_tsquery (?, ?)
              order by p.last_modified_date desc, p.title
              limit 50") in
-      sth#execute [`Int hostid; `String "default"; `String tsquery];
+      sth#execute [Some hostid; Some "default"; Some tsquery];
 
       let contents =
        sth#map (function
-                  | [`Int contentid; _; `String url; `Null;
-                     `String title; `Timestamp last_modified] ->
+                  | [Some contentid; _; Some url; None;
+                     Some title; `Timestamp last_modified] ->
                       contentid, url, title, None, last_modified
-                  | [`Int contentid; `Int version; `Null; `String url;
-                     `String title; `Timestamp last_modified] ->
+                  | [Some contentid; Some version; None; Some url;
+                     Some title; `Timestamp last_modified] ->
                       contentid, url, title, Some version, last_modified
                   | _ -> assert false) in
 
@@ -132,11 +132,11 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid host user =
              ("select id, sectionname, content from contents
                  where id in " ^ qs) in
          sth#execute
-           (List.map (fun (contentid, _,_,_,_) -> `Int contentid) contents);
+           (List.map (fun (contentid, _,_,_,_) -> Some contentid) contents);
          sth#map (function
-                    | [ `Int id; `Null; `String content ] ->
+                    | [ Some id; None; Some content ] ->
                         id, (None, content)
-                    | [ `Int id; `String sectionname; `String content ] ->
+                    | [ Some id; Some sectionname; Some content ] ->
                         id, (Some sectionname, content)
                     | _ -> assert false)
        ) in
@@ -152,7 +152,7 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid host user =
                    [ "url", Template.VarString url;
                      "title", Template.VarString title;
                      "have_version", Template.VarConditional have_version;
-                     "version", Template.VarString (string_of_int version);
+                     "version", Template.VarString (Int32.to_string version);
                      "last_modified", Template.VarString last_modified ]
                 ) titles in
       template#table "titles" table;
@@ -178,7 +178,7 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid host user =
             [ "url", Template.VarString url;
               "title", Template.VarString title;
               "have_version", Template.VarConditional have_version;
-              "version", Template.VarString (string_of_int version);
+              "version", Template.VarString (Int32.to_string version);
               "have_sectionname", Template.VarConditional have_sectionname;
               "sectionname", Template.VarString sectionname;
               "linkname", Template.VarString linkname;