(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* 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
(* 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
email_notify ~body ~subject ~user dbh hostid;
(* Redirect back to the URL. *)
- q#redirect ("http://" ^ hostname ^ "/" ^ url);
- return ()
+ q#redirect ("http://" ^ hostname ^ "/" ^ url)
);
in
*)
"" in
- q#redirect ("http://" ^ hostname ^ "/" ^ url);
- return ()
+ q#redirect ("http://" ^ hostname ^ "/" ^ url)
in
(* This code decides where we are in the current editing cycle.