(* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. * $Id: diff.ml,v 1.3 2004/09/07 14:58:34 rich Exp $ *) open Apache open Registry open Cgi open Printf open Cocanwiki open Cocanwiki_template open Cocanwiki_diff let template = get_template "diff.html" let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ = let page = q#param "page" in let page = if page = "" then "index" else page in (* "version" parameter, required, is the newest version. If the * "old_version" parameter is given then we compare against that. * Otherwise we look in the database to find the version of this * page previous to "version", and use that as "old_version". If * there is no older version in the database, then we compare against * version '0' which means a blank page. * * NB. In case you hadn't worked it out yet, version numbers are * page.ids. *) let version = int_of_string (q#param "version") in let diff, old_version = try let old_version = int_of_string (q#param "old_version") in get_diff dbh hostid page ~old_version ~version () with Not_found -> get_diff dbh hostid page ~version () in template#set "version" (string_of_int version); template#set "old_version" (string_of_int old_version); template#set "page" page; template#set "diff" diff; q#template template let () = register_script run