X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=scripts%2Fedit.ml;h=df0242ee443a8d604ce2ccdae1321a4379a1f2bc;hb=5b036c1119e5871a8996c98639cd861ea7d93e75;hp=3edce8ce5f15d84d85f866002e46c3d4623cea92;hpb=4bc6c4992dbf48fce59efc39cd31f97f03291383;p=cocanwiki.git diff --git a/scripts/edit.ml b/scripts/edit.ml index 3edce8c..df0242e 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.16 2004/10/09 09:41:38 rich Exp $ + * $Id: edit.ml,v 1.19 2004/10/10 16: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 @@ -323,11 +323,19 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user = q "The page name supplied is too short or invalid."; return () in + (* Initial page contents. *) + let contents = + match pt with + Page url -> [] + | Title title -> + [ "", "", + "" ^ title ^ " is " ] in + let model = { id = 0; pt = pt; description = title; redirect = ""; - contents = [] } in + contents = contents } in model_to_template model template in @@ -521,7 +529,8 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user = let sth = dbh#prepare_cached "set constraints pages_redirect_cn, sitemenu_url_cn, - page_emails_url_cn, links_from_cn deferred" in + page_emails_url_cn, links_from_cn, recently_visited_url_cn + deferred" in sth#execute []; (* Mark the old page as deleted. NB. There is a small race @@ -633,10 +642,20 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user = in let cancel id = - let sth = dbh#prepare_cached "select url from pages - where hostid = ? and id = ?" in - sth#execute [`Int hostid; `Int id]; - let url = sth#fetch1string () in + let url = + if id <> 0 then ( + let sth = dbh#prepare_cached "select url from pages + where hostid = ? and id = ?" in + sth#execute [`Int hostid; `Int id]; + sth#fetch1string () + ) else if q#param "pt_type" = "page" then + q#param "pt_value" + else + (* Create a new page, but the user hits the cancel button. Because + * we didn't save where they came from, we now have nowhere to + * go. So we redirect to the home page. XXX + *) + "" in q#redirect ("http://" ^ hostname ^ "/" ^ url); return ()