From 5fbc0955aef8b887a7bd1d91ff7b1a0ba9d1b90a Mon Sep 17 00:00:00 2001 From: rich Date: Wed, 26 Jul 2006 13:12:10 +0000 Subject: [PATCH] Fixed some bitrot and some unused variables. --- scripts/admin/edit_hostnames.ml | 5 ++--- scripts/delete_contact.ml | 10 +++------ scripts/delete_contact_form.ml | 6 ++---- scripts/delete_user.ml | 6 ++---- scripts/edit.ml | 38 +++++++++++++++++------------------ scripts/edit_host_settings.ml | 6 ++---- scripts/edit_sitemenu.ml | 8 +++----- scripts/invite_user.ml | 6 ++---- scripts/lib/cocanwiki_ext_calendar.ml | 4 ++-- scripts/mailing_list_confirm.ml | 20 +++++++++--------- scripts/rename_page.ml | 6 ++---- scripts/send_feedback.ml | 6 ++---- 12 files changed, 50 insertions(+), 71 deletions(-) diff --git a/scripts/admin/edit_hostnames.ml b/scripts/admin/edit_hostnames.ml index 1fe9e62..7b3978f 100644 --- a/scripts/admin/edit_hostnames.ml +++ b/scripts/admin/edit_hostnames.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit_hostnames.ml,v 1.10 2006/03/28 16:24:08 rich Exp $ + * $Id: edit_hostnames.ml,v 1.11 2006/07/26 13:12:11 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 @@ -36,8 +36,7 @@ let run r (q : cgi) dbh _ host' _ = if q#param_true "cancel" then ( let { hostname = hostname } = host' in q#redirect ("http://" ^ hostname ^ "/_bin/admin/host.cmo?hostid=" ^ - Int32.to_string hostid); - return () + Int32.to_string hostid) ); let canonical_hostname = q#param "canonical_hostname" in diff --git a/scripts/delete_contact.ml b/scripts/delete_contact.ml index 07758f1..12bada0 100644 --- a/scripts/delete_contact.ml +++ b/scripts/delete_contact.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: delete_contact.ml,v 1.5 2006/03/27 18:09:46 rich Exp $ + * $Id: delete_contact.ml,v 1.6 2006/07/26 13:12:10 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 @@ -29,19 +29,15 @@ open Cocanwiki_ok let run r (q : cgi) dbh hostid { hostname = hostname } _ = (* Cancel? *) - if q#param_true "cancel" then ( + if q#param_true "cancel" then q#redirect ("http://" ^ hostname ^ "/_bin/contacts.cmo"); - return () - ); (* We can delete multiple contact forms from this script, which is * quite unusual. *) let ids = List.map Int32.of_string (q#param_all "delete") in - if ids = [] then ( + if ids = [] then q#redirect ("http://" ^ hostname ^ "/_bin/contacts.cmo"); - return () - ); (* Need to check the contact emails all belong to this host. *) let rows = PGSQL(dbh) diff --git a/scripts/delete_contact_form.ml b/scripts/delete_contact_form.ml index 1dd0bfd..91b7f3b 100644 --- a/scripts/delete_contact_form.ml +++ b/scripts/delete_contact_form.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: delete_contact_form.ml,v 1.3 2006/03/27 18:09:46 rich Exp $ + * $Id: delete_contact_form.ml,v 1.4 2006/07/26 13:12:10 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 @@ -34,10 +34,8 @@ let run r (q : cgi) dbh hostid { hostname = hostname } _ = * quite unusual. *) let ids = List.map Int32.of_string (q#param_all "delete") in - if ids = [] then ( + if ids = [] then q#redirect ("http://" ^ hostname ^ "/_bin/contacts.cmo"); - return () - ); let rows = PGSQL(dbh) "select id, name, subject from contacts diff --git a/scripts/delete_user.ml b/scripts/delete_user.ml index 9e4cffd..ecdc44a 100644 --- a/scripts/delete_user.ml +++ b/scripts/delete_user.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: delete_user.ml,v 1.6 2006/03/27 18:09:46 rich Exp $ + * $Id: delete_user.ml,v 1.7 2006/07/26 13:12:10 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 @@ -28,11 +28,9 @@ open Cocanwiki open Cocanwiki_ok let run r (q : cgi) dbh hostid {hostname = hostname} self = - if q#param_true "cancel" then ( + if q#param_true "cancel" then (* Request cancelled. *) q#redirect ("http://" ^ hostname ^ "/_users"); - return () - ); let userid = Int32.of_string (q#param "userid") in diff --git a/scripts/edit.ml b/scripts/edit.ml index db31b59..c9aa1df 100644 --- a/scripts/edit.ml +++ b/scripts/edit.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit.ml,v 1.28 2006/03/27 18:09:46 rich Exp $ + * $Id: edit.ml,v 1.29 2006/07/26 13:12:10 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 @@ -275,23 +275,23 @@ let run r (q : cgi) dbh hostid {hostname = hostname} user = (* Begin editing with a blank page, typically a template. *) let begin_editing_new pt = - let url, title = - match pt with - Page url -> url, url - | Title title -> - match Wikilib.generate_url_of_title dbh hostid title with - Wikilib.GenURL_OK url -> url, title - | Wikilib.GenURL_Duplicate url -> - q#redirect ("http://" ^ hostname ^ "/" ^ url); - return () - | Wikilib.GenURL_TooShort | Wikilib.GenURL_BadURL -> - error ~back_button:true ~title:"Bad page name" - dbh hostid q - "The page name supplied is too short or invalid."; - return () in + (* Just check the title. *) + (match pt with + | Page url -> () + | Title title -> + match Wikilib.generate_url_of_title dbh hostid title with + | Wikilib.GenURL_OK url -> () + | Wikilib.GenURL_Duplicate url -> + q#redirect ("http://" ^ hostname ^ "/" ^ url) + | Wikilib.GenURL_TooShort | Wikilib.GenURL_BadURL -> + error ~back_button:true ~title:"Bad page name" + dbh hostid q + "The page name supplied is too short or invalid."; + return () + ); let model = match pt with - Page url -> new_page pt + | Page url -> new_page pt | Title title -> new_page_with_title title in model_to_template model template @@ -454,8 +454,7 @@ let run r (q : cgi) dbh hostid {hostname = hostname} user = email_notify ~body ~subject ~user dbh hostid; (* Redirect back to the URL. *) - q#redirect ("http://" ^ hostname ^ "/" ^ url); - return () + q#redirect ("http://" ^ hostname ^ "/" ^ url) ); in @@ -476,8 +475,7 @@ let run r (q : cgi) dbh hostid {hostname = hostname} user = *) "" in - q#redirect ("http://" ^ hostname ^ "/" ^ url); - return () + q#redirect ("http://" ^ hostname ^ "/" ^ url) in (* This code decides where we are in the current editing cycle. diff --git a/scripts/edit_host_settings.ml b/scripts/edit_host_settings.ml index b7dc999..ff4c231 100644 --- a/scripts/edit_host_settings.ml +++ b/scripts/edit_host_settings.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit_host_settings.ml,v 1.10 2006/03/27 18:09:46 rich Exp $ + * $Id: edit_host_settings.ml,v 1.11 2006/07/26 13:12:10 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 @@ -30,11 +30,9 @@ open Cocanwiki_strings let run r (q : cgi) dbh hostid { hostname = hostname } _ = (* Cancel? *) - if q#param_true "cancel" then ( + if q#param_true "cancel" then (* Request cancelled. *) q#redirect ("http://" ^ hostname ^ "/_bin/host_menu.cmo"); - return () - ); (* Get parameters. *) let edit_anon = q#param_true "edit_anon" in diff --git a/scripts/edit_sitemenu.ml b/scripts/edit_sitemenu.ml index 6680e52..6c7aebb 100644 --- a/scripts/edit_sitemenu.ml +++ b/scripts/edit_sitemenu.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit_sitemenu.ml,v 1.11 2006/03/27 19:10:29 rich Exp $ + * $Id: edit_sitemenu.ml,v 1.12 2006/07/26 13:12:10 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 @@ -78,7 +78,7 @@ let run r (q : cgi) dbh hostid { hostname = hostname } user= (* Check for errors in the model. *) let check_for_errors model = let errors = ref [] in - let add_error msg = errors := msg :: !errors in +(* let add_error msg = errors := msg :: !errors in *) let get_errors () = List.rev !errors in (* XXX Not implemented yet. *) @@ -290,10 +290,8 @@ let run r (q : cgi) dbh hostid { hostname = hostname } user= * page - the page URL opened newly for editing. *) if q#param_true "inedit" then ( - if q#param_true "cancel" then ( + if q#param_true "cancel" then cancel (); - return () - ); if q#param_true "save" then ( let ok = try_save () in if ok then return () (* ... else fall through *) diff --git a/scripts/invite_user.ml b/scripts/invite_user.ml index 19bd170..8f3a09a 100644 --- a/scripts/invite_user.ml +++ b/scripts/invite_user.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: invite_user.ml,v 1.7 2006/03/28 13:20:00 rich Exp $ + * $Id: invite_user.ml,v 1.8 2006/07/26 13:12:10 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 @@ -39,10 +39,8 @@ let run r (q : cgi) dbh hostid {hostname = hostname} user = let emails = Pcre.split ~rex:split_re emails in (* This guy's got no friends ... *) - if emails = [] then ( + if emails = [] then q#redirect ("http://" ^ hostname ^ "/"); - return () - ); let userid, username, email = match user with User (userid, username, _, prefs) -> userid, username, prefs.email diff --git a/scripts/lib/cocanwiki_ext_calendar.ml b/scripts/lib/cocanwiki_ext_calendar.ml index 1d54ca7..bbd5506 100644 --- a/scripts/lib/cocanwiki_ext_calendar.ml +++ b/scripts/lib/cocanwiki_ext_calendar.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_ext_calendar.ml,v 1.3 2006/03/27 16:43:44 rich Exp $ + * $Id: cocanwiki_ext_calendar.ml,v 1.4 2006/07/26 13:12:11 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 @@ -248,7 +248,7 @@ let extension dbh hostid url = template#to_string - | Some ((yyyy, mm, dd) as date) -> (* Single day view. *) + | Some (yyyy, mm, dd) -> (* Single day view. *) let template = day_template in (* XXX This will change once we start doing date and time events. diff --git a/scripts/mailing_list_confirm.ml b/scripts/mailing_list_confirm.ml index d7b7316..e35c32b 100644 --- a/scripts/mailing_list_confirm.ml +++ b/scripts/mailing_list_confirm.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: mailing_list_confirm.ml,v 1.6 2006/03/28 13:20:00 rich Exp $ + * $Id: mailing_list_confirm.ml,v 1.7 2006/07/26 13:12:10 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 @@ -34,15 +34,15 @@ let run r (q : cgi) dbh hostid _ _ = let rows = PGSQL(dbh) "select email from mailing_lists where hostid = $hostid and pending = $pending" in - let email = - match rows with - | [email] -> email - | [] -> - error ~close_button:true ~title:"Email already confirmed" - dbh hostid q - "It looks like that email address has already been confirmed."; - return () - | _ -> assert false in + (* Already confirmed? *) + (match rows with + | [_] -> () + | [] -> + error ~close_button:true ~title:"Email already confirmed" + dbh hostid q + "It looks like that email address has already been confirmed."; + return () + | _ -> assert false); (* Update the database. *) PGSQL(dbh) "update mailing_lists set pending = null diff --git a/scripts/rename_page.ml b/scripts/rename_page.ml index a1d287c..3e257dc 100644 --- a/scripts/rename_page.ml +++ b/scripts/rename_page.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: rename_page.ml,v 1.5 2006/03/28 16:24:08 rich Exp $ + * $Id: rename_page.ml,v 1.6 2006/07/26 13:12:10 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 @@ -34,10 +34,8 @@ let run r (q : cgi) dbh hostid {hostname = hostname} user = let page = q#param "page" in (* Cancelled? *) - if q#param_true "cancel" then ( + if q#param_true "cancel" then q#redirect ("http://" ^ hostname ^ "/" ^ page); - return () - ); let new_title = trim (q#param "new_title") in diff --git a/scripts/send_feedback.ml b/scripts/send_feedback.ml index 1de626e..ffe7c7c 100644 --- a/scripts/send_feedback.ml +++ b/scripts/send_feedback.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: send_feedback.ml,v 1.8 2006/03/28 16:24:08 rich Exp $ + * $Id: send_feedback.ml,v 1.9 2006/07/26 13:12:10 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 @@ -33,11 +33,9 @@ open Cocanwiki_ok let run r (q : cgi) dbh hostid {hostname = hostname} user = let template = get_template dbh hostid "send_feedback.txt" in - if q#param_true "cancel" then ( + if q#param_true "cancel" then (* Request cancelled. *) q#redirect ("http://" ^ hostname); - return () - ); (* Get the feedback email for this host. *) let to_addr = List.hd ( -- 1.8.3.1