Fixed some bitrot and some unused variables.
[cocanwiki.git] / scripts / edit.ml
index db31b59..c9aa1df 100644 (file)
@@ -1,7 +1,7 @@
 (* 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
@@ -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.