Updated MANIFEST. Bumped version for release.
[cocanwiki.git] / scripts / lib / cocanwiki_pages.ml
index f6abd61..f713277 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: cocanwiki_pages.ml,v 1.2 2004/10/30 10:16:10 rich Exp $
+ * $Id: cocanwiki_pages.ml,v 1.4 2005/11/17 10:14:43 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
@@ -155,7 +155,7 @@ let save_page (dbh : Dbi.connection) hostid ?user ?r model =
                   `String model.description; logged_ip; logged_user;
                   redirect];
 
-      let pageid = sth#serial "pages_id_seq" in
+      let pageid = Int64.to_int (sth#serial "pages_id_seq") in
 
       (* Create the page contents. *)
       let sth = dbh#prepare_cached "insert into contents (pageid,
@@ -194,6 +194,12 @@ let save_page (dbh : Dbi.connection) hostid ?user ?r model =
              creation_date, url, title, css
          | _ -> assert false in
 
+      (* Title changed? *)
+      let title =
+       match model.pt with
+           Title new_title when title <> new_title -> new_title
+         | _ -> title in
+
       (* Has someone else edited this page in the meantime? *)
       let sth = dbh#prepare_cached "select max(id) from pages
                                      where hostid = ? and url = ?" in
@@ -240,7 +246,7 @@ let save_page (dbh : Dbi.connection) hostid ?user ?r model =
                   logged_user; redirect; css];
 
       (* New page ID <> old page ID model.id. *)
-      let pageid = sth#serial "pages_id_seq" in
+      let pageid = Int64.to_int (sth#serial "pages_id_seq") in
 
       (* Create the page contents. *)
       let sth = dbh#prepare_cached "insert into contents (pageid,