From 1f125fd7a6794f352f30de71a3905d5356a07008 Mon Sep 17 00:00:00 2001 From: rich Date: Thu, 9 Sep 2004 09:35:33 +0000 Subject: [PATCH] All new templates. Site menu displays basically everywhere. Added the "host" object which simplified how scripts are called / makes them more robust to future changes. --- scripts/admin/admin.ml | 4 ++-- scripts/admin/edit_emails.ml | 6 +++--- scripts/admin/edit_emails_form.ml | 4 ++-- scripts/admin/edit_host_css.ml | 4 ++-- scripts/admin/edit_host_css_form.ml | 4 ++-- scripts/admin/edit_hostnames.ml | 6 +++--- scripts/admin/edit_hostnames_form.ml | 4 ++-- scripts/admin/host.ml | 4 ++-- scripts/cocanwiki.ml | 11 +++++++++-- scripts/create.ml | 4 ++-- scripts/create_form.ml | 4 ++-- scripts/delete_file.ml | 4 ++-- scripts/delete_file_form.ml | 4 ++-- scripts/delete_image.ml | 4 ++-- scripts/delete_image_form.ml | 4 ++-- scripts/diff.ml | 4 ++-- scripts/edit.ml | 4 ++-- scripts/edit_page_css.ml | 4 ++-- scripts/edit_page_css_form.ml | 4 ++-- scripts/edit_sitemenu.ml | 4 ++-- scripts/edit_user.ml | 4 ++-- scripts/edit_user_form.ml | 4 ++-- scripts/file.ml | 4 ++-- scripts/files.ml | 4 ++-- scripts/forgot_password.ml | 4 ++-- scripts/forgot_password_form.ml | 4 ++-- scripts/history.ml | 4 ++-- scripts/hoststyle.ml | 4 ++-- scripts/image.ml | 4 ++-- scripts/images.ml | 4 ++-- scripts/login.ml | 4 ++-- scripts/login_form.ml | 4 ++-- scripts/logout.ml | 4 ++-- scripts/page.ml | 4 ++-- scripts/pagestyle.ml | 4 ++-- scripts/preview.ml | 4 ++-- scripts/recent.ml | 4 ++-- scripts/restore.ml | 4 ++-- scripts/restore_form.ml | 4 ++-- scripts/search.ml | 4 ++-- scripts/signup.ml | 4 ++-- scripts/sitemap.ml | 4 ++-- scripts/undelete_file.ml | 4 ++-- scripts/undelete_file_form.ml | 4 ++-- scripts/undelete_image.ml | 4 ++-- scripts/undelete_image_form.ml | 4 ++-- scripts/upload_file.ml | 4 ++-- scripts/upload_file_form.ml | 4 ++-- scripts/upload_image.ml | 4 ++-- scripts/upload_image_form.ml | 4 ++-- scripts/users.ml | 4 ++-- templates/create_form.html | 18 ++++++++++++++++-- templates/delete_file_form.html | 8 +++++--- templates/delete_image_form.html | 8 +++++--- templates/diff.html | 8 +++++--- templates/edit.html | 3 ++- templates/edit_conflict.html | 3 ++- templates/edit_page_css_form.html | 8 +++++--- templates/edit_sitemenu.html | 18 ++++++++++++++++-- templates/files.html | 8 +++++--- templates/forgot_password_form.html | 8 +++++--- templates/history.html | 8 +++++--- templates/images.html | 8 +++++--- templates/login_form.html | 8 +++++--- templates/page.html | 4 ++-- templates/page_404.html | 7 +++---- templates/recent.html | 8 +++++--- templates/restore_form.html | 8 +++++--- templates/sitemap.html | 8 +++++--- templates/undelete_file_form.html | 8 +++++--- templates/undelete_image_form.html | 8 +++++--- templates/upload_file_form.html | 8 +++++--- templates/upload_image_form.html | 8 +++++--- templates/users.html | 8 +++++--- 74 files changed, 237 insertions(+), 167 deletions(-) diff --git a/scripts/admin/admin.ml b/scripts/admin/admin.ml index 2394428..2889e37 100644 --- a/scripts/admin/admin.ml +++ b/scripts/admin/admin.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: admin.ml,v 1.4 2004/09/08 15:46:53 rich Exp $ + * $Id: admin.ml,v 1.5 2004/09/09 09:35:34 rich Exp $ *) open Apache @@ -15,7 +15,7 @@ open Cocanwiki_date let template = _get_template "admin/admin.html" -let run r (q : cgi) (dbh : Dbi.connection) _ _ = +let run r (q : cgi) (dbh : Dbi.connection) _ _ _ = (* Select out the alternative hostnames. *) let sth = dbh#prepare_cached "select hs.hostid, hs.name from hostnames hs diff --git a/scripts/admin/edit_emails.ml b/scripts/admin/edit_emails.ml index 4f5abb8..1eaa376 100644 --- a/scripts/admin/edit_emails.ml +++ b/scripts/admin/edit_emails.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit_emails.ml,v 1.3 2004/09/07 14:58:34 rich Exp $ + * $Id: edit_emails.ml,v 1.4 2004/09/09 09:35:35 rich Exp $ *) open Apache @@ -16,11 +16,11 @@ open Cocanwiki_strings let split_re = Pcre.regexp "[\\r\\n,;]+" let email_re = Pcre.regexp "(.*)<(.*)>" -let run r (q : cgi) (dbh : Dbi.connection) host_stuff _ = +let run r (q : cgi) (dbh : Dbi.connection) _ host' _ = let hostid = int_of_string (q#param "hostid") in if q#param_true "cancel" then ( - let _, hostname, _ = host_stuff in + let { hostname = hostname } = host' in q#redirect ("http://" ^ hostname ^ "/_bin/admin/host.cmo?hostid=" ^ string_of_int hostid); raise CgiExit diff --git a/scripts/admin/edit_emails_form.ml b/scripts/admin/edit_emails_form.ml index b057473..eb793cd 100644 --- a/scripts/admin/edit_emails_form.ml +++ b/scripts/admin/edit_emails_form.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit_emails_form.ml,v 1.3 2004/09/08 15:46:53 rich Exp $ + * $Id: edit_emails_form.ml,v 1.4 2004/09/09 09:35:35 rich Exp $ *) open Apache @@ -14,7 +14,7 @@ open Cocanwiki_template let template = _get_template "admin/edit_emails_form.html" -let run r (q : cgi) (dbh : Dbi.connection) _ _ = +let run r (q : cgi) (dbh : Dbi.connection) _ _ _ = let hostid = int_of_string (q#param "hostid") in template#set "id" (string_of_int hostid); diff --git a/scripts/admin/edit_host_css.ml b/scripts/admin/edit_host_css.ml index 8287fac..c891ba7 100644 --- a/scripts/admin/edit_host_css.ml +++ b/scripts/admin/edit_host_css.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit_host_css.ml,v 1.3 2004/09/07 14:58:34 rich Exp $ + * $Id: edit_host_css.ml,v 1.4 2004/09/09 09:35:35 rich Exp $ *) open Apache @@ -13,7 +13,7 @@ open Cocanwiki open Cocanwiki_ok open Cocanwiki_strings -let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ = +let run r (q : cgi) (dbh : Dbi.connection) _ _ _ = let hostid = int_of_string (q#param "hostid") in let css = q#param "css" in diff --git a/scripts/admin/edit_host_css_form.ml b/scripts/admin/edit_host_css_form.ml index 11a5e48..aac3e58 100644 --- a/scripts/admin/edit_host_css_form.ml +++ b/scripts/admin/edit_host_css_form.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit_host_css_form.ml,v 1.3 2004/09/08 15:46:53 rich Exp $ + * $Id: edit_host_css_form.ml,v 1.4 2004/09/09 09:35:35 rich Exp $ *) open Apache @@ -14,7 +14,7 @@ open Cocanwiki_template let template = _get_template "admin/edit_host_css_form.html" -let run r (q : cgi) (dbh : Dbi.connection) _ _ = +let run r (q : cgi) (dbh : Dbi.connection) _ _ _ = let hostid = int_of_string (q#param "hostid") in template#set "id" (string_of_int hostid); diff --git a/scripts/admin/edit_hostnames.ml b/scripts/admin/edit_hostnames.ml index f572cb9..ffd35d9 100644 --- a/scripts/admin/edit_hostnames.ml +++ b/scripts/admin/edit_hostnames.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit_hostnames.ml,v 1.3 2004/09/07 14:58:34 rich Exp $ + * $Id: edit_hostnames.ml,v 1.4 2004/09/09 09:35:35 rich Exp $ *) open Apache @@ -15,11 +15,11 @@ open Cocanwiki_strings let split_re = Pcre.regexp "[\\s,;]+" -let run r (q : cgi) (dbh : Dbi.connection) host_stuff _ = +let run r (q : cgi) (dbh : Dbi.connection) _ host' _ = let hostid = int_of_string (q#param "hostid") in if q#param_true "cancel" then ( - let _, hostname, _ = host_stuff in + let { hostname = hostname } = host' in q#redirect ("http://" ^ hostname ^ "/_bin/admin/host.cmo?hostid=" ^ string_of_int hostid); raise CgiExit diff --git a/scripts/admin/edit_hostnames_form.ml b/scripts/admin/edit_hostnames_form.ml index 2070b86..8b120b1 100644 --- a/scripts/admin/edit_hostnames_form.ml +++ b/scripts/admin/edit_hostnames_form.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit_hostnames_form.ml,v 1.3 2004/09/08 15:46:53 rich Exp $ + * $Id: edit_hostnames_form.ml,v 1.4 2004/09/09 09:35:35 rich Exp $ *) open Apache @@ -14,7 +14,7 @@ open Cocanwiki_template let template = _get_template "admin/edit_hostnames_form.html" -let run r (q : cgi) (dbh : Dbi.connection) _ _ = +let run r (q : cgi) (dbh : Dbi.connection) _ _ _ = let hostid = int_of_string (q#param "hostid") in template#set "id" (string_of_int hostid); diff --git a/scripts/admin/host.ml b/scripts/admin/host.ml index 99b3bf2..b36c8dc 100644 --- a/scripts/admin/host.ml +++ b/scripts/admin/host.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: host.ml,v 1.4 2004/09/08 15:46:53 rich Exp $ + * $Id: host.ml,v 1.5 2004/09/09 09:35:35 rich Exp $ *) open Apache @@ -15,7 +15,7 @@ open Cocanwiki_date let template = _get_template "admin/host.html" -let run r (q : cgi) (dbh : Dbi.connection) _ _ = +let run r (q : cgi) (dbh : Dbi.connection) _ _ _ = let hostid = int_of_string (q#param "hostid") in template#set "id" (string_of_int hostid); diff --git a/scripts/cocanwiki.ml b/scripts/cocanwiki.ml index 9df94a7..842917b 100644 --- a/scripts/cocanwiki.ml +++ b/scripts/cocanwiki.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: cocanwiki.ml,v 1.4 2004/09/07 16:19:43 rich Exp $ + * $Id: cocanwiki.ml,v 1.5 2004/09/09 09:35:33 rich Exp $ *) open Apache @@ -46,6 +46,10 @@ let test_permission edit_anon perm user = let can_edit edit_anon = test_permission edit_anon CanEdit let can_manage_users = test_permission false CanManageUsers +(* The "host object". *) +type host_t = { hostname : string; + edit_anon : bool; } + (* Our wrapper around the standard [register_script] function. * * The optional ~restrict and ~anonymous parameters work as follows: @@ -96,6 +100,9 @@ let register_script ?(restrict = []) ?(anonymous = true) run = failwith ("Hostname ``" ^ hostname ^ "'' not found in " ^ "the hosts/hostnames tables in the database.") in + (* Create the host object. *) + let host = { hostname = hostname; edit_anon = edit_anon; } in + (* Look for the user's cookie, and determine from this the user * object. *) @@ -153,7 +160,7 @@ let register_script ?(restrict = []) ?(anonymous = true) run = if permitted then ( (* Call the actual CGI script. *) try - run r q dbh (hostid, hostname, edit_anon) user + run r q dbh hostid host user with CgiExit -> () ) else diff --git a/scripts/create.ml b/scripts/create.ml index c1f5f23..3da0560 100644 --- a/scripts/create.ml +++ b/scripts/create.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: create.ml,v 1.3 2004/09/08 09:54:28 rich Exp $ + * $Id: create.ml,v 1.4 2004/09/09 09:35:33 rich Exp $ *) open Apache @@ -15,7 +15,7 @@ open Cocanwiki open Cocanwiki_emailnotify open Cocanwiki_ok -let run r (q : cgi) (dbh : Dbi.connection) (hostid, hostname, _) _ = +let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ = (* Get the page title. *) let title = q#param "title" in diff --git a/scripts/create_form.ml b/scripts/create_form.ml index 1523fbc..75c9a33 100644 --- a/scripts/create_form.ml +++ b/scripts/create_form.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: create_form.ml,v 1.4 2004/09/08 15:46:52 rich Exp $ + * $Id: create_form.ml,v 1.5 2004/09/09 09:35:33 rich Exp $ *) open Apache @@ -15,7 +15,7 @@ open Cocanwiki open Cocanwiki_template open Cocanwiki_ok -let run r (q : cgi) (dbh : Dbi.connection) (hostid, hostname, _) _ = +let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ = let template = get_template dbh hostid "create_form.html" in (* Get the page title. *) diff --git a/scripts/delete_file.ml b/scripts/delete_file.ml index 2efd82f..21847ec 100644 --- a/scripts/delete_file.ml +++ b/scripts/delete_file.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: delete_file.ml,v 1.4 2004/09/08 09:54:28 rich Exp $ + * $Id: delete_file.ml,v 1.5 2004/09/09 09:35:33 rich Exp $ *) open Apache @@ -13,7 +13,7 @@ open Cocanwiki open Cocanwiki_ok open Cocanwiki_emailnotify -let run r (q : cgi) (dbh : Dbi.connection) (hostid, hostname, _) _ = +let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ = let id = int_of_string (q#param "id") in if q#param_true "yes" then ( diff --git a/scripts/delete_file_form.ml b/scripts/delete_file_form.ml index 48c87cc..827c29f 100644 --- a/scripts/delete_file_form.ml +++ b/scripts/delete_file_form.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: delete_file_form.ml,v 1.5 2004/09/08 15:46:52 rich Exp $ + * $Id: delete_file_form.ml,v 1.6 2004/09/09 09:35:33 rich Exp $ *) open Apache @@ -12,7 +12,7 @@ open Printf open Cocanwiki open Cocanwiki_template -let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ = +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 diff --git a/scripts/delete_image.ml b/scripts/delete_image.ml index aa3bb1d..b112f96 100644 --- a/scripts/delete_image.ml +++ b/scripts/delete_image.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: delete_image.ml,v 1.4 2004/09/08 09:54:28 rich Exp $ + * $Id: delete_image.ml,v 1.5 2004/09/09 09:35:33 rich Exp $ *) open Apache @@ -13,7 +13,7 @@ open Cocanwiki open Cocanwiki_ok open Cocanwiki_emailnotify -let run r (q : cgi) (dbh : Dbi.connection) (hostid, hostname, _) _ = +let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ = let id = int_of_string (q#param "id") in if q#param_true "yes" then ( diff --git a/scripts/delete_image_form.ml b/scripts/delete_image_form.ml index d0d282f..f0624a2 100644 --- a/scripts/delete_image_form.ml +++ b/scripts/delete_image_form.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: delete_image_form.ml,v 1.5 2004/09/08 15:46:52 rich Exp $ + * $Id: delete_image_form.ml,v 1.6 2004/09/09 09:35:33 rich Exp $ *) open Apache @@ -12,7 +12,7 @@ open Printf open Cocanwiki open Cocanwiki_template -let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ = +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 diff --git a/scripts/diff.ml b/scripts/diff.ml index 4defd29..e94d5c8 100644 --- a/scripts/diff.ml +++ b/scripts/diff.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: diff.ml,v 1.5 2004/09/08 15:46:52 rich Exp $ + * $Id: diff.ml,v 1.6 2004/09/09 09:35:33 rich Exp $ *) open Apache @@ -13,7 +13,7 @@ open Cocanwiki open Cocanwiki_template open Cocanwiki_diff -let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ = +let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ = let template = get_template dbh hostid "diff.html" in let page = q#param "page" in diff --git a/scripts/edit.ml b/scripts/edit.ml index 527db2a..effef45 100644 --- a/scripts/edit.ml +++ b/scripts/edit.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit.ml,v 1.6 2004/09/08 15:46:53 rich Exp $ + * $Id: edit.ml,v 1.7 2004/09/09 09:35:33 rich Exp $ *) open Apache @@ -30,7 +30,7 @@ type model_t = { * for each section. *) } -let run r (q : cgi) (dbh : Dbi.connection) (hostid, hostname, _) _ = +let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ = let template = get_template dbh hostid "edit.html" in let template_conflict = get_template dbh hostid "edit_conflict.html" in diff --git a/scripts/edit_page_css.ml b/scripts/edit_page_css.ml index 38da4a1..bef37af 100644 --- a/scripts/edit_page_css.ml +++ b/scripts/edit_page_css.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit_page_css.ml,v 1.5 2004/09/08 13:09:05 rich Exp $ + * $Id: edit_page_css.ml,v 1.6 2004/09/09 09:35:33 rich Exp $ *) open Apache @@ -15,7 +15,7 @@ open Cocanwiki_diff open Cocanwiki_emailnotify open Cocanwiki_strings -let run r (q : cgi) (dbh : Dbi.connection) (hostid, hostname, _) _ = +let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ = let page = q#param "page" in let css = q#param "css" in diff --git a/scripts/edit_page_css_form.ml b/scripts/edit_page_css_form.ml index befceb0..ac8082d 100644 --- a/scripts/edit_page_css_form.ml +++ b/scripts/edit_page_css_form.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit_page_css_form.ml,v 1.4 2004/09/08 15:46:53 rich Exp $ + * $Id: edit_page_css_form.ml,v 1.5 2004/09/09 09:35:33 rich Exp $ *) open Apache @@ -12,7 +12,7 @@ open Printf open Cocanwiki open Cocanwiki_template -let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ = +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 diff --git a/scripts/edit_sitemenu.ml b/scripts/edit_sitemenu.ml index 36d48f7..798fe68 100644 --- a/scripts/edit_sitemenu.ml +++ b/scripts/edit_sitemenu.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit_sitemenu.ml,v 1.2 2004/09/08 15:46:53 rich Exp $ + * $Id: edit_sitemenu.ml,v 1.3 2004/09/09 09:35:33 rich Exp $ *) open Apache @@ -23,7 +23,7 @@ open Cocanwiki_strings *) type model_t = (string * string) list (* label, url *) -let run r (q : cgi) (dbh : Dbi.connection) (hostid, hostname, _) _ = +let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ = let template = get_template dbh hostid "edit_sitemenu.html" in (* Workaround bugs in IE, specifically lack of support for