1 (* COCANWIKI - a wiki written in Objective CAML.
2 * Written by Richard W.M. Jones <rich@merjis.com>.
3 * Copyright (C) 2004 Merjis Ltd.
4 * $Id: history.ml,v 1.11 2006/03/27 19:10:29 rich Exp $
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
28 open Cocanwiki_template
31 let run r (q : cgi) dbh hostid _ _ =
32 let template = get_template dbh hostid "history.html" in
34 let page = q#param "page" in
35 let page = if page = "" then "index" else page in
36 template#set "page" page;
39 PGSQL(dbh) "nullable-results"
40 "select p.id, p.url, p.url_deleted, p.title, p.last_modified_date,
42 from pages p left outer join users u on p.logged_user = u.id
43 where p.hostid = $hostid and (p.url = $page or p.url_deleted = $page)
44 order by p.last_modified_date desc" in
49 | (Some version, Some url, _, Some title,
50 Some last_modified_date, logged_ip, logged_user) ->
51 let date = printable_date_time last_modified_date in
52 let has_logged_ip, logged_ip =
55 | Some ip -> true, ip in
56 let has_logged_user, logged_user =
57 match logged_user with
59 | Some name -> true, name in
60 [ "version", Template.VarString (Int32.to_string version);
61 "url", Template.VarString url;
62 "title", Template.VarString title;
63 "last_modified_date", Template.VarString date;
64 "has_logged_ip", Template.VarConditional has_logged_ip;
65 "logged_ip", Template.VarString logged_ip;
66 "has_logged_user", Template.VarConditional has_logged_user;
67 "logged_user", Template.VarString logged_user;
68 "is_live", Template.VarConditional true ]
69 | (Some version, None, Some url, Some title,
70 Some last_modified_date, logged_ip, logged_user) ->
71 let date = printable_date_time last_modified_date in
72 let has_logged_ip, logged_ip =
75 | Some ip -> true, ip in
76 let has_logged_user, logged_user =
77 match logged_user with
79 | Some name -> true, name in
80 [ "version", Template.VarString (Int32.to_string version);
81 "url", Template.VarString url;
82 "title", Template.VarString title;
83 "last_modified_date", Template.VarString date;
84 "has_logged_ip", Template.VarConditional has_logged_ip;
85 "logged_ip", Template.VarString logged_ip;
86 "has_logged_user", Template.VarConditional has_logged_user;
87 "logged_user", Template.VarString logged_user;
88 "is_live", Template.VarConditional false ]
92 template#table "history" table;
97 register_script ~restrict:[CanEdit] run