Add IE6- and IE7-specific stylesheets, only served to broken browsers.
[cocanwiki.git] / scripts / hoststyle.ml
index c3a259c..32d92ec 100644 (file)
@@ -1,7 +1,7 @@
 (* COCANWIKI - a wiki written in Objective CAML.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * Copyright (C) 2004 Merjis Ltd.
- * $Id: hoststyle.ml,v 1.8 2006/03/27 19:10:29 rich Exp $
+ * $Id: hoststyle.ml,v 1.9 2006/12/06 09:46:57 rich Exp $
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,13 +27,35 @@ open Printf
 open Cocanwiki
 open Cocanwiki_template
 
+type stylesheet = Global | Ie6_fixes | Ie7_fixes
+let string_of_stylesheet = function
+  | Global -> "global"
+  | Ie6_fixes -> "ie6_fixes"
+  | Ie7_fixes -> "ie7_fixes"
+let stylesheet_of_string = function
+  | "global" -> Global
+  | "ie6_fixes" -> Ie6_fixes
+  | "ie7_fixes" -> Ie7_fixes
+  | str -> failwith ("stylesheet_of_string: unknown stylesheet: " ^ str)
+
 let run r (q : cgi) dbh hostid _ _ =
-  (* Get the CSS. *)
-  let css = List.hd (PGSQL(dbh) "select css from hosts where id = $hostid") in
+  (* Which stylesheet to serve? *)
+  let css = if q#param_exists "css" then q#param "css" else "global" in
+  let css = stylesheet_of_string css in
+
+  (* Get the CSS itself. *)
+  let css =
+    match css with
+    | Global ->
+       PGSQL(dbh) "select css from hosts where id = $hostid"
+    | Ie6_fixes ->
+       PGSQL(dbh) "select ie6_fixes_css from hosts where id = $hostid"
+    | Ie7_fixes ->
+       PGSQL(dbh) "select ie7_fixes_css from hosts where id = $hostid" in
   let css =
     match css with
-    | None -> ""
-    | Some css -> css in
+    | [Some css] -> css
+    | _ -> "" in
 
   (* It's crucial, for speed of page delivery and rendering, to have
    * an expires header for CSS.  Even though this means that occasionally