Fixed the ok/error page - multiple HTML problems.
Error page now sets HTTP status code to 400, allowing us to detect
errors programmatically.
templates/users.html
templates/visualise_links.html
templates/what_links_here.html
-tools/delete_mail.ml
\ No newline at end of file
+tools/delete_mail.ml
+tools/import_mail.sh
+tools/import_mbox.sh
\ No newline at end of file
Section: web
Architecture: all
Depends: libpgsql-ocaml, libdbi-ocaml (>= 0.9.9), libpcre-ocaml,
- ocaml-base-nox-3.08, libapache-mod-caml, libtemplate-ocaml-dev, imagemagick
+ ocaml-base-nox-3.08, libapache-mod-caml, libtemplate-ocaml-dev,
+ libocamlnet-ocaml-dev (>= 0.98),
+ imagemagick, curl (>= 7.12.1)
Suggests: apache
Recommends: graphviz
Description: A Wiki written in Objective CAML (OCaml)
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_ok.ml,v 1.5 2004/09/09 12:21:22 rich Exp $
+ * $Id: cocanwiki_ok.ml,v 1.6 2004/10/12 10:00:38 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
let error ?cookie ?cookies ?title ?(icon = "/_graphics/error.png")
?icon_alt ?back_button ?close_button q message =
+ (* Set the status so scripts can determine if the request failed. *)
+ Request.set_status q#request cHTTP_BAD_REQUEST;
StdPages.error ?cookie ?cookies ~template:ok_error_template
?title ~icon ?icon_alt ?back_button ?close_button q message
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: mail_import.ml,v 1.3 2004/10/11 16:07:25 rich Exp $
+ * $Id: mail_import.ml,v 1.4 2004/10/12 10:00:38 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
upload.upload_value
with
Not_found ->
- (* Force an error status which a script can detect. *)
- Request.set_status r cHTTP_BAD_REQUEST;
error ~back_button:true ~title:"No message"
q "No message was uploaded.";
return () in
* cannot thread it, so give up.
*)
if date = "" || inet_message_id = "" then (
- Request.set_status r cHTTP_BAD_REQUEST;
error ~back_button:true ~title:"Headers missing"
q "Date or Message-ID header missing. Cannot handle this message. ";
return ()
<h1>::title_html::</h1>
::end::
-<div id="mid">
-<div id="cnt">
-
::if(has_icon)::
<img style="float: left; clear:both; margin:10px;"
- alt="::icon_alt_html_tag::"
- src="::icon_html_tag::">
+ alt="::icon_alt_html_tag::" src="::icon_html_tag::"
+ width="32" height="32"/>
::end::
<p>::message_html::</p>
<hr>
::end::
<input type="submit" value="::name_html_tag::"></form></td>
::end::
-
-</div>
-</div>
+</tr></table>
</body>
</html>
--- /dev/null
+#!/bin/sh -
+
+set -e
+
+# Check servername, username, password are supplied.
+if [ $# -lt 3 ]; then
+ echo "Usage: $0 servername username password"
+ echo "eg: $0 wiki.example.com fred secret"
+ exit 1
+fi
+servername=$1
+username="$2"
+password="$3"
+shift 3
+
+# Cookie jar.
+cj=/tmp/$$.cookies
+
+curl="curl -c $cj -o /dev/null -s -w %{http_code}"
+
+# Login to the remote server. The side-effect of this is just to put
+# a cookie in the cookie jar.
+rv=`$curl -F username="$username" -F password="$password" http://$servername/_bin/login.cmo`
+if [ "$rv" != 200 ]; then
+ echo "Login failed. Username or password incorrect."
+ exit 1
+fi
+
+curl="curl -b $cj -c $cj -o /dev/null -s -w %{http_code}"
+
+# Import the mail messages.
+for m in "$@"; do
+ rv=`$curl -F file="<$m" http://$servername/_bin/mail_import.cmo`
+ if [ "$rv" != 200 ]; then
+ echo "Warning: Failed to import message $m"
+ fi
+done
+
+# Remove any temporary files.
+rm -f $cj
--- /dev/null
+#!/bin/sh -
+
+# Usage: import_mbox.sh servername username password < mbox
+
+set -e
+
+d=/tmp/$$.mail
+mkdir --mode=0700 $d
+
+# Read the mbox from stdin and split it into separate files in the directory.
+formail -s sh -c "tail +2 > $d/\$FILENO"
+
+# Now run import_mail.sh on groups of files.
+ls -1 $d | sed -e "s|^|$d/|" | xargs ./import_mail.sh "$@"
+
+# Remove the mail directory.
+rm -rf $d