X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=scripts%2Flib%2Fcocanwiki_template.ml;h=524255b4c4c6d4fe5ccb2c1091a1a9c25ae6f67d;hb=6ad484dd47c27fd54c2f26fb931ba125bae9abc6;hp=c64784573544cd98009ae1c1b8b253a864189a13;hpb=20923b33c08fccfca617b21935c4a4f6201593f8;p=cocanwiki.git diff --git a/scripts/lib/cocanwiki_template.ml b/scripts/lib/cocanwiki_template.ml index c647845..524255b 100644 --- a/scripts/lib/cocanwiki_template.ml +++ b/scripts/lib/cocanwiki_template.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: cocanwiki_template.ml,v 1.1 2004/10/21 11:42:05 rich Exp $ + * $Id: cocanwiki_template.ml,v 1.2 2004/10/23 10:13:20 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 @@ -81,17 +81,35 @@ let get_template ?page (dbh : Dbi.connection) hostid filename = let template = _get_template filename in (* Get standard fields concerning this host from the database. *) - let sth = dbh#prepare_cached "select theme_css from hosts - where id = ?" in + let sth = + dbh#prepare_cached + "select h.theme_css, p.name, p.url + from hosts h left outer join powered_by p on h.powered_by = p.id + where h.id = ?" in sth#execute [`Int hostid]; - let theme_css = + let theme_css, powered_by_name, powered_by_url = match sth#fetch1 () with - [ `Null ] -> "/_css/standard.css" - | [ `String file ] -> file + | [ a; b; c] -> a, b, c + | _ -> assert false in + let theme_css = + match theme_css with + | `Null -> "/_css/standard.css" + | `String file -> file + | _ -> assert false in + let powered_by_name, powered_by_url = + match powered_by_name, powered_by_url with + | `Null, `Null -> + let url = "http://sandbox.merjis.com/" in + let name = Cocanwiki_version.package ^ " " ^ + Cocanwiki_version.version in + name, url + | `String name, `String url -> name, url | _ -> assert false in template#set "theme_css" theme_css; + template#set "powered_by_name" powered_by_name; + template#set "powered_by_url" powered_by_url; (* Site menu. *) let sth = dbh#prepare_cached "select url, label, ordering from sitemenu