2 * Written by Richard W.M. Jones <rich@merjis.com>.
3 * Copyright (C) 2004 Merjis Ltd.
4 * $Id: create_form.ml,v 1.3 2004/09/08 09:54:28 rich Exp $
15 open Cocanwiki_template
18 let template = get_template "create_form.html"
20 let run r (q : cgi) (dbh : Dbi.connection) (hostid, hostname, _) _ =
21 (* Get the page title. *)
22 let title = q#param "title" in
25 match Wikilib.generate_url_of_title dbh hostid title with
26 Wikilib.GenURL_OK url -> url
27 | Wikilib.GenURL_TooShort | Wikilib.GenURL_BadURL ->
28 error ~back_button:true ~title:"Bad page name"
29 q "The page name supplied is too short or invalid.";
31 | Wikilib.GenURL_Duplicate url ->
32 q#redirect ("http://" ^ hostname ^ "/" ^ url);
36 template#set "title" title;
41 register_script ~restrict:[CanEdit] run