cocanwiki_images.cmi
cocanwiki_images.cmx: cocanwiki_files.cmx cocanwiki_strings.cmx \
cocanwiki_images.cmi
-cocanwiki_ok.cmo: cocanwiki_template.cmo
+cocanwiki_ok.cmo: cocanwiki_template.cmi
cocanwiki_ok.cmx: cocanwiki_template.cmx
-cocanwiki_template.cmo: cocanwiki_files.cmo
-cocanwiki_template.cmx: cocanwiki_files.cmx
+cocanwiki_template.cmo: cocanwiki_files.cmo cocanwiki_template.cmi
+cocanwiki_template.cmx: cocanwiki_files.cmx cocanwiki_template.cmi
create.cmo: cocanwiki.cmo cocanwiki_emailnotify.cmo cocanwiki_ok.cmo \
wikilib.cmi
create.cmx: cocanwiki.cmx cocanwiki_emailnotify.cmx cocanwiki_ok.cmx \
wikilib.cmx
-create_form.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_template.cmo \
+create_form.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_template.cmi \
wikilib.cmi
create_form.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_template.cmx \
wikilib.cmx
delete_file.cmo: cocanwiki.cmo cocanwiki_emailnotify.cmo cocanwiki_ok.cmo
delete_file.cmx: cocanwiki.cmx cocanwiki_emailnotify.cmx cocanwiki_ok.cmx
-delete_file_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+delete_file_form.cmo: cocanwiki.cmo cocanwiki_template.cmi
delete_file_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
delete_image.cmo: cocanwiki.cmo cocanwiki_emailnotify.cmo cocanwiki_ok.cmo
delete_image.cmx: cocanwiki.cmx cocanwiki_emailnotify.cmx cocanwiki_ok.cmx
-delete_image_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+delete_image_form.cmo: cocanwiki.cmo cocanwiki_template.cmi
delete_image_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
-diff.cmo: cocanwiki.cmo cocanwiki_diff.cmo cocanwiki_template.cmo
+diff.cmo: cocanwiki.cmo cocanwiki_diff.cmo cocanwiki_template.cmi
diff.cmx: cocanwiki.cmx cocanwiki_diff.cmx cocanwiki_template.cmx
edit.cmo: cocanwiki.cmo cocanwiki_diff.cmo cocanwiki_emailnotify.cmo \
- cocanwiki_ok.cmo cocanwiki_strings.cmo cocanwiki_template.cmo
+ cocanwiki_ok.cmo cocanwiki_strings.cmo cocanwiki_template.cmi
edit.cmx: cocanwiki.cmx cocanwiki_diff.cmx cocanwiki_emailnotify.cmx \
cocanwiki_ok.cmx cocanwiki_strings.cmx cocanwiki_template.cmx
edit_page_css.cmo: cocanwiki.cmo cocanwiki_diff.cmo cocanwiki_emailnotify.cmo \
cocanwiki_ok.cmo cocanwiki_strings.cmo
edit_page_css.cmx: cocanwiki.cmx cocanwiki_diff.cmx cocanwiki_emailnotify.cmx \
cocanwiki_ok.cmx cocanwiki_strings.cmx
-edit_page_css_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+edit_page_css_form.cmo: cocanwiki.cmo cocanwiki_template.cmi
edit_page_css_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
+edit_sitemenu.cmo: cocanwiki.cmo cocanwiki_emailnotify.cmo cocanwiki_ok.cmo \
+ cocanwiki_strings.cmo cocanwiki_template.cmi
+edit_sitemenu.cmx: cocanwiki.cmx cocanwiki_emailnotify.cmx cocanwiki_ok.cmx \
+ cocanwiki_strings.cmx cocanwiki_template.cmx
edit_user.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_strings.cmo
edit_user.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_strings.cmx
-edit_user_form.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_template.cmo
+edit_user_form.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_template.cmi
edit_user_form.cmx: cocanwiki.cmx cocanwiki_date.cmx cocanwiki_template.cmx
file.cmo: cgi_expires.cmo cocanwiki.cmo
file.cmx: cgi_expires.cmx cocanwiki.cmx
-files.cmo: cocanwiki.cmo cocanwiki_template.cmo
+files.cmo: cocanwiki.cmo cocanwiki_template.cmi
files.cmx: cocanwiki.cmx cocanwiki_template.cmx
forgot_password.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_strings.cmo
forgot_password.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_strings.cmx
-forgot_password_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+forgot_password_form.cmo: cocanwiki.cmo cocanwiki_template.cmi
forgot_password_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
-history.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_template.cmo
+history.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_template.cmi
history.cmx: cocanwiki.cmx cocanwiki_date.cmx cocanwiki_template.cmx
-hoststyle.cmo: cgi_expires.cmo cocanwiki.cmo cocanwiki_template.cmo
+hoststyle.cmo: cgi_expires.cmo cocanwiki.cmo cocanwiki_template.cmi
hoststyle.cmx: cgi_expires.cmx cocanwiki.cmx cocanwiki_template.cmx
image.cmo: cgi_expires.cmo cocanwiki.cmo
image.cmx: cgi_expires.cmx cocanwiki.cmx
-images.cmo: cocanwiki.cmo cocanwiki_template.cmo
+images.cmo: cocanwiki.cmo cocanwiki_template.cmi
images.cmx: cocanwiki.cmx cocanwiki_template.cmx
login.cmo: cocanwiki.cmo cocanwiki_ok.cmo
login.cmx: cocanwiki.cmx cocanwiki_ok.cmx
-login_form.cmo: cocanwiki.cmo cocanwiki_strings.cmo cocanwiki_template.cmo
+login_form.cmo: cocanwiki.cmo cocanwiki_strings.cmo cocanwiki_template.cmi
login_form.cmx: cocanwiki.cmx cocanwiki_strings.cmx cocanwiki_template.cmx
logout.cmo: cocanwiki.cmo cocanwiki_ok.cmo
logout.cmx: cocanwiki.cmx cocanwiki_ok.cmx
page.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_ok.cmo \
- cocanwiki_template.cmo cocanwiki_version.cmo wikilib.cmi
+ cocanwiki_template.cmi cocanwiki_version.cmo wikilib.cmi
page.cmx: cocanwiki.cmx cocanwiki_date.cmx cocanwiki_ok.cmx \
cocanwiki_template.cmx cocanwiki_version.cmx wikilib.cmx
pagestyle.cmo: cgi_expires.cmo cocanwiki.cmo
pagestyle.cmx: cgi_expires.cmx cocanwiki.cmx
preview.cmo: cocanwiki.cmo wikilib.cmi
preview.cmx: cocanwiki.cmx wikilib.cmx
-recent.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_template.cmo
+recent.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_template.cmi
recent.cmx: cocanwiki.cmx cocanwiki_date.cmx cocanwiki_template.cmx
restore.cmo: cocanwiki.cmo cocanwiki_diff.cmo cocanwiki_emailnotify.cmo \
cocanwiki_ok.cmo
restore.cmx: cocanwiki.cmx cocanwiki_diff.cmx cocanwiki_emailnotify.cmx \
cocanwiki_ok.cmx
restore_form.cmo: cocanwiki.cmo cocanwiki_diff.cmo cocanwiki_ok.cmo \
- cocanwiki_template.cmo
+ cocanwiki_template.cmi
restore_form.cmx: cocanwiki.cmx cocanwiki_diff.cmx cocanwiki_ok.cmx \
cocanwiki_template.cmx
search.cmo: cocanwiki.cmo
signup.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_strings.cmo
signup.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_strings.cmx
sitemap.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_strings.cmo \
- cocanwiki_template.cmo wikilib.cmi
+ cocanwiki_template.cmi wikilib.cmi
sitemap.cmx: cocanwiki.cmx cocanwiki_date.cmx cocanwiki_strings.cmx \
cocanwiki_template.cmx wikilib.cmx
-undelete_file.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_template.cmo
+undelete_file.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_template.cmi
undelete_file.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_template.cmx
-undelete_file_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+undelete_file_form.cmo: cocanwiki.cmo cocanwiki_template.cmi
undelete_file_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
-undelete_image.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_template.cmo
+undelete_image.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_template.cmi
undelete_image.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_template.cmx
-undelete_image_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+undelete_image_form.cmo: cocanwiki.cmo cocanwiki_template.cmi
undelete_image_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
upload_file.cmo: cocanwiki.cmo cocanwiki_emailnotify.cmo cocanwiki_images.cmi \
- cocanwiki_ok.cmo cocanwiki_template.cmo
+ cocanwiki_ok.cmo cocanwiki_template.cmi
upload_file.cmx: cocanwiki.cmx cocanwiki_emailnotify.cmx cocanwiki_images.cmx \
cocanwiki_ok.cmx cocanwiki_template.cmx
-upload_file_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+upload_file_form.cmo: cocanwiki.cmo cocanwiki_template.cmi
upload_file_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
upload_image.cmo: cocanwiki.cmo cocanwiki_emailnotify.cmo \
cocanwiki_images.cmi cocanwiki_ok.cmo
upload_image.cmx: cocanwiki.cmx cocanwiki_emailnotify.cmx \
cocanwiki_images.cmx cocanwiki_ok.cmx
-upload_image_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+upload_image_form.cmo: cocanwiki.cmo cocanwiki_template.cmi
upload_image_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
-users.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_template.cmo
+users.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_template.cmi
users.cmx: cocanwiki.cmx cocanwiki_date.cmx cocanwiki_template.cmx
wikilib.cmo: wikilib.cmi
wikilib.cmx: wikilib.cmi
-admin/admin.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_template.cmo
+admin/admin.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_template.cmi
admin/admin.cmx: cocanwiki.cmx cocanwiki_date.cmx cocanwiki_template.cmx
admin/create_host.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_strings.cmo
admin/create_host.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_strings.cmx
-admin/create_host_form.cmo: cocanwiki_template.cmo
+admin/create_host_form.cmo: cocanwiki_template.cmi
admin/create_host_form.cmx: cocanwiki_template.cmx
admin/edit_emails.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_strings.cmo
admin/edit_emails.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_strings.cmx
-admin/edit_emails_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+admin/edit_emails_form.cmo: cocanwiki.cmo cocanwiki_template.cmi
admin/edit_emails_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
admin/edit_host_css.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_strings.cmo
admin/edit_host_css.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_strings.cmx
-admin/edit_host_css_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+admin/edit_host_css_form.cmo: cocanwiki.cmo cocanwiki_template.cmi
admin/edit_host_css_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
admin/edit_hostnames.cmo: cocanwiki.cmo cocanwiki_ok.cmo \
cocanwiki_strings.cmo
admin/edit_hostnames.cmx: cocanwiki.cmx cocanwiki_ok.cmx \
cocanwiki_strings.cmx
-admin/edit_hostnames_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+admin/edit_hostnames_form.cmo: cocanwiki.cmo cocanwiki_template.cmi
admin/edit_hostnames_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
-admin/host.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_template.cmo
+admin/host.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_template.cmi
admin/host.cmx: cocanwiki.cmx cocanwiki_date.cmx cocanwiki_template.cmx
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: admin.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
+ * $Id: admin.ml,v 1.4 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki_template
open Cocanwiki_date
-let template = get_template "admin/admin.html"
+let template = _get_template "admin/admin.html"
let run r (q : cgi) (dbh : Dbi.connection) _ _ =
(* Select out the alternative hostnames. *)
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: create_host_form.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: create_host_form.ml,v 1.3 2004/09/08 15:46:53 rich Exp $
*
* NB. Because there might not be any hosts existing when this Wiki
* is created, this is not a normal Cocanwiki.register_script script.
open Cgi
open Printf
-let template = Cocanwiki_template.get_template "admin/create_host_form.html"
+let template = Cocanwiki_template._get_template "admin/create_host_form.html"
let run r =
let q = new cgi r in
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit_emails_form.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: edit_emails_form.ml,v 1.3 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki
open Cocanwiki_template
-let template = get_template "admin/edit_emails_form.html"
+let template = _get_template "admin/edit_emails_form.html"
let run r (q : cgi) (dbh : Dbi.connection) _ _ =
let hostid = int_of_string (q#param "hostid") in
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit_host_css_form.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: edit_host_css_form.ml,v 1.3 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki
open Cocanwiki_template
-let template = get_template "admin/edit_host_css_form.html"
+let template = _get_template "admin/edit_host_css_form.html"
let run r (q : cgi) (dbh : Dbi.connection) _ _ =
let hostid = int_of_string (q#param "hostid") in
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit_hostnames_form.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: edit_hostnames_form.ml,v 1.3 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki
open Cocanwiki_template
-let template = get_template "admin/edit_hostnames_form.html"
+let template = _get_template "admin/edit_hostnames_form.html"
let run r (q : cgi) (dbh : Dbi.connection) _ _ =
let hostid = int_of_string (q#param "hostid") in
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: host.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
+ * $Id: host.ml,v 1.4 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki_template
open Cocanwiki_date
-let template = get_template "admin/host.html"
+let template = _get_template "admin/host.html"
let run r (q : cgi) (dbh : Dbi.connection) _ _ =
let hostid = int_of_string (q#param "hostid") in
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_ok.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
+ * $Id: cocanwiki_ok.ml,v 1.4 2004/09/08 15:46:52 rich Exp $
*)
open Apache
(* Override StdPages.ok and StdPages.error with out our versions.
* Also have some standard buttons around.
*)
-let ok_error_template = get_template "ok_error.html"
+let ok_error_template = _get_template "ok_error.html"
let error ?cookie ?cookies ?title ?(icon = "/_graphics/error.png")
?icon_alt ?back_button ?close_button q message =
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_template.ml,v 1.2 2004/09/07 14:58:34 rich Exp $
+ * $Id: cocanwiki_template.ml,v 1.3 2004/09/08 15:46:52 rich Exp $
+ *
+ * This module wraps around the Template library. It provides caching
+ * of templates and fills in standard fields on a host-specific basis.
+ *
*)
-open Apache
-open Cgi
+open Unix
open Cocanwiki_files
-(* Wrapper around [Cgi.Template.template] function which loads the
- * template from a pre-defined path and sets up some default variables.
- *)
-let get_template =
- let path =
+let base =
+ let base =
try Sys.getenv "COCANWIKI_TEMPLATES"
with Not_found -> "/usr/share/cocanwiki/templates" in
let is_dir path =
try (Unix.stat path).Unix.st_kind = Unix.S_DIR
with Unix.Unix_error _ -> false in
- if not (is_dir path) then
+ if not (is_dir base) then
failwith ("environment variable $COCANWIKI_TEMPLATES " ^
"must be set to point to my 'templates' directory " ^
"(see README file for more details)");
- fun filename ->
- Template.template (path // filename)
+ base
+
+(* Cache of precompiled templates, arranged by full path. *)
+let cache = Hashtbl.create 32
+
+let _get_template filename =
+ let path = base // filename in
+ let stat = Unix.stat path in
+ let mtime = stat.st_mtime in
+
+ try
+ let template, old_mtime = Hashtbl.find cache path in
+ if old_mtime < mtime then (
+ (* The template has changed on disk since it was compiled. Reload. *)
+ let template = Template.template path in
+ Hashtbl.replace cache path (template, mtime);
+ template
+ ) else
+ template
+ with
+ Not_found ->
+ (* Template not seen before, so load it. *)
+ let template = Template.template path in
+ Hashtbl.replace cache path (template, mtime);
+ template
+
+let get_template (dbh : Dbi.connection) hostid filename =
+ let template = _get_template filename in
+
+ (* Get standard fields concerning this host from the database. *)
+ (* XXX *)
+
+ template
--- /dev/null
+(* COCANWIKI scripts.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * Copyright (C) 2004 Merjis Ltd.
+ * $Id: cocanwiki_template.mli,v 1.1 2004/09/08 15:46:52 rich Exp $
+ *)
+
+(** Get template from filename, with no host-specific substitutions. *)
+val _get_template : string -> Template.template
+
+(** Get template from filename, with host-specific substitutions. *)
+val get_template : Dbi.connection -> int -> string -> Template.template
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: create_form.ml,v 1.3 2004/09/08 09:54:28 rich Exp $
+ * $Id: create_form.ml,v 1.4 2004/09/08 15:46:52 rich Exp $
*)
open Apache
open Cocanwiki_template
open Cocanwiki_ok
-let template = get_template "create_form.html"
-
let run r (q : cgi) (dbh : Dbi.connection) (hostid, hostname, _) _ =
+ let template = get_template dbh hostid "create_form.html" in
+
(* Get the page title. *)
let title = q#param "title" in
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: delete_file_form.ml,v 1.4 2004/09/08 09:54:28 rich Exp $
+ * $Id: delete_file_form.ml,v 1.5 2004/09/08 15:46:52 rich Exp $
*)
open Apache
open Cocanwiki
open Cocanwiki_template
-let template = get_template "delete_file_form.html"
-
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
+ let template = get_template dbh hostid "delete_file_form.html" in
+
let id = int_of_string (q#param "id") in
let sth = dbh#prepare_cached "select name from files
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: delete_image_form.ml,v 1.4 2004/09/08 09:54:28 rich Exp $
+ * $Id: delete_image_form.ml,v 1.5 2004/09/08 15:46:52 rich Exp $
*)
open Apache
open Cocanwiki
open Cocanwiki_template
-let template = get_template "delete_image_form.html"
-
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
+ let template = get_template dbh hostid "delete_image_form.html" in
+
let id = int_of_string (q#param "id") in
let sth = dbh#prepare_cached "select name, width, height, alt
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: diff.ml,v 1.4 2004/09/08 09:54:28 rich Exp $
+ * $Id: diff.ml,v 1.5 2004/09/08 15:46:52 rich Exp $
*)
open Apache
open Cocanwiki_template
open Cocanwiki_diff
-let template = get_template "diff.html"
-
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
+ let template = get_template dbh hostid "diff.html" in
+
let page = q#param "page" in
let page = if page = "" then "index" else page in
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit.ml,v 1.5 2004/09/08 13:09:05 rich Exp $
+ * $Id: edit.ml,v 1.6 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki_diff
open Cocanwiki_strings
-let template = get_template "edit.html"
-let template_conflict = get_template "edit_conflict.html"
-
(* We keep an "internal model" of the page - see build_internal_model ()
* below.
*)
}
let run r (q : cgi) (dbh : Dbi.connection) (hostid, hostname, _) _ =
+ let template = get_template dbh hostid "edit.html" in
+ let template_conflict = get_template dbh hostid "edit_conflict.html" in
+
(* Workaround bugs in IE, specifically lack of support for <button>
* elements.
*)
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit_page_css_form.ml,v 1.3 2004/09/08 09:54:28 rich Exp $
+ * $Id: edit_page_css_form.ml,v 1.4 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki
open Cocanwiki_template
-let template = get_template "edit_page_css_form.html"
-
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
+ let template = get_template dbh hostid "edit_page_css_form.html" in
+
let page = q#param "page" in
let sth = dbh#prepare_cached "select css from pages
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit_sitemenu.ml,v 1.1 2004/09/08 14:47:47 rich Exp $
+ * $Id: edit_sitemenu.ml,v 1.2 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki_emailnotify
open Cocanwiki_strings
-let template = get_template "edit_sitemenu.html"
-
(* We keep an "internal model" of the menu - see build_internal_model ()
* below.
*)
type model_t = (string * string) list (* label, url *)
let run r (q : cgi) (dbh : Dbi.connection) (hostid, hostname, _) _ =
+ let template = get_template dbh hostid "edit_sitemenu.html" in
+
(* Workaround bugs in IE, specifically lack of support for <button>
* elements.
*)
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit_user_form.ml,v 1.1 2004/09/08 12:45:38 rich Exp $
+ * $Id: edit_user_form.ml,v 1.2 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki_template
open Cocanwiki_date
-let template = get_template "edit_user_form.html"
-
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
+ let template = get_template dbh hostid "edit_user_form.html" in
+
let userid = int_of_string (q#param "userid") in
let sth =
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: files.ml,v 1.4 2004/09/08 09:54:28 rich Exp $
+ * $Id: files.ml,v 1.5 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki
open Cocanwiki_template
-let template = get_template "files.html"
-
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
+ let template = get_template dbh hostid "files.html" in
+
let deleted = q#param_true "deleted" in
template#conditional "deleted" deleted;
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: forgot_password_form.ml,v 1.1 2004/09/07 17:16:46 rich Exp $
+ * $Id: forgot_password_form.ml,v 1.2 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki
open Cocanwiki_template
-let template = get_template "forgot_password_form.html"
-
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
+ let template = get_template dbh hostid "forgot_password_form.html" in
+
q#template template
let () =
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: history.ml,v 1.4 2004/09/08 09:54:28 rich Exp $
+ * $Id: history.ml,v 1.5 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki_template
open Cocanwiki_date
-let template = get_template "history.html"
-
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
+ let template = get_template dbh hostid "history.html" in
+
let page = q#param "page" in
let page = if page = "" then "index" else page in
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: images.ml,v 1.4 2004/09/08 09:54:28 rich Exp $
+ * $Id: images.ml,v 1.5 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki
open Cocanwiki_template
-let template = get_template "images.html"
-
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
+ let template = get_template dbh hostid "images.html" in
+
let deleted = q#param_true "deleted" in
template#conditional "deleted" deleted;
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: login_form.ml,v 1.1 2004/09/07 16:19:43 rich Exp $
+ * $Id: login_form.ml,v 1.2 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki_template
open Cocanwiki_strings
-let template = get_template "login_form.html"
-
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
+ let template = get_template dbh hostid "login_form.html" in
+
let redirect = try q#param "redirect" with Not_found -> "" in
if string_is_whitespace redirect then
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: page.ml,v 1.7 2004/09/08 14:01:17 rich Exp $
+ * $Id: page.ml,v 1.8 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki_ok
open Cocanwiki_date
-let template_page = get_template "page.html"
-let template_404 = get_template "page_404.html"
-
(* Maximum level of redirection. *)
let max_redirect = 4
| FPNotFound
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, edit_anon) user =
+ let template_page = get_template dbh hostid "page.html" in
+ let template_404 = get_template dbh hostid "page_404.html" in
+
let page = q#param "page" in
let page = if page = "" then "index" else page in
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: recent.ml,v 1.4 2004/09/08 09:54:28 rich Exp $
+ * $Id: recent.ml,v 1.5 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki_template
open Cocanwiki_date
-let template = get_template "recent.html"
-
let max_age = "3 months"
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
+ let template = get_template dbh hostid "recent.html" in
+
let sth =
dbh#prepare_cached
"select id, url, url_deleted, title, last_modified_date, logged_ip
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: restore_form.ml,v 1.4 2004/09/08 09:54:28 rich Exp $
+ * $Id: restore_form.ml,v 1.5 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki_ok
open Cocanwiki_diff
-let template = get_template "restore_form.html"
-
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
+ let template = get_template dbh hostid "restore_form.html" in
+
(* Parameters. *)
let page = q#param "page" in
let old_version = int_of_string (q#param "version") in
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: sitemap.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
+ * $Id: sitemap.ml,v 1.4 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki_date
open Cocanwiki_strings
-let template = get_template "sitemap.html"
-
let run r (q : cgi) (dbh : Dbi.connection) (hostid, hostname, _) _ =
+ let template = get_template dbh hostid "sitemap.html" in
+
(* Pull out all the current pages, and a bit of content from each. *)
let sth = dbh#prepare_cached "select p.url, p.url = 'index',
p.title, p.description,
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: undelete_file_form.ml,v 1.4 2004/09/08 09:54:28 rich Exp $
+ * $Id: undelete_file_form.ml,v 1.5 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki
open Cocanwiki_template
-let template = get_template "undelete_file_form.html"
-
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
+ let template = get_template dbh hostid "undelete_file_form.html" in
+
let id = int_of_string (q#param "id") in
let sth = dbh#prepare_cached "select name, name_deleted
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: undelete_image_form.ml,v 1.4 2004/09/08 09:54:28 rich Exp $
+ * $Id: undelete_image_form.ml,v 1.5 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki
open Cocanwiki_template
-let template = get_template "undelete_image_form.html"
-
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
+ let template = get_template dbh hostid "undelete_image_form.html" in
+
let id = int_of_string (q#param "id") in
let sth = dbh#prepare_cached "select name, name_deleted, width, height, alt
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: upload_file_form.ml,v 1.4 2004/09/08 09:54:28 rich Exp $
+ * $Id: upload_file_form.ml,v 1.5 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki
open Cocanwiki_template
-let template = get_template "upload_file_form.html"
+let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
+ let template = get_template dbh hostid "upload_file_form.html" in
-let run r (q : cgi) (dbh : Dbi.connection) _ _ =
q#template template
let () =
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: upload_image_form.ml,v 1.4 2004/09/08 09:54:28 rich Exp $
+ * $Id: upload_image_form.ml,v 1.5 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki
open Cocanwiki_template
-let template = get_template "upload_image_form.html"
+let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
+ let template = get_template dbh hostid "upload_image_form.html" in
-let run r (q : cgi) (dbh : Dbi.connection) _ _ =
q#template template
let () =
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: users.ml,v 1.1 2004/09/08 10:42:20 rich Exp $
+ * $Id: users.ml,v 1.2 2004/09/08 15:46:53 rich Exp $
*)
open Apache
open Cocanwiki_template
open Cocanwiki_date
-let template = get_template "users.html"
-
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
+ let template = get_template dbh hostid "users.html" in
+
let sth =
dbh#prepare_cached
"select id, name, email, registration_date, can_edit, can_manage_users