-# $Id: Makefile.config,v 1.30 2006/03/27 16:43:43 rich Exp $
+# $Id: Makefile.config,v 1.31 2006/05/09 11:36:16 rich Exp $
PACKAGE := cocanwiki
-VERSION := 1.4.0
+VERSION := 1.4.1
# Normally ignored. However, if you are installing centrally (using
# 'make pkg-install'), then the components are installed in the
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: contact.ml,v 1.10 2006/03/27 18:09:46 rich Exp $
+ * $Id: contact.ml,v 1.11 2006/05/09 11:36:16 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
+let subj_rex = Pcre.regexp "\\$\\w+"
+
let run r (q : cgi) dbh hostid {hostname = hostname} user =
let template = get_template dbh hostid "contact.txt" in
let not_empty name = (q#upload name).upload_value <> "" in
List.filter not_empty uploads in
+ (* Substitute any $Field fields in the subject line. The substitution
+ * is very simple-minded.
+ *)
+ let subst pat =
+ let n = String.length pat in
+ assert (n > 0 && pat.[0] = '$');
+ let fieldname = String.sub pat 1 (n-1) in
+ if List.mem fieldname names then
+ q#param fieldname
+ else
+ pat
+ in
+ let subject = Pcre.substitute ~rex:subj_rex ~subst subject in
+
(* Get the IP address for logging purposes. *)
let ip =
try Connection.remote_ip (Request.connection r) with Not_found -> "" in