+csv dep for PG'OCaml.
[cocanwiki.git] / scripts / lib / cocanwiki_pages.mli
1 (* COCANWIKI - a wiki written in Objective CAML.
2  * Written by Richard W.M. Jones <rich@merjis.com>.
3  * Copyright (C) 2004 Merjis Ltd.
4  * $Id: cocanwiki_pages.mli,v 1.8 2006/08/17 09:11:31 rich Exp $
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; see the file COPYING.  If not, write to
18  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *)
21
22 open Cocanwiki
23
24 (* Page (URL) or title. *)
25 type pt = Page of string | Title of string
26
27 type section =
28     string option * string option * string option * string option * string
29     (* (sectionname, divname, divclass, jsgo, content) *)
30
31 type model = {
32   id : int32;                           (* Original page ID (0 = none). *)
33   pt : pt;                              (* Page of title (only used if id=0) *)
34   description : string;                 (* Description. *)
35   keywords : string option;             (* Keywords. *)
36   noodp : bool option;                  (* NOODP per-page override. *)
37   redirect : string option;             (* Redirect to. *)
38   contents_ : section list;             (* List of sections. *)
39 }
40
41 exception SaveURLError
42 exception SaveConflict of int32 * int32 * string * string option
43   (** New version, old version, URL, CSS. *)
44
45 val new_page : pt -> model
46   (** Create a new, blank page. *)
47
48 val new_page_with_title : string -> model
49   (** Friendlier version of {!new_page} which creates a new page from
50     * a title and begins an introductory paragraph for the user.
51     *)
52
53 val load_page : PGOCaml.pa_pg_data PGOCaml.t -> int32 -> url:string -> ?version:int32 -> unit -> model
54   (** Load a page from the database.  A non-current version can be
55     * specified with the optional [?version] parameter, otherwise the
56     * latest version is loaded.
57     *
58     * @raise Not_found If the page cannot be found.
59     *)
60
61 val save_page : Apache.Request.t -> PGOCaml.pa_pg_data PGOCaml.t -> int32 -> ?user:user_t -> model -> string * int32
62   (** Save a page.  If the page is new, this creates a new page in the
63     * database.  If the page is old, then the page is edited.
64     *
65     * Notification emails are not sent.
66     *
67     * @raise SaveURLError Duplicate URL or bad URL (happens only when creating
68     *   new pages).
69     *
70     * @raise SaveConflict If there was an editing conflict.
71     *
72     * @return (url, pageid)
73     *)