html/_graphics/newpage.png
html/_graphics/ok.png
html/_graphics/tick.png
+html/_graphics/xml.png
html/_js/editor.js
html/_static/markup.html
html/robots.txt
scripts/recent.ml
scripts/restore.ml
scripts/restore_form.ml
+scripts/rss.ml
scripts/search.ml
scripts/signup.ml
scripts/sitemap.ml
templates/page_404.html
templates/recent.html
templates/restore_form.html
+templates/rss.xml
templates/sitemap.html
templates/undelete_file_form.html
templates/undelete_image_form.html
-# $Id: Makefile,v 1.6 2004/09/17 12:35:37 rich Exp $
+# $Id: Makefile,v 1.7 2004/09/20 15:34:36 rich Exp $
include Makefile.config
install -m 0644 html/_graphics/*.png $(DESTDIR)$(WIKIINSTALLDIR)/html/_graphics
install -m 0644 html/_js/*.js $(DESTDIR)$(WIKIINSTALLDIR)/html/_js
install -m 0644 html/_static/*.html $(DESTDIR)$(WIKIINSTALLDIR)/html/_static
- install -m 0644 templates/*.html templates/*.txt $(DESTDIR)$(WIKIINSTALLDIR)/templates
+ install -m 0644 templates/*.html templates/*.txt templates/*.xml $(DESTDIR)$(WIKIINSTALLDIR)/templates
install -m 0644 templates/admin/*.html $(DESTDIR)$(WIKIINSTALLDIR)/templates/admin
clean:
# Apache configuration for COCANWIKI.
-# $Id: cocanwiki.conf,v 1.4 2004/09/17 12:35:37 rich Exp $
+# $Id: cocanwiki.conf,v 1.5 2004/09/20 15:34:36 rich Exp $
# Uncomment the following lines if necessary. You will probably need
# to adjust the paths to reflect where cocanwiki is really installed.
RewriteRule ^/([^_].*)/edit$ /_bin/edit.cmo?page=$1 [PT,L,QSA]
RewriteRule ^/([^_].*)/editcss$ /_bin/edit_page_css_form.cmo?page=$1 [PT,L,QSA]
RewriteRule ^/([^_].*)/history$ /_bin/history.cmo?page=$1 [PT,L,QSA]
+RewriteRule ^/([^_].*)/index.rss$ /_bin/rss.cmo?page=$1 [PT,L,QSA]
RewriteRule ^/([^_].*)/styles.css$ /_bin/pagestyle.cmo?page=$1 [PT,L,QSA]
# Serve pages.
logout.cmo: cocanwiki.cmo cocanwiki_ok.cmo
logout.cmx: cocanwiki.cmx cocanwiki_ok.cmx
page.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_ok.cmo \
- cocanwiki_template.cmi wikilib.cmi
+ cocanwiki_strings.cmo cocanwiki_template.cmi wikilib.cmi
page.cmx: cocanwiki.cmx cocanwiki_date.cmx cocanwiki_ok.cmx \
- cocanwiki_template.cmx wikilib.cmx
+ cocanwiki_strings.cmx cocanwiki_template.cmx wikilib.cmx
pagestyle.cmo: cgi_expires.cmo cocanwiki.cmo
pagestyle.cmx: cgi_expires.cmx cocanwiki.cmx
preview.cmo: cocanwiki.cmo wikilib.cmi
cocanwiki_template.cmi
restore_form.cmx: cocanwiki.cmx cocanwiki_diff.cmx cocanwiki_ok.cmx \
cocanwiki_template.cmx
+rss.cmo: cocanwiki.cmo cocanwiki_template.cmi wikilib.cmi
+rss.cmx: cocanwiki.cmx cocanwiki_template.cmx wikilib.cmx
search.cmo: cocanwiki.cmo
search.cmx: cocanwiki.cmx
signup.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_strings.cmo
# Makefile for COCANWIKI.
-# $Id: Makefile,v 1.12 2004/09/17 16:03:34 rich Exp $
+# $Id: Makefile,v 1.13 2004/09/20 15:34:36 rich Exp $
include ../Makefile.config
recent.cmo \
restore.cmo \
restore_form.cmo \
+ rss.cmo \
search.cmo \
signup.cmo \
sitemap.cmo \
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki.ml,v 1.7 2004/09/17 15:24:54 rich Exp $
+ * $Id: cocanwiki.ml,v 1.8 2004/09/20 15:34:36 rich Exp $
*
* 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
open Printf
open Cocanwiki_ok
+open Cocanwiki_strings
module Pool = DbiPool (Dbi_postgres)
~title:"Access denied"
q "You do not have permission to access this part of the site."
)
+
+(* Convert a section name into something valid for use in <a name="...">
+ * XXX This breaks horribly for non-7-bit strings.
+ * XXX This is stuck here because we don't have a good place for it, and
+ * because it needs to be fixed for i18n compliance.
+ *)
+let linkname_of_sectionname str =
+ let str = String.copy str in
+ for i = 0 to String.length str - 1 do
+ if not (isalnum str.[i]) then str.[i] <- '_'
+ done;
+ str
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: page.ml,v 1.14 2004/09/20 11:11:15 rich Exp $
+ * $Id: page.ml,v 1.15 2004/09/20 15:34:36 rich Exp $
*
* 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
open Cocanwiki_template
open Cocanwiki_ok
open Cocanwiki_date
-open Cocanwiki_strings
(* Maximum level of redirection. *)
let max_redirect = 4
let can_manage_users = can_manage_users user in
let can_manage_contacts = can_manage_contacts user in
- (* Convert a section name into something valid for use in <a name="...">
- * XXX This breaks horribly for non-7-bit strings.
- *)
- let linkname_of_sectionname str =
- let str = String.copy str in
- for i = 0 to String.length str - 1 do
- if not (isalnum str.[i]) then str.[i] <- '_'
- done;
- str
- in
-
(* This code generates ordinary pages. *)
let make_page title description pageid last_modified_date has_page_css
version page page' =
--- /dev/null
+(* COCANWIKI - a wiki written in Objective CAML.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * Copyright (C) 2004 Merjis Ltd.
+ * $Id: rss.ml,v 1.1 2004/09/20 15:34:36 rich Exp $
+ *
+ * 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; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ *---
+ *
+ * This generates an RSS feed from a page. Articles in the RSS feed are
+ * mapped to sections in the page. At the moment it's fairly crude, but
+ * it's good enough for blogging at the moment. We can think about
+ * cleaning it up later.
+ *)
+
+open Apache
+open Registry
+open Cgi
+open Printf
+
+open Cocanwiki
+open Cocanwiki_template
+
+let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} _ =
+ let template = get_template dbh hostid "rss.xml" in
+
+ let page = q#param "page" in
+ let page = if page = "" then "index" else page in
+ template#set "page" page;
+
+ template#set "hostname" hostname;
+
+ (* Get the title and description of the page. *)
+ let sth = dbh#prepare_cached "select id, title, description
+ from pages
+ where hostid = ? and url = ?
+ and redirect is null" in
+ sth#execute [`Int hostid; `String page];
+
+ let pageid, title, description =
+ match sth#fetch1 () with
+ [ `Int id; `String title; `String description ] ->
+ id, title, description
+ | _ -> assert false in
+
+ template#set "title" title;
+ template#set "description" description;
+
+ (* Get the sections in the live page. *)
+ let sth = dbh#prepare_cached "select sectionname, content, ordering
+ from contents
+ where pageid = ?
+ and sectionname is not null
+ order by ordering" in
+ sth#execute [`Int pageid];
+
+ let sections =
+ sth#map (function [`String sectionname; `String content; _] ->
+ sectionname, content
+ | _ -> assert false) in
+
+ let sections =
+ List.map (fun (sectionname, content) ->
+ let content = Wikilib.xhtml_of_content dbh hostid content in
+ let linkname = linkname_of_sectionname sectionname in
+ [ "sectionname", Template.VarString sectionname;
+ "linkname", Template.VarString linkname;
+ "content", Template.VarString content ]
+ ) sections in
+
+ template#table "sections" sections;
+
+ q#template ~content_type:"text/xml" template
+
+let () =
+ register_script run
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<rdf:RDF
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns="http://purl.org/rss/1.0/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+>
+ <channel rdf:about="http://::hostname_html_tag::/::page_html_tag::">
+ <title>::title_html::</title>
+ <link>http://::hostname_html_tag::/::page_html_tag::</link>
+ <description>::description_html::</description>
+ <language>en-GB</language>
+ <items>
+ <rdf:Seq>
+ ::table(sections)::
+ <rdf:li rdf:resource="http://::hostname_html_tag::/::page_html_tag::#::linkname_html_tag::"/>
+ ::end::
+ </rdf:Seq>
+ </items>
+ </channel>
+::table(sections)::
+ <item rdf:about="http://::hostname_html_tag::/::page_html_tag::#::linkname_html_tag::">
+ <title>::sectionname_html::</title>
+ <link>http://::hostname_html_tag::/::page_html_tag::#::linkname_html_tag::</link>
+ <description>::content_html_textarea::</description>
+ <!-- <dc:creator> ... </dc:creator> -->
+ <!-- <dc:date> ... </dc:date> -->
+ </item>
+::end::
+</rdf:RDF>