All new templates. Site menu displays basically everywhere.
[cocanwiki.git] / scripts / hoststyle.ml
1 (* COCANWIKI scripts.
2  * Written by Richard W.M. Jones <rich@merjis.com>.
3  * Copyright (C) 2004 Merjis Ltd.
4  * $Id: hoststyle.ml,v 1.3 2004/09/09 09:35:33 rich Exp $
5  *)
6
7 open Apache
8 open Registry
9 open Cgi
10 open Printf
11
12 open Cocanwiki
13 open Cocanwiki_template
14
15 let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
16   (* Get the CSS. *)
17   let sth = dbh#prepare_cached "select css from hosts where id = ?" in
18   sth#execute [`Int hostid];
19
20   let css =
21     match sth#fetch1 () with
22         [ `Null ] -> ""
23       | [ `String css ] -> css
24       | _ -> assert false in
25
26   (* It's crucial, for speed of page delivery and rendering, to have
27    * an expires header for CSS.  Even though this means that occasionally
28    * people will need to hit [Shift]+Reload, I'm going to set a
29    * medium-length expiry time on this resource.
30    *)
31   Table.set (Request.headers_out r) "Expires" (Cgi_expires.expires_medium ());
32
33   q#header ~content_type:"text/css" ();
34   print_string r css
35
36 let () =
37   register_script run