Moved to merjis/tools/wiki.
[cocanwiki.git] / scripts / edit_page_css_form.ml
1 (* COCANWIKI scripts.
2  * Written by Richard W.M. Jones <rich@merjis.com>.
3  * Copyright (C) 2004 Merjis Ltd.
4  * $Id: edit_page_css_form.ml,v 1.1 2004/09/07 10:14:09 rich Exp $
5  *)
6
7 open Apache
8 open Registry
9 open Cgi
10 open Printf
11
12 open Cocanwiki
13
14 let template = get_template "edit_page_css_form.html"
15
16 let run r (q : cgi) (dbh : Dbi.connection) (hostid, _) _ =
17   let page = q#param "page" in
18
19   let sth = dbh#prepare_cached "select css from pages
20                                  where hostid = ? and url = ?" in
21   sth#execute [`Int hostid; `String page];
22
23   let css =
24     match sth#fetch1 () with
25       | [ `Null ] -> ""
26       | [ `String css ] -> css
27       | _ -> assert false in
28
29   template#set "page" page;
30   template#set "css" css;
31
32   q#template template
33
34 let () =
35   register_script run