From 32f71ff9f960ecb191f256a6cfc11a3f2c0c0cf7 Mon Sep 17 00:00:00 2001 From: rich Date: Mon, 1 Nov 2004 12:57:53 +0000 Subject: [PATCH] Removed the diff_sidebyside preference for now. It had a really fundamental bug which means it didn't work properly. Needs to be fixed up properly at a later date. --- cocanwiki.sql | 3 +-- scripts/.depend | 20 +++++++++++--------- scripts/diff.ml | 6 +++--- scripts/edit.ml | 9 ++++----- scripts/edit_page_css.ml | 5 ++--- scripts/lib/cocanwiki.ml | 11 ++++------- scripts/lib/cocanwiki_diff.ml | 16 ++++++++-------- scripts/lib/cocanwiki_diff.mli | 9 +++------ scripts/lib/cocanwiki_emailnotify.ml | 5 +++-- scripts/restore.ml | 4 ++-- scripts/restore_form.ml | 4 ++-- scripts/user_prefs.ml | 7 +++---- scripts/user_prefs_form.ml | 3 +-- templates/user_prefs_form.html | 3 +-- 14 files changed, 48 insertions(+), 57 deletions(-) diff --git a/cocanwiki.sql b/cocanwiki.sql index 7f5b718..8d20a39 100644 --- a/cocanwiki.sql +++ b/cocanwiki.sql @@ -248,8 +248,7 @@ CREATE TABLE users ( force_password_change boolean DEFAULT false NOT NULL, can_import_mail boolean DEFAULT false NOT NULL, email_notify boolean DEFAULT true NOT NULL, - invite text, - diff_sidebyside boolean DEFAULT false NOT NULL + invite text ); diff --git a/scripts/.depend b/scripts/.depend index b2533d2..4b938bc 100644 --- a/scripts/.depend +++ b/scripts/.depend @@ -2,8 +2,10 @@ lib/cocanwiki.cmo: lib/cocanwiki_ok.cmo lib/cocanwiki_strings.cmo lib/cocanwiki.cmx: lib/cocanwiki_ok.cmx lib/cocanwiki_strings.cmx lib/cocanwiki_create_host.cmo: lib/cocanwiki_create_host.cmi lib/cocanwiki_create_host.cmx: lib/cocanwiki_create_host.cmi -lib/cocanwiki_diff.cmo: lib/cocanwiki.cmo lib/cocanwiki_files.cmo -lib/cocanwiki_diff.cmx: lib/cocanwiki.cmx lib/cocanwiki_files.cmx +lib/cocanwiki_diff.cmo: lib/cocanwiki.cmo lib/cocanwiki_files.cmo \ + lib/cocanwiki_diff.cmi +lib/cocanwiki_diff.cmx: lib/cocanwiki.cmx lib/cocanwiki_files.cmx \ + lib/cocanwiki_diff.cmi lib/cocanwiki_emailnotify.cmo: lib/cocanwiki.cmo lib/cocanwiki_emailnotify.cmx: lib/cocanwiki.cmx lib/cocanwiki_ext_calendar.cmo: lib/cocanwiki.cmo lib/cocanwiki_date.cmo \ @@ -29,9 +31,9 @@ lib/cocanwiki_pages.cmo: lib/cocanwiki.cmo lib/cocanwiki_links.cmi \ lib/cocanwiki_pages.cmx: lib/cocanwiki.cmx lib/cocanwiki_links.cmx \ lib/cocanwiki_strings.cmx lib/wikilib.cmx lib/cocanwiki_pages.cmi lib/cocanwiki_template.cmo: lib/cocanwiki_files.cmo lib/cocanwiki_strings.cmo \ - lib/cocanwiki_template.cmi + lib/cocanwiki_version.cmo lib/cocanwiki_template.cmi lib/cocanwiki_template.cmx: lib/cocanwiki_files.cmx lib/cocanwiki_strings.cmx \ - lib/cocanwiki_template.cmi + lib/cocanwiki_version.cmx lib/cocanwiki_template.cmi lib/wikilib.cmo: lib/cocanwiki_strings.cmo lib/wikilib.cmi lib/wikilib.cmx: lib/cocanwiki_strings.cmx lib/wikilib.cmi lib/cocanwiki_mail.cmi: lib/cocanwiki.cmo @@ -90,9 +92,9 @@ delete_user_form.cmo: lib/cocanwiki.cmo lib/cocanwiki_ok.cmo \ lib/cocanwiki_template.cmi delete_user_form.cmx: lib/cocanwiki.cmx lib/cocanwiki_ok.cmx \ lib/cocanwiki_template.cmx -diff.cmo: lib/cocanwiki.cmo lib/cocanwiki_diff.cmo lib/cocanwiki_template.cmi +diff.cmo: lib/cocanwiki.cmo lib/cocanwiki_diff.cmi lib/cocanwiki_template.cmi diff.cmx: lib/cocanwiki.cmx lib/cocanwiki_diff.cmx lib/cocanwiki_template.cmx -edit.cmo: lib/cocanwiki.cmo lib/cocanwiki_diff.cmo \ +edit.cmo: lib/cocanwiki.cmo lib/cocanwiki_diff.cmi \ lib/cocanwiki_emailnotify.cmo lib/cocanwiki_ok.cmo \ lib/cocanwiki_pages.cmi lib/cocanwiki_strings.cmo \ lib/cocanwiki_template.cmi lib/wikilib.cmi @@ -116,7 +118,7 @@ edit_host_settings.cmo: lib/cocanwiki.cmo lib/cocanwiki_ok.cmo edit_host_settings.cmx: lib/cocanwiki.cmx lib/cocanwiki_ok.cmx edit_host_settings_form.cmo: lib/cocanwiki.cmo lib/cocanwiki_template.cmi edit_host_settings_form.cmx: lib/cocanwiki.cmx lib/cocanwiki_template.cmx -edit_page_css.cmo: lib/cocanwiki.cmo lib/cocanwiki_diff.cmo \ +edit_page_css.cmo: lib/cocanwiki.cmo lib/cocanwiki_diff.cmi \ lib/cocanwiki_emailnotify.cmo lib/cocanwiki_ok.cmo \ lib/cocanwiki_strings.cmo edit_page_css.cmx: lib/cocanwiki.cmx lib/cocanwiki_diff.cmx \ @@ -252,13 +254,13 @@ recent.cmx: lib/cocanwiki.cmx lib/cocanwiki_date.cmx \ lib/cocanwiki_template.cmx recently_visited.cmo: lib/cocanwiki.cmo lib/cocanwiki_template.cmi recently_visited.cmx: lib/cocanwiki.cmx lib/cocanwiki_template.cmx -restore.cmo: lib/cocanwiki.cmo lib/cocanwiki_diff.cmo \ +restore.cmo: lib/cocanwiki.cmo lib/cocanwiki_diff.cmi \ lib/cocanwiki_emailnotify.cmo lib/cocanwiki_links.cmi \ lib/cocanwiki_ok.cmo restore.cmx: lib/cocanwiki.cmx lib/cocanwiki_diff.cmx \ lib/cocanwiki_emailnotify.cmx lib/cocanwiki_links.cmx \ lib/cocanwiki_ok.cmx -restore_form.cmo: lib/cocanwiki.cmo lib/cocanwiki_diff.cmo \ +restore_form.cmo: lib/cocanwiki.cmo lib/cocanwiki_diff.cmi \ lib/cocanwiki_ok.cmo lib/cocanwiki_template.cmi restore_form.cmx: lib/cocanwiki.cmx lib/cocanwiki_diff.cmx \ lib/cocanwiki_ok.cmx lib/cocanwiki_template.cmx diff --git a/scripts/diff.ml b/scripts/diff.ml index f81b9d4..09d21a1 100644 --- a/scripts/diff.ml +++ b/scripts/diff.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: diff.ml,v 1.8 2004/10/30 10:16:10 rich Exp $ + * $Id: diff.ml,v 1.9 2004/11/01 12:57:53 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 @@ -49,10 +49,10 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ user = let diff, old_version = try let old_version = int_of_string (q#param "old_version") in - get_diff dbh hostid ~user page ~old_version ~version () + get_diff dbh hostid page ~old_version ~version () with Not_found -> - get_diff dbh hostid ~user page ~version () in + get_diff dbh hostid page ~version () in template#set "version" (string_of_int version); template#set "old_version" (string_of_int old_version); diff --git a/scripts/edit.ml b/scripts/edit.ml index aa3daa6..2e9ee50 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.23 2004/10/30 10:16:10 rich Exp $ + * $Id: edit.ml,v 1.24 2004/11/01 12:57:53 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 @@ -359,15 +359,14 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user = | SaveConflict (new_version, old_version, url, css) -> (* Edited by someone else ... Get the other's changes. *) let other_diff, _ = - get_diff dbh hostid ~user url - ~old_version ~version:new_version () in + get_diff dbh hostid url ~old_version ~version:new_version () in (* Synthesize our own changes. *) let old_page = get_version_for_diff dbh old_version in let new_page = page_for_diff css (List.map (fun (sectionname, _, content) -> sectionname, content) model.contents) in - let our_diff = diff_cmd ~user old_page new_page in + let our_diff = diff_cmd old_page new_page in (* Fill out the conflict template. *) template_conflict#set "other_diff" other_diff; @@ -427,7 +426,7 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user = let body = fun () -> (* Prepare the diff between this version and the previous version. *) - let diff, _ = get_diff dbh hostid ~user url ~version:pageid () in + let diff, _ = get_diff dbh hostid url ~version:pageid () in "Page: http://" ^ hostname ^ "/" ^ url ^ "\n\n" ^ diff in diff --git a/scripts/edit_page_css.ml b/scripts/edit_page_css.ml index b9cb6ee..1ff9ad3 100644 --- a/scripts/edit_page_css.ml +++ b/scripts/edit_page_css.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_page_css.ml,v 1.14 2004/10/30 10:16:10 rich Exp $ + * $Id: edit_page_css.ml,v 1.15 2004/11/01 12:57:53 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 @@ -95,8 +95,7 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user = let subject = "CSS for page " ^ page ^ " has been modified" in let body = fun () -> let diff, _ = - get_diff dbh hostid ~user page - ~version:pageid ~old_version:oldpageid () in + get_diff dbh hostid page ~version:pageid ~old_version:oldpageid () in "Page: http://" ^ hostname ^ "/" ^ page ^ "\n\n" ^ diff in diff --git a/scripts/lib/cocanwiki.ml b/scripts/lib/cocanwiki.ml index 553c03a..4f21cc0 100644 --- a/scripts/lib/cocanwiki.ml +++ b/scripts/lib/cocanwiki.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.ml,v 1.2 2004/10/30 10:16:10 rich Exp $ + * $Id: cocanwiki.ml,v 1.3 2004/11/01 12:57:53 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 @@ -53,7 +53,6 @@ type permissions_t = CanView | CanEdit | CanManageUsers | CanManageContacts type prefs_t = { email : string option; (* Email address. *) email_notify : bool; (* Email notification. *) - diff_sidebyside : bool; (* Shows diffs side-by-side. *) } (* The "user object". *) @@ -161,7 +160,7 @@ let register_script ?(restrict = []) ?(anonymous = true) run = "select u.id, u.name, u.can_edit, u.can_manage_users, u.can_manage_contacts, u.can_manage_site, u.can_edit_global_css, u.can_import_mail, - u.email, u.email_notify, u.diff_sidebyside + u.email, u.email_notify from usercookies uc, users u where uc.cookie = ? and uc.userid = u.id and u.hostid = ?" in sth#execute [`String cookie; `Int hostid]; @@ -170,8 +169,7 @@ let register_script ?(restrict = []) ?(anonymous = true) run = `Bool can_edit; `Bool can_manage_users; `Bool can_manage_contacts; `Bool can_manage_site; `Bool can_edit_global_css; `Bool can_import_mail; - (`Null | `String _) as email; `Bool email_notify; - `Bool diff_sidebyside ] -> + (`Null | `String _) as email; `Bool email_notify ] -> (* Every logged in user can view. *) let perms = [CanView] in let perms = @@ -198,8 +196,7 @@ let register_script ?(restrict = []) ?(anonymous = true) run = `Null -> None | `String email -> Some email in let prefs = { email = email; - email_notify = email_notify; - diff_sidebyside = diff_sidebyside } in + email_notify = email_notify; } in User (userid, name, perms, prefs) | _ -> assert false) with diff --git a/scripts/lib/cocanwiki_diff.ml b/scripts/lib/cocanwiki_diff.ml index ff143a2..9238686 100644 --- a/scripts/lib/cocanwiki_diff.ml +++ b/scripts/lib/cocanwiki_diff.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_diff.ml,v 1.2 2004/10/30 10:16:10 rich Exp $ + * $Id: cocanwiki_diff.ml,v 1.3 2004/11/01 12:57:53 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 @@ -40,7 +40,7 @@ let page_for_diff css sections = let le_re = Pcre.regexp "\r?\n" let le_subst = Pcre.subst "\n" -let diff_cmd ~user old_page new_page = +let diff_cmd old_page new_page = (* Convert line-endings in the input files from \r\n to \n. Diff * can get confused by the \r characters, particularly in side-by-side * mode when asked to expand tabs (-y -t). @@ -52,10 +52,10 @@ let diff_cmd ~user old_page new_page = let new_filename = output_tempfile new_page in let old_filename = output_tempfile old_page in - let diff_sidebyside = - match user with - Anonymous -> false - | User (_, _, _, prefs) -> prefs.diff_sidebyside in + (* Side-by-side mode was good, but stupidly implemented. It's + * disabled right now. + *) + let diff_sidebyside = false in let options = if not diff_sidebyside then @@ -102,7 +102,7 @@ let get_version_for_diff (dbh : Dbi.connection) version = page ) -let get_diff (dbh : Dbi.connection) hostid ~user page ?old_version ~version ()= +let get_diff (dbh : Dbi.connection) hostid page ?old_version ~version ()= let old_version = match old_version with | Some version -> version @@ -121,5 +121,5 @@ let get_diff (dbh : Dbi.connection) hostid ~user page ?old_version ~version ()= let old_page = get_version_for_diff dbh old_version in (* Compute the diff of the two versions. *) - let diff = diff_cmd ~user old_page new_page in + let diff = diff_cmd old_page new_page in diff, old_version diff --git a/scripts/lib/cocanwiki_diff.mli b/scripts/lib/cocanwiki_diff.mli index 543257d..6bbeb71 100644 --- a/scripts/lib/cocanwiki_diff.mli +++ b/scripts/lib/cocanwiki_diff.mli @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: cocanwiki_diff.mli,v 1.1 2004/10/30 10:16:10 rich Exp $ + * $Id: cocanwiki_diff.mli,v 1.2 2004/11/01 12:57:53 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 @@ -21,12 +21,9 @@ val page_for_diff : string -> (string * string) list -> string -val diff_cmd : user:Cocanwiki.user_t -> string -> string -> string +val diff_cmd : string -> string -> string val get_version_for_diff : Dbi.connection -> int -> string -val get_diff : - Dbi.connection -> - int -> - user:Cocanwiki.user_t -> +val get_diff : Dbi.connection -> int -> string -> ?old_version:int -> version:int -> unit -> string * int diff --git a/scripts/lib/cocanwiki_emailnotify.ml b/scripts/lib/cocanwiki_emailnotify.ml index 7d014c5..937d5f2 100644 --- a/scripts/lib/cocanwiki_emailnotify.ml +++ b/scripts/lib/cocanwiki_emailnotify.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_emailnotify.ml,v 1.4 2004/10/30 10:16:10 rich Exp $ + * $Id: cocanwiki_emailnotify.ml,v 1.5 2004/11/01 12:57:53 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 @@ -48,7 +48,8 @@ let email_notify ~subject ~body ?user (dbh : Dbi.connection) hostid = * 'email_notify' table. Don't send email to invited accounts * who have not yet confirmed. *) - let sth = dbh#prepare_cached "select email, name from users + let sth = dbh#prepare_cached "select email, name + from users where hostid = ? and id <> ? and email_notify and email is not null and invite is null" in diff --git a/scripts/restore.ml b/scripts/restore.ml index 0e74693..ed7f383 100644 --- a/scripts/restore.ml +++ b/scripts/restore.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: restore.ml,v 1.15 2004/10/30 10:16:10 rich Exp $ + * $Id: restore.ml,v 1.16 2004/11/01 12:57:53 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 @@ -96,7 +96,7 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user = let subject = "Page " ^ page ^ " has been restored." in let body = fun () -> (* Prepare the diff between this version and the previous version. *) - let diff, _ = get_diff dbh hostid ~user page ~version:pageid () in + let diff, _ = get_diff dbh hostid page ~version:pageid () in "Page: http://" ^ hostname ^ "/" ^ page ^ "\n\n" ^ diff in diff --git a/scripts/restore_form.ml b/scripts/restore_form.ml index 4e9552a..e1c4c49 100644 --- a/scripts/restore_form.ml +++ b/scripts/restore_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: restore_form.ml,v 1.9 2004/10/30 10:16:10 rich Exp $ + * $Id: restore_form.ml,v 1.10 2004/11/01 12:57:53 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 @@ -54,7 +54,7 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ user = return () ); - let diff, _ = get_diff dbh hostid ~user page ~old_version ~version () in + let diff, _ = get_diff dbh hostid page ~old_version ~version () in (* Display the diff. *) template#set "diff" diff; diff --git a/scripts/user_prefs.ml b/scripts/user_prefs.ml index e603c19..b7c6729 100644 --- a/scripts/user_prefs.ml +++ b/scripts/user_prefs.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: user_prefs.ml,v 1.3 2004/10/30 10:16:10 rich Exp $ + * $Id: user_prefs.ml,v 1.4 2004/11/01 12:57:53 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 @@ -35,7 +35,6 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname=hostname} user = (* Get the fields. *) let new_email = trim (q#param "email") in let email_notify = q#param_true "email_notify" in - let diff_sidebyside = q#param_true "diff_sidebyside" in let userid = match user with @@ -44,9 +43,9 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname=hostname} user = (* Update the preferences fields. *) let sth = - dbh#prepare_cached "update users set email_notify = ?, diff_sidebyside = ? + dbh#prepare_cached "update users set email_notify = ? where hostid = ? and id = ?" in - sth#execute [`Bool email_notify; `Bool diff_sidebyside; + sth#execute [`Bool email_notify; `Int hostid; `Int userid]; (* Have we changed the email address? *) diff --git a/scripts/user_prefs_form.ml b/scripts/user_prefs_form.ml index 86d384a..efac44a 100644 --- a/scripts/user_prefs_form.ml +++ b/scripts/user_prefs_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: user_prefs_form.ml,v 1.2 2004/10/30 10:16:10 rich Exp $ + * $Id: user_prefs_form.ml,v 1.3 2004/11/01 12:57:53 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 @@ -60,7 +60,6 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid host user = template#set "registration_date" (printable_date' registration_date); template#conditional "can_edit" can_edit; template#conditional "email_notify" prefs.email_notify; - template#conditional "diff_sidebyside" prefs.diff_sidebyside; q#template template diff --git a/templates/user_prefs_form.html b/templates/user_prefs_form.html index 9bd7fb4..69de82d 100644 --- a/templates/user_prefs_form.html +++ b/templates/user_prefs_form.html @@ -34,8 +34,7 @@ -
- + -- 1.8.3.1