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: host.ml,v 1.10 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/host.html"
33 let run r (q : cgi) dbh _ _ _ =
34 let hostid = Int32.of_string (q#param "hostid") in
35 template#set "id" (Int32.to_string hostid);
37 (* Pull out some overall details for this host. *)
39 "select h.canonical_hostname, h.css is not null,
40 (select count(*) from pages
41 where hostid = h.id and url is not null),
42 (select count(*) from pages
44 (select max(last_modified_date) from pages
45 where hostid = h.id and url is not null),
46 (select min(last_modified_date) from pages
47 where hostid = h.id and url is not null)
49 where h.id = $hostid" in
51 let canonical_hostname, has_css, page_count, total_count,
52 last_modified_date, creation_date =
54 | [ canonical_hostname, Some has_css,
57 last_modified_date, creation_date ] ->
58 let page_count = match page_count with
61 let total_count = match total_count with
64 let last_modified_date = match last_modified_date with
66 | Some t -> printable_date t in
67 let creation_date = match creation_date with
69 | Some t -> printable_date t in
70 canonical_hostname, has_css, page_count, total_count,
71 last_modified_date, creation_date
72 | _ -> assert false in
74 template#set "canonical_hostname" canonical_hostname;
75 template#conditional "has_css" has_css;
76 template#set "page_count" (Int64.to_string page_count);
77 template#set "total_count" (Int64.to_string total_count);
78 template#set "last_modified_date" last_modified_date;
79 template#set "creation_date" creation_date;
81 (* Pull out any aliases. *)
83 "select name from hostnames
84 where hostid = $hostid and name <> $canonical_hostname" in
85 let table = List.map (
87 [ "hostname", Template.VarString hostname ]
89 template#table "hostnames" table;