2 * Written by Richard W.M. Jones <rich@merjis.com>.
3 * Copyright (C) 2004 Merjis Ltd.
4 * $Id: sitemap.ml,v 1.1 2004/09/07 10:14:09 rich Exp $
16 let template = get_template "sitemap.html"
18 let run r (q : cgi) (dbh : Dbi.connection) (hostid, hostname) _ =
19 (* Pull out all the current pages, and a bit of content from each. *)
20 let sth = dbh#prepare_cached "select p.url, p.url = 'index',
21 p.title, p.description,
23 (select content from contents
25 order by ordering limit 1) as content
27 where p.hostid = ? and p.url is not null
28 and p.redirect is null
29 order by 2 desc, 3, 1" in
30 sth#execute [`Int hostid];
34 (function [`String url; _; `String title; `String description;
35 `Timestamp last_modified_date;
36 (`Null | `String _) as content] ->
37 let url = if url = "index" then "" else url in
38 let date = printable_date last_modified_date in
39 [ "url", Template.VarString url;
40 "title", Template.VarString title;
41 "description", Template.VarString description;
42 "last_modified_date", Template.VarString date;
43 "has_content", Template.VarConditional (content <> `Null);
44 "content", Template.VarString
49 (Wikilib.text_of_xhtml
50 (Wikilib.xhtml_of_content dbh hostid c))) ]
51 | _ -> assert false) in
53 template#set "hostname" hostname;
54 template#table "sitemap" table;