-
Notifications
You must be signed in to change notification settings - Fork 3
/
page_revisions.ml
67 lines (54 loc) · 1.95 KB
/
page_revisions.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
(* Copyright (c) 2006-2008 Janne Hellsten <jjhellst@gmail.com> *)
(*
* 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 the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. You should have received
* a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*)
open XHTML.M
open Eliom_sessions
open Eliom_parameters
open Eliom_services
open Eliom_predefmod.Xhtml
open Lwt
open ExtList
open ExtString
open Services
open Types
module Db = Database
let revision_table sp page_descr =
Db.with_conn (fun conn -> Db.query_page_revisions ~conn page_descr) >>= fun revisions ->
let page_link descr (rev:int) =
a ~sp ~service:wiki_view_page [pcdata ("Revision "^(string_of_int rev))]
(descr, (None, (Some rev, None))) in
let rows =
List.map
(fun r ->
tr (td [page_link page_descr r.pr_revision])
[td [pcdata r.pr_created];
td [pcdata (Option.default "" r.pr_owner_login)]])
revisions in
return
[table
(tr (th [pcdata "Revision"]) [th [pcdata "When"]; th [pcdata "Changed by"]])
rows]
let view_page_revisions sp page_descr =
Session.with_guest_login sp
(fun cur_user sp ->
revision_table sp page_descr >>= fun revisions ->
return
(Html_util.html_stub sp
(Html_util.navbar_html sp ~cur_user
(h1 [pcdata (page_descr ^ " Revisions")] :: revisions))))
(* /page_revisions?page_id=<id> *)
let _ =
register page_revisions_page
(fun sp page_descr () ->
view_page_revisions sp page_descr)