X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=scripts%2Frecent.ml;h=5ae5092a49a950e46bc81f4788899effc2749cdd;hb=bfa88724ee152ba00c2b2fca881dd78a6599820a;hp=94afb984fa34b7c10c9f06e0eec7aab49fbd01bb;hpb=da90d13b12890069f0bade66b6676daf80b41bfd;p=cocanwiki.git diff --git a/scripts/recent.ml b/scripts/recent.ml index 94afb98..5ae5092 100644 --- a/scripts/recent.ml +++ b/scripts/recent.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: recent.ml,v 1.10 2005/11/23 11:32:13 rich Exp $ + * $Id: recent.ml,v 1.11 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,22 +32,22 @@ let default_offset = 0 let default_limit = 100 let max_limit = 1000 -let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ = +let run r (q : cgi) dbh hostid _ _ = let template = get_template dbh hostid "recent.html" in (* Count the number of changes. *) let sth = dbh#prepare_cached "select count(*)::int4 from pages where hostid = ?" in - sth#execute [`Int hostid]; + sth#execute [Some hostid]; let count = sth#fetch1int () in (* Get the offset and limit specified, and adjust them so that we will * be displaying some changes. *) let offset = - try int_of_string (q#param "offset") with Not_found -> default_offset in + try Int32.of_string (q#param "offset") with Not_found -> default_offset in let limit = - try int_of_string (q#param "limit") with Not_found -> default_limit in + try Int32.of_string (q#param "limit") with Not_found -> default_limit in let limit = if limit < 1 then 1 @@ -58,15 +58,15 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ = else if offset >= count then max 0 (count - limit) else offset in - template#set "offset" (string_of_int offset); - template#set "last" (string_of_int (min (offset + limit) count - 1)); - template#set "limit" (string_of_int limit); - template#set "count" (string_of_int count); + template#set "offset" (Int32.to_string offset); + template#set "last" (Int32.to_string (min (offset + limit) count - 1)); + template#set "limit" (Int32.to_string limit); + template#set "count" (Int32.to_string count); template#conditional "has_next" (offset + limit < count); - template#set "next_offset" (string_of_int (offset + limit)); + template#set "next_offset" (Int32.to_string (offset + limit)); template#conditional "has_prev" (offset > 0); - template#set "prev_offset" (string_of_int (max 0 (offset - limit))); + template#set "prev_offset" (Int32.to_string (max 0 (offset - limit))); (* Get the actual changes. *) let sth = @@ -77,25 +77,25 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ = where p.hostid = ? order by p.last_modified_date desc offset ? limit ?" in - sth#execute [`Int hostid; `Int offset; `Int limit]; + sth#execute [Some hostid; Some offset; Some limit]; let table = sth#map (function - | [`Int version; `String url; _; `String title; + | [Some version; Some url; _; Some title; `Timestamp last_modified_date; logged_ip; logged_user] -> let date = printable_date_time last_modified_date in let has_logged_ip, logged_ip = match logged_ip with - `Null -> false, "" - | `String ip -> true, ip + None -> false, "" + | Some ip -> true, ip | _ -> assert false in let has_logged_user, logged_user = match logged_user with - `Null -> false, "" - | `String name -> true, name + None -> false, "" + | Some name -> true, name | _ -> assert false in - [ "version", Template.VarString (string_of_int version); + [ "version", Template.VarString (Int32.to_string version); "url", Template.VarString url; "title", Template.VarString title; "last_modified_date", Template.VarString date; @@ -104,20 +104,20 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ = "has_logged_user", Template.VarConditional has_logged_user; "logged_user", Template.VarString logged_user; "is_live", Template.VarConditional true ] - | [`Int version; `Null; `String url; `String title; + | [Some version; None; Some url; Some title; `Timestamp last_modified_date; logged_ip; logged_user] -> let date = printable_date_time last_modified_date in let has_logged_ip, logged_ip = match logged_ip with - `Null -> false, "" - | `String ip -> true, ip + None -> false, "" + | Some ip -> true, ip | _ -> assert false in let has_logged_user, logged_user = match logged_user with - `Null -> false, "" - | `String name -> true, name + None -> false, "" + | Some name -> true, name | _ -> assert false in - [ "version", Template.VarString (string_of_int version); + [ "version", Template.VarString (Int32.to_string version); "url", Template.VarString url; "title", Template.VarString title; "last_modified_date", Template.VarString date;