X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=scripts%2Fsearch.ml;h=2d449b88424a807ce190603fee5be979c1f13b4c;hb=bfa88724ee152ba00c2b2fca881dd78a6599820a;hp=456c0e9dc0c2114ce08733ad50feb35cb78cd20c;hpb=d303f75eed3a09bbe2516d9a2a9a4aa9b862ceb3;p=cocanwiki.git diff --git a/scripts/search.ml b/scripts/search.ml index 456c0e9..2d449b8 100644 --- a/scripts/search.ml +++ b/scripts/search.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * 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;