(* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. * $Id: create_form.ml,v 1.2 2004/09/07 13:40:10 rich Exp $ *) open Apache open Registry open Cgi open Printf open ExtString open Cocanwiki open Cocanwiki_template open Cocanwiki_ok let template = get_template "create_form.html" let run r (q : cgi) (dbh : Dbi.connection) (hostid, hostname, _) _ = (* Get the page title. *) let title = q#param "title" in let url = match Wikilib.generate_url_of_title dbh hostid title with Wikilib.GenURL_OK url -> url | Wikilib.GenURL_TooShort | Wikilib.GenURL_BadURL -> error ~back_button:true ~title:"Bad page name" q "The page name supplied is too short or invalid."; raise CgiExit | Wikilib.GenURL_Duplicate url -> q#redirect ("http://" ^ hostname ^ "/" ^ url); raise CgiExit in (* Show the form. *) template#set "title" title; q#template template let () = register_script run