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: admin.ml,v 1.8 2006/03/28 16:24:08 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 template = _get_template "admin/admin.html"
33 let run r (q : cgi) dbh _ _ _ =
34 (* Select out the alternative hostnames. *)
35 let hostnames = PGSQL(dbh)
36 "select hs.hostid, hs.name from hostnames hs
37 where not exists (select 1 from hosts
39 and canonical_hostname = hs.name)" in
41 (* Pull out the details of all the wikis on the server. *)
43 "select h.id, h.canonical_hostname,
44 (select count(*) from pages
45 where hostid = h.id and url is not null),
46 (select max(last_modified_date) from pages
47 where hostid = h.id and url is not null)
53 function (id, canonical_hostname,
54 page_count, last_modified_date) ->
55 let page_count = match page_count with
58 let last_modified_date = match last_modified_date with
60 | Some date -> printable_date date in
63 List.filter (fun (i, _) -> i = id) hostnames in
65 List.map (fun (_, hostname) ->
66 [ "hostname", Template.VarString hostname ])
69 [ "id", Template.VarString (Int32.to_string id);
70 "canonical_hostname", Template.VarString canonical_hostname;
71 "page_count", Template.VarString (Int64.to_string page_count);
72 "last_modified_date", Template.VarString last_modified_date;
73 "hostnames", Template.VarTable hostnames ]
76 template#table "hosts" table;