(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* 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.9 2006/08/14 11:36:50 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
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
let new_page =
if page = "index" then page
else
- match Wikilib.generate_url_of_title dbh hostid new_title with
+ match Wikilib.generate_url_of_title r dbh hostid new_title with
| Wikilib.GenURL_OK url | Wikilib.GenURL_Duplicate url -> url
| Wikilib.GenURL_TooShort | Wikilib.GenURL_BadURL ->
error ~title:"Bad title" ~back_button:true
(* If it's the same as the old URL, then this is a simple title change. *)
let model = load_page dbh hostid ~url:page () in
let model = { model with pt = Title new_title } in
- let url, _ = save_page dbh hostid ~user ~r model in
+ let url, _ = save_page r dbh hostid ~user model in
assert (url = new_page)
) else (
(* Not the same as the old URL, so set the old page to a redirect and
*)
let old_model = load_page dbh hostid ~url:page () in
let new_model = new_page_with_title new_title in
- let new_model = { new_model with description = old_model.description;
+ let new_model = { new_model with
+ description = old_model.description;
+ keywords = old_model.keywords;
+ noodp = old_model.noodp;
contents_ = old_model.contents_ } in
let old_model = { old_model with redirect = Some new_page } in
- ignore (save_page dbh hostid ~user ~r old_model);
+ ignore (save_page r dbh hostid ~user old_model);
try
- ignore (save_page dbh hostid ~user ~r new_model)
+ ignore (save_page r dbh hostid ~user new_model)
with
SaveURLError ->
error ~title:"Page exists"