-cgi_expires.cmo: merjisforwiki.cmi
-cgi_expires.cmx: merjisforwiki.cmx
-cocanwiki.cmo: cocanwiki_ok.cmo merjisforwiki.cmi
-cocanwiki.cmx: cocanwiki_ok.cmx merjisforwiki.cmx
-cocanwiki_date.cmo: merjisforwiki.cmi
-cocanwiki_date.cmx: merjisforwiki.cmx
-cocanwiki_diff.cmo: merjisforwiki.cmi
-cocanwiki_diff.cmx: merjisforwiki.cmx
-cocanwiki_emailnotify.cmo: merjisforwiki.cmi
-cocanwiki_emailnotify.cmx: merjisforwiki.cmx
-cocanwiki_ok.cmo: cocanwiki_template.cmo merjisforwiki.cmi
-cocanwiki_ok.cmx: cocanwiki_template.cmx merjisforwiki.cmx
-cocanwiki_template.cmo: merjisforwiki.cmi
-cocanwiki_template.cmx: merjisforwiki.cmx
+cgi_expires.cmo: cocanwiki_date.cmo
+cgi_expires.cmx: cocanwiki_date.cmx
+cocanwiki.cmo: cocanwiki_ok.cmo
+cocanwiki.cmx: cocanwiki_ok.cmx
+cocanwiki_diff.cmo: cocanwiki_files.cmo
+cocanwiki_diff.cmx: cocanwiki_files.cmx
+cocanwiki_images.cmo: cocanwiki_files.cmo cocanwiki_strings.cmo \
+ cocanwiki_images.cmi
+cocanwiki_images.cmx: cocanwiki_files.cmx cocanwiki_strings.cmx \
+ cocanwiki_images.cmi
+cocanwiki_ok.cmo: cocanwiki_template.cmo
+cocanwiki_ok.cmx: cocanwiki_template.cmx
+cocanwiki_template.cmo: cocanwiki_files.cmo
+cocanwiki_template.cmx: cocanwiki_files.cmx
create.cmo: cocanwiki.cmo cocanwiki_emailnotify.cmo cocanwiki_ok.cmo \
wikilib.cmi
create.cmx: cocanwiki.cmx cocanwiki_emailnotify.cmx cocanwiki_ok.cmx \
wikilib.cmx
-create_form.cmo: cocanwiki.cmo cocanwiki_ok.cmo wikilib.cmi
-create_form.cmx: cocanwiki.cmx cocanwiki_ok.cmx wikilib.cmx
-delete_file.cmo: cocanwiki.cmo cocanwiki_emailnotify.cmo cocanwiki_ok.cmo \
- merjisforwiki.cmi
-delete_file.cmx: cocanwiki.cmx cocanwiki_emailnotify.cmx cocanwiki_ok.cmx \
- merjisforwiki.cmx
-delete_file_form.cmo: cocanwiki.cmo merjisforwiki.cmi
-delete_file_form.cmx: cocanwiki.cmx merjisforwiki.cmx
-delete_image.cmo: cocanwiki.cmo cocanwiki_emailnotify.cmo cocanwiki_ok.cmo \
- merjisforwiki.cmi
-delete_image.cmx: cocanwiki.cmx cocanwiki_emailnotify.cmx cocanwiki_ok.cmx \
- merjisforwiki.cmx
-delete_image_form.cmo: cocanwiki.cmo merjisforwiki.cmi
-delete_image_form.cmx: cocanwiki.cmx merjisforwiki.cmx
-diff.cmo: cocanwiki.cmo cocanwiki_diff.cmo merjisforwiki.cmi
-diff.cmx: cocanwiki.cmx cocanwiki_diff.cmx merjisforwiki.cmx
+create_form.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_template.cmo \
+ wikilib.cmi
+create_form.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_template.cmx \
+ wikilib.cmx
+delete_file.cmo: cocanwiki.cmo cocanwiki_emailnotify.cmo cocanwiki_ok.cmo
+delete_file.cmx: cocanwiki.cmx cocanwiki_emailnotify.cmx cocanwiki_ok.cmx
+delete_file_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+delete_file_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
+delete_image.cmo: cocanwiki.cmo cocanwiki_emailnotify.cmo cocanwiki_ok.cmo
+delete_image.cmx: cocanwiki.cmx cocanwiki_emailnotify.cmx cocanwiki_ok.cmx
+delete_image_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+delete_image_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
+diff.cmo: cocanwiki.cmo cocanwiki_diff.cmo cocanwiki_template.cmo
+diff.cmx: cocanwiki.cmx cocanwiki_diff.cmx cocanwiki_template.cmx
edit.cmo: cocanwiki.cmo cocanwiki_diff.cmo cocanwiki_emailnotify.cmo \
- cocanwiki_ok.cmo merjisforwiki.cmi
+ cocanwiki_ok.cmo cocanwiki_strings.cmo cocanwiki_template.cmo
edit.cmx: cocanwiki.cmx cocanwiki_diff.cmx cocanwiki_emailnotify.cmx \
- cocanwiki_ok.cmx merjisforwiki.cmx
+ cocanwiki_ok.cmx cocanwiki_strings.cmx cocanwiki_template.cmx
edit_page_css.cmo: cocanwiki.cmo cocanwiki_diff.cmo cocanwiki_emailnotify.cmo \
- cocanwiki_ok.cmo merjisforwiki.cmi
+ cocanwiki_ok.cmo cocanwiki_strings.cmo
edit_page_css.cmx: cocanwiki.cmx cocanwiki_diff.cmx cocanwiki_emailnotify.cmx \
- cocanwiki_ok.cmx merjisforwiki.cmx
-edit_page_css_form.cmo: cocanwiki.cmo
-edit_page_css_form.cmx: cocanwiki.cmx
-file.cmo: cgi_expires.cmo cocanwiki.cmo merjisforwiki.cmi
-file.cmx: cgi_expires.cmx cocanwiki.cmx merjisforwiki.cmx
-files.cmo: cocanwiki.cmo merjisforwiki.cmi
-files.cmx: cocanwiki.cmx merjisforwiki.cmx
-history.cmo: cocanwiki.cmo merjisforwiki.cmi
-history.cmx: cocanwiki.cmx merjisforwiki.cmx
-hoststyle.cmo: cgi_expires.cmo cocanwiki.cmo
-hoststyle.cmx: cgi_expires.cmx cocanwiki.cmx
-image.cmo: cgi_expires.cmo cocanwiki.cmo merjisforwiki.cmi
-image.cmx: cgi_expires.cmx cocanwiki.cmx merjisforwiki.cmx
-images.cmo: cocanwiki.cmo merjisforwiki.cmi
-images.cmx: cocanwiki.cmx merjisforwiki.cmx
-merjisforwiki.cmo: merjisforwiki.cmi
-merjisforwiki.cmx: merjisforwiki.cmi
-page.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_version.cmo \
- merjisforwiki.cmi wikilib.cmi
-page.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_version.cmx \
- merjisforwiki.cmx wikilib.cmx
+ cocanwiki_ok.cmx cocanwiki_strings.cmx
+edit_page_css_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+edit_page_css_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
+file.cmo: cgi_expires.cmo cocanwiki.cmo
+file.cmx: cgi_expires.cmx cocanwiki.cmx
+files.cmo: cocanwiki.cmo cocanwiki_template.cmo
+files.cmx: cocanwiki.cmx cocanwiki_template.cmx
+history.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_template.cmo
+history.cmx: cocanwiki.cmx cocanwiki_date.cmx cocanwiki_template.cmx
+hoststyle.cmo: cgi_expires.cmo cocanwiki.cmo cocanwiki_template.cmo
+hoststyle.cmx: cgi_expires.cmx cocanwiki.cmx cocanwiki_template.cmx
+image.cmo: cgi_expires.cmo cocanwiki.cmo
+image.cmx: cgi_expires.cmx cocanwiki.cmx
+images.cmo: cocanwiki.cmo cocanwiki_template.cmo
+images.cmx: cocanwiki.cmx cocanwiki_template.cmx
+page.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_ok.cmo \
+ cocanwiki_template.cmo wikilib.cmi
+page.cmx: cocanwiki.cmx cocanwiki_date.cmx cocanwiki_ok.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
preview.cmx: cocanwiki.cmx wikilib.cmx
-recent.cmo: cocanwiki.cmo
-recent.cmx: cocanwiki.cmx
+recent.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_template.cmo
+recent.cmx: cocanwiki.cmx cocanwiki_date.cmx cocanwiki_template.cmx
restore.cmo: cocanwiki.cmo cocanwiki_diff.cmo cocanwiki_emailnotify.cmo \
- cocanwiki_ok.cmo merjisforwiki.cmi
+ cocanwiki_ok.cmo
restore.cmx: cocanwiki.cmx cocanwiki_diff.cmx cocanwiki_emailnotify.cmx \
- cocanwiki_ok.cmx merjisforwiki.cmx
+ cocanwiki_ok.cmx
restore_form.cmo: cocanwiki.cmo cocanwiki_diff.cmo cocanwiki_ok.cmo \
- merjisforwiki.cmi
+ cocanwiki_template.cmo
restore_form.cmx: cocanwiki.cmx cocanwiki_diff.cmx cocanwiki_ok.cmx \
- merjisforwiki.cmx
+ cocanwiki_template.cmx
search.cmo: cocanwiki.cmo
search.cmx: cocanwiki.cmx
-sitemap.cmo: cocanwiki.cmo merjisforwiki.cmi wikilib.cmi
-sitemap.cmx: cocanwiki.cmx merjisforwiki.cmx wikilib.cmx
-undelete_file.cmo: cocanwiki.cmo cocanwiki_ok.cmo merjisforwiki.cmi
-undelete_file.cmx: cocanwiki.cmx cocanwiki_ok.cmx merjisforwiki.cmx
-undelete_file_form.cmo: cocanwiki.cmo merjisforwiki.cmi
-undelete_file_form.cmx: cocanwiki.cmx merjisforwiki.cmx
-undelete_image.cmo: cocanwiki.cmo cocanwiki_ok.cmo merjisforwiki.cmi
-undelete_image.cmx: cocanwiki.cmx cocanwiki_ok.cmx merjisforwiki.cmx
-undelete_image_form.cmo: cocanwiki.cmo merjisforwiki.cmi
-undelete_image_form.cmx: cocanwiki.cmx merjisforwiki.cmx
-upload_file.cmo: cocanwiki.cmo cocanwiki_emailnotify.cmo cocanwiki_ok.cmo \
- merjisforwiki.cmi
-upload_file.cmx: cocanwiki.cmx cocanwiki_emailnotify.cmx cocanwiki_ok.cmx \
- merjisforwiki.cmx
-upload_file_form.cmo: cocanwiki.cmo merjisforwiki.cmi
-upload_file_form.cmx: cocanwiki.cmx merjisforwiki.cmx
-upload_image.cmo: cocanwiki.cmo cocanwiki_emailnotify.cmo cocanwiki_ok.cmo \
- merjisforwiki.cmi
-upload_image.cmx: cocanwiki.cmx cocanwiki_emailnotify.cmx cocanwiki_ok.cmx \
- merjisforwiki.cmx
-upload_image_form.cmo: cocanwiki.cmo merjisforwiki.cmi
-upload_image_form.cmx: cocanwiki.cmx merjisforwiki.cmx
-wikilib.cmo: merjisforwiki.cmi wikilib.cmi
-wikilib.cmx: merjisforwiki.cmx wikilib.cmi
-admin/admin.cmo: cocanwiki.cmo merjisforwiki.cmi
-admin/admin.cmx: cocanwiki.cmx merjisforwiki.cmx
-admin/create_host.cmo: cocanwiki.cmo cocanwiki_ok.cmo merjisforwiki.cmi
-admin/create_host.cmx: cocanwiki.cmx cocanwiki_ok.cmx merjisforwiki.cmx
-admin/create_host_form.cmo: cocanwiki.cmo
-admin/create_host_form.cmx: cocanwiki.cmx
-admin/edit_emails.cmo: cocanwiki.cmo cocanwiki_ok.cmo merjisforwiki.cmi
-admin/edit_emails.cmx: cocanwiki.cmx cocanwiki_ok.cmx merjisforwiki.cmx
-admin/edit_emails_form.cmo: cocanwiki.cmo
-admin/edit_emails_form.cmx: cocanwiki.cmx
-admin/edit_host_css.cmo: cocanwiki.cmo cocanwiki_ok.cmo merjisforwiki.cmi
-admin/edit_host_css.cmx: cocanwiki.cmx cocanwiki_ok.cmx merjisforwiki.cmx
-admin/edit_host_css_form.cmo: cocanwiki.cmo
-admin/edit_host_css_form.cmx: cocanwiki.cmx
-admin/edit_hostnames.cmo: cocanwiki.cmo cocanwiki_ok.cmo merjisforwiki.cmi
-admin/edit_hostnames.cmx: cocanwiki.cmx cocanwiki_ok.cmx merjisforwiki.cmx
-admin/edit_hostnames_form.cmo: cocanwiki.cmo
-admin/edit_hostnames_form.cmx: cocanwiki.cmx
-admin/host.cmo: cocanwiki.cmo merjisforwiki.cmi
-admin/host.cmx: cocanwiki.cmx merjisforwiki.cmx
+sitemap.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_strings.cmo \
+ cocanwiki_template.cmo wikilib.cmi
+sitemap.cmx: cocanwiki.cmx cocanwiki_date.cmx cocanwiki_strings.cmx \
+ cocanwiki_template.cmx wikilib.cmx
+undelete_file.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_template.cmo
+undelete_file.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_template.cmx
+undelete_file_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+undelete_file_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
+undelete_image.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_template.cmo
+undelete_image.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_template.cmx
+undelete_image_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+undelete_image_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
+upload_file.cmo: cocanwiki.cmo cocanwiki_emailnotify.cmo cocanwiki_images.cmi \
+ cocanwiki_ok.cmo cocanwiki_template.cmo
+upload_file.cmx: cocanwiki.cmx cocanwiki_emailnotify.cmx cocanwiki_images.cmx \
+ cocanwiki_ok.cmx cocanwiki_template.cmx
+upload_file_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+upload_file_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
+upload_image.cmo: cocanwiki.cmo cocanwiki_emailnotify.cmo \
+ cocanwiki_images.cmi cocanwiki_ok.cmo
+upload_image.cmx: cocanwiki.cmx cocanwiki_emailnotify.cmx \
+ cocanwiki_images.cmx cocanwiki_ok.cmx
+upload_image_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+upload_image_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
+wikilib.cmo: wikilib.cmi
+wikilib.cmx: wikilib.cmi
+admin/admin.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_template.cmo
+admin/admin.cmx: cocanwiki.cmx cocanwiki_date.cmx cocanwiki_template.cmx
+admin/create_host.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_strings.cmo
+admin/create_host.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_strings.cmx
+admin/create_host_form.cmo: cocanwiki_template.cmo
+admin/create_host_form.cmx: cocanwiki_template.cmx
+admin/edit_emails.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_strings.cmo
+admin/edit_emails.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_strings.cmx
+admin/edit_emails_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+admin/edit_emails_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
+admin/edit_host_css.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_strings.cmo
+admin/edit_host_css.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_strings.cmx
+admin/edit_host_css_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+admin/edit_host_css_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
+admin/edit_hostnames.cmo: cocanwiki.cmo cocanwiki_ok.cmo \
+ cocanwiki_strings.cmo
+admin/edit_hostnames.cmx: cocanwiki.cmx cocanwiki_ok.cmx \
+ cocanwiki_strings.cmx
+admin/edit_hostnames_form.cmo: cocanwiki.cmo cocanwiki_template.cmo
+admin/edit_hostnames_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
+admin/host.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_template.cmo
+admin/host.cmx: cocanwiki.cmx cocanwiki_date.cmx cocanwiki_template.cmx
# Makefile for COCANWIKI.
-# $Id: Makefile,v 1.2 2004/09/07 13:40:10 rich Exp $
+# $Id: Makefile,v 1.3 2004/09/07 14:58:34 rich Exp $
include ../Makefile.config
CPP := cpp
LIB_OBJS := \
- merjisforwiki.cmo \
cocanwiki_date.cmo \
+ cocanwiki_version.cmo \
+ cocanwiki_files.cmo \
+ cocanwiki_strings.cmo \
+ cocanwiki_images.cmo \
cocanwiki_template.cmo \
cocanwiki_ok.cmo \
cocanwiki.cmo \
- cocanwiki_version.cmo \
cocanwiki_diff.cmo \
cocanwiki_emailnotify.cmo \
wikilib.cmo \
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: admin.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: admin.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_template
+open Cocanwiki_date
let template = get_template "admin/admin.html"
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: create_host.ml,v 1.1 2004/09/07 10:14:10 rich Exp $
+ * $Id: create_host.ml,v 1.2 2004/09/07 14:58:34 rich Exp $
*
* NB. Because there might not be any hosts existing when this Wiki
* is created, this is not a normal Cocanwiki.register_script script.
open Cgi
open Printf
-open Merjisforwiki
+open Cocanwiki_strings
let split_re = Pcre.regexp "[\\s,;]+"
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit_emails.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: edit_emails.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_ok
+open Cocanwiki_strings
let split_re = Pcre.regexp "[\\r\\n,;]+"
let email_re = Pcre.regexp "(.*)<(.*)>"
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit_host_css.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: edit_host_css.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_ok
+open Cocanwiki_strings
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
let hostid = int_of_string (q#param "hostid") in
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit_hostnames.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: edit_hostnames.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_ok
+open Cocanwiki_strings
let split_re = Pcre.regexp "[\\s,;]+"
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: host.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: host.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_template
+open Cocanwiki_date
let template = get_template "admin/host.html"
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cgi_expires.ml,v 1.1 2004/09/07 10:14:09 rich Exp $
+ * $Id: cgi_expires.ml,v 1.2 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Printf
-open Merjisforwiki
+open Cocanwiki_date
(* This library should eventually be integrated with mod_caml. XXX *)
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: cocanwiki.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki_ok
module Pool = DbiPool (Dbi_postgres)
-(* Generate a printable datestamp for pages. *)
-let printable_date (date, _) =
- sprintf "%d %s %04d" date.Dbi.day (short_month date.Dbi.month) date.Dbi.year
-
-let printable_date_time (date, time) =
- sprintf "%d %s %04d %02d:%02d" date.Dbi.day (short_month date.Dbi.month)
- date.Dbi.year time.Dbi.hour time.Dbi.min
-
(* This function is used to grab a database handle. It's used in a couple
* of very special places, and is not for general consumption.
*)
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_date.ml,v 1.1 2004/09/07 13:40:10 rich Exp $
+ * $Id: cocanwiki_date.ml,v 1.2 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
+let short_weekday = function
+ | 0 -> "Sun" | 1 -> "Mon" | 2 -> "Tue" | 3 -> "Wed"
+ | 4 -> "Thu" | 5 -> "Fri" | 6 -> "Sat" | 7 -> "Sun"
+ | _ -> invalid_arg "short_weekday"
+
+let short_month = function
+ | 1 -> "Jan" | 2 -> "Feb" | 3 -> "Mar" | 4 -> "Apr"
+ | 5 -> "May" | 6 -> "Jun" | 7 -> "Jul" | 8 -> "Aug"
+ | 9 -> "Sep" | 10 -> "Oct" | 11 -> "Nov" | 12 -> "Dec"
+ | _ -> invalid_arg "short_month"
(* Generate a printable datestamp for pages. *)
let printable_date (date, _) =
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_diff.ml,v 1.1 2004/09/07 10:14:09 rich Exp $
+ * $Id: cocanwiki_diff.ml,v 1.2 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
+open Cocanwiki_files
(* Convenience code for generating diffs between versions. See diff.ml
* and edit.ml which both use this code.
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_emailnotify.ml,v 1.1 2004/09/07 10:14:09 rich Exp $
+ * $Id: cocanwiki_emailnotify.ml,v 1.2 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
(* This is where we coordinate email notification from various
* scripts which create or update the wiki.
*)
--- /dev/null
+(* Basic file functions.
+ * Copyright (C) 2004 Merjis Ltd.
+ * Written By Richard W.M. Jones (rich@merjis.com)
+ * $Id: cocanwiki_files.ml,v 1.1 2004/09/07 14:58:34 rich Exp $
+ *)
+
+open Printf
+
+(*----- File functions. -----*)
+
+let (//) = Filename.concat
+
+let rec input_all_lines chan =
+ try
+ let line = input_line chan in
+ line :: input_all_lines chan
+ with
+ End_of_file -> []
+
+let input_all chan =
+ let buf = Buffer.create 16384 in
+ let tmpsize = 16384 in
+ let tmp = String.create tmpsize in
+ let n = ref 0 in
+ while n := input chan tmp 0 tmpsize; !n > 0 do
+ Buffer.add_substring buf tmp 0 !n;
+ done;
+ Buffer.contents buf
+
+let input_file filename =
+ let chan = open_in_bin filename in
+ let data = input_all chan in
+ close_in chan;
+ data
+
+let output_file filename data =
+ let chan = open_out_bin filename in
+ output_string chan data;
+ close_out chan
+
+let output_tempfile data =
+ let filename, chan = Filename.open_temp_file "tmp" ".tmp" in
+ output_string chan data;
+ close_out chan;
+ filename
+
+(*----- Command functions. -----*)
+
+let cmd cmd =
+ let code = Sys.command cmd in
+ if code <> 0 then failwith (cmd ^ ": error code " ^ string_of_int code)
+
+let copy infile outfile =
+ cmd (sprintf "cp %s %s" infile outfile)
+
+let pget cmd =
+ let chan = Unix.open_process_in cmd in
+ let lines = input_all_lines chan in
+ let stat = Unix.close_process_in chan in
+ (match stat with
+ Unix.WEXITED 0 -> ()
+ | Unix.WEXITED i ->
+ failwith ("command failed with code " ^ string_of_int i)
+ | Unix.WSIGNALED i ->
+ failwith ("command killed by signal " ^ string_of_int i)
+ | Unix.WSTOPPED i ->
+ failwith ("command stopped by signal " ^ string_of_int i));
+ lines
+
+let unlink file =
+ try Unix.unlink file with Unix.Unix_error _ -> ()
--- /dev/null
+(* COCANWIKI scripts.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * Copyright (C) 2004 Merjis Ltd.
+ * $Id: cocanwiki_images.ml,v 1.1 2004/09/07 14:58:34 rich Exp $
+ *)
+
+open Printf
+
+open Cocanwiki_strings
+open Cocanwiki_files
+
+(* Find the format of an image. Uses the external 'identify' program,
+ * part of ImageMagick. Returns (mime_type, width, height). Throws
+ * Invalid_argument "image_identify" if the data is not an image.
+ *)
+let image_identify_re = Pcre.regexp "^\\S+ ([A-Z]+) (\\d+)x(\\d+)"
+
+let image_identify data =
+ let filename = output_tempfile data in
+ let in_chan = Unix.open_process_in ("identify " ^ filename) in
+ let line = input_line in_chan in
+ let status = Unix.close_process_in in_chan in
+ unlink filename;
+ (match status with
+ Unix.WEXITED 0 -> (* Identify was OK with it ... *)
+ ()
+ | Unix.WEXITED _ -> (* Couldn't identify the file type. *)
+ raise (Invalid_argument "image_identify")
+ | Unix.WSIGNALED n ->
+ failwith ("image_identify: 'identify' killed by signal " ^
+ string_of_int n)
+ | Unix.WSTOPPED n ->
+ failwith ("image_identify: 'identify' stopped by signal " ^
+ string_of_int n));
+ try
+ let subs = Pcre.exec ~rex:image_identify_re line in
+ let type_string = Pcre.get_substring subs 1 in
+ let width = int_of_string (Pcre.get_substring subs 2) in
+ let height = int_of_string (Pcre.get_substring subs 3) in
+ let typ =
+ match type_string with
+ "JPEG" -> "image/jpeg"
+ | "GIF" -> "image/gif"
+ | "PNG" -> "image/png"
+ | _ -> raise (Invalid_argument "image_identify") in
+ typ, width, height
+ with
+ Not_found ->
+ raise (Invalid_argument "image_identify")
+
+(* Make a thumbnail of an image. This uses the ImageMagick program 'convert'.
+ *)
+let image_thumbnail data max_width max_height =
+ let filename = output_tempfile data in
+ let cmd = sprintf "convert -size %dx%d %s -resize %dx%d -"
+ max_width max_height filename max_width max_height in
+ let in_chan = Unix.open_process_in cmd in
+ let thumbnail = input_all in_chan in
+ let status = Unix.close_process_in in_chan in
+ unlink filename;
+ (match status with
+ Unix.WEXITED 0 -> (* Convert was OK with it ... *)
+ ()
+ | Unix.WEXITED n -> (* Convert failed. *)
+ failwith ("convert: fail with error code " ^ string_of_int n)
+ | Unix.WSIGNALED n ->
+ failwith ("convert: killed by signal " ^ string_of_int n)
+ | Unix.WSTOPPED n ->
+ failwith ("convert: stopped by signal " ^ string_of_int n));
+ let mime_type, width, height = image_identify thumbnail in
+ thumbnail, mime_type, width, height
+
+(*----- Files and MIME types. -----*)
+
+let ws_re = Pcre.regexp "\\s+"
+let ext_re = Pcre.regexp "\\.([a-z0-9]+)$"
+
+let mime_types =
+ try
+ let chan = open_in "/etc/mime.types" in
+ let lines = input_all_lines chan in
+ close_in chan;
+ let lines = List.filter (fun line ->
+ not (string_is_whitespace line) &&
+ String.length line > 0 &&
+ line.[0] <> '#') lines in
+ let res = ref [] in
+ List.iter (fun line ->
+ let fields = Pcre.split ~rex:ws_re line in
+ match fields with
+ [] -> assert false
+ | typ :: exts ->
+ List.iter (fun ext ->
+ res := (ext, typ) :: !res) exts) lines;
+ !res
+ with
+ Sys_error _ -> []
+
+let mime_type_of_filename name =
+ try
+ let subs = Pcre.exec ~rex:ext_re name in
+ let ext = Pcre.get_substring subs 1 in
+ let ext = String.lowercase ext in
+ List.assoc ext mime_types
+ with
+ Not_found -> "application/octet-stream"
--- /dev/null
+(* COCANWIKI scripts.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * Copyright (C) 2004 Merjis Ltd.
+ * $Id: cocanwiki_images.mli,v 1.1 2004/09/07 14:58:34 rich Exp $
+ *)
+
+val image_identify : string -> string * int * int
+val image_thumbnail : string -> int -> int -> string * string * int * int
+
+val mime_type_of_filename : string -> string
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_ok.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: cocanwiki_ok.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki_template
(* Override StdPages.ok and StdPages.error with out our versions.
--- /dev/null
+(* Basic string functions.
+ * Copyright (C) 2004 Merjis Ltd.
+ * Written By Richard W.M. Jones (rich@merjis.com)
+ * $Id: cocanwiki_strings.ml,v 1.1 2004/09/07 14:58:34 rich Exp $
+ *)
+
+open ExtString
+
+let string_contains substr str =
+ try String.find str substr; true
+ with String.Invalid_string -> false
+
+let string_of_char = String.make 1
+
+let truncate n str =
+ if String.length str < n then str else String.sub str 0 (n-1)
+
+(* These versions only work in the C locale for 7-bit characters. *)
+let isspace c =
+ c = ' '
+ (* || c = '\f' *) || c = '\n' || c = '\r' || c = '\t' (* || c = '\v' *)
+
+let isalpha c =
+ c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z'
+
+let isdigit c =
+ c >= '0' && c <= '9'
+
+let isalnum c =
+ c >= '0' && c <= '9' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z'
+
+let islower c =
+ c >= 'a' && c <= 'z'
+
+let isupper c =
+ c >= 'A' && c <= 'Z'
+
+let isxdigit c =
+ c >= '0' && c <= '9' || c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F'
+
+let triml ?(test = isspace) str =
+ let i = ref 0 in
+ let n = ref (String.length str) in
+ while !n > 0 && test str.[!i]; do
+ decr n;
+ incr i
+ done;
+ if !i = 0 then str
+ else String.sub str !i !n
+
+let trimr ?(test = isspace) str =
+ let n = ref (String.length str) in
+ while !n > 0 && test str.[!n-1]; do
+ decr n
+ done;
+ if !n = String.length str then str
+ else String.sub str 0 !n
+
+let trim ?(test = isspace) str =
+ trimr (triml str)
+
+let string_for_all f str =
+ let len = String.length str in
+ let rec loop i =
+ if i = len then true
+ else (
+ let c = str.[i] in
+ if not (f c) then false
+ else loop (i+1)
+ )
+ in
+ loop 0
+
+let string_exists f str =
+ let len = String.length str in
+ let rec loop i =
+ if i = len then false
+ else (
+ let c = str.[i] in
+ if f c then true
+ else loop (i+1)
+ )
+ in
+ loop 0
+
+let string_is_whitespace = string_for_all isspace
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_template.ml,v 1.1 2004/09/07 13:40:10 rich Exp $
+ * $Id: cocanwiki_template.ml,v 1.2 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
-open Merjisforwiki
+open Cocanwiki_files
(* Wrapper around [Cgi.Template.template] function which loads the
* template from a pre-defined path and sets up some default variables.
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: delete_file.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: delete_file.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cocanwiki_ok
open Cocanwiki_emailnotify
-open Merjisforwiki
-
let run r (q : cgi) (dbh : Dbi.connection) (hostid, hostname, _) _ =
let id = int_of_string (q#param "id") in
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: delete_file_form.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: delete_file_form.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cocanwiki
open Cocanwiki_template
-open Merjisforwiki
-
let template = get_template "delete_file_form.html"
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: delete_image.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: delete_image.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cocanwiki_ok
open Cocanwiki_emailnotify
-open Merjisforwiki
-
let run r (q : cgi) (dbh : Dbi.connection) (hostid, hostname, _) _ =
let id = int_of_string (q#param "id") in
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: delete_image_form.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: delete_image_form.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_template
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: diff.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: diff.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_template
open Cocanwiki_diff
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: edit.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open ExtString
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_template
open Cocanwiki_ok
open Cocanwiki_emailnotify
open Cocanwiki_diff
+open Cocanwiki_strings
let template = get_template "edit.html"
let template_conflict = get_template "edit_conflict.html"
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit_page_css.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: edit_page_css.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_ok
open Cocanwiki_diff
open Cocanwiki_emailnotify
+open Cocanwiki_strings
let run r (q : cgi) (dbh : Dbi.connection) (hostid, hostname, _) _ =
let page = q#param "page" in
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: file.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: file.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: files.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: files.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_template
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: history.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: history.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_template
+open Cocanwiki_date
let template = get_template "history.html"
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: image.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: image.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
-open Cocanwiki
open Cocanwiki
let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: images.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: images.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_template
+++ /dev/null
-(* Basic Merjis functions.
- * Copyright (C) 2004 Merjis Ltd.
- * Written By Richard W.M. Jones (rich@merjis.com)
- * $Id: merjisforwiki.ml,v 1.1 2004/09/07 10:14:09 rich Exp $
- *)
-
-(* This is a copy of an internal library which we use at Merjis. *)
-
-open Printf
-open ExtString
-open ExtList
-
-(*----- Basic stuff. -----*)
-
-let identity x = x
-
-let unique =
- let n = ref 0 in
- fun () -> incr n; !n
-
-let rec range a b =
- if a <= b then
- a :: range (a+1) b
- else
- []
-
-(*----- String functions. -----*)
-
-let string_contains substr str =
- try String.find str substr; true
- with String.Invalid_string -> false
-
-let string_of_char = String.make 1
-
-let truncate n str =
- if String.length str < n then str else String.sub str 0 (n-1)
-
-(* These versions only work in the C locale for 7-bit characters. *)
-let isspace c =
- c = ' '
- (* || c = '\f' *) || c = '\n' || c = '\r' || c = '\t' (* || c = '\v' *)
-
-let isalpha c =
- c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z'
-
-let isdigit c =
- c >= '0' && c <= '9'
-
-let isalnum c =
- c >= '0' && c <= '9' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z'
-
-let islower c =
- c >= 'a' && c <= 'z'
-
-let isupper c =
- c >= 'A' && c <= 'Z'
-
-let isxdigit c =
- c >= '0' && c <= '9' || c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F'
-
-let triml ?(test = isspace) str =
- let i = ref 0 in
- let n = ref (String.length str) in
- while !n > 0 && test str.[!i]; do
- decr n;
- incr i
- done;
- if !i = 0 then str
- else String.sub str !i !n
-
-let trimr ?(test = isspace) str =
- let n = ref (String.length str) in
- while !n > 0 && test str.[!n-1]; do
- decr n
- done;
- if !n = String.length str then str
- else String.sub str 0 !n
-
-let trim ?(test = isspace) str =
- trimr (triml str)
-
-let string_for_all f str =
- let len = String.length str in
- let rec loop i =
- if i = len then true
- else (
- let c = str.[i] in
- if not (f c) then false
- else loop (i+1)
- )
- in
- loop 0
-
-let string_exists f str =
- let len = String.length str in
- let rec loop i =
- if i = len then false
- else (
- let c = str.[i] in
- if f c then true
- else loop (i+1)
- )
- in
- loop 0
-
-let string_is_whitespace = string_for_all isspace
-
-(*----- List functions. -----*)
-
-let first n xs =
- fst (List.split_nth n xs)
-
-let rec uniq ?(cmp = Pervasives.compare) = function
- [] -> []
- | [x] -> [x]
- | x :: y :: xs when compare x y = 0 ->
- uniq (x :: xs)
- | x :: y :: xs ->
- x :: uniq (y :: xs)
-
-let sort_uniq ?cmp xs =
- let xs = List.sort ?cmp xs in
- let xs = uniq ?cmp xs in
- xs
-
-let frequency ?(cmp = Pervasives.compare) xs =
- let xs = List.sort ~cmp xs in
- let rec loop = function
- [] -> []
- | [x] -> [1, x]
- | x :: y :: xs when cmp x y = 0 ->
- let rest = loop (y :: xs) in
- let (count, _), rest = List.hd rest, List.tl rest in
- (count+1, y) :: rest
- | x :: xs ->
- (1, x) :: loop xs
- in
- let xs = loop xs in
- List.rev (List.sort xs)
-
-(* This version by Isaac Trotts. *)
-let group_by ?(cmp = Pervasives.compare) ls =
- let ls' =
- List.fold_left
- (fun acc (day1, x1) ->
- match acc with
- [] -> [day1, [x1]]
- | (day2, ls2) :: acctl ->
- if cmp day1 day2 = 0
- then (day1, x1 :: ls2) :: acctl
- else (day1, [x1]) :: acc)
- []
- ls
- in
- let ls' = List.rev ls' in
- List.map (fun (x, xs) -> x, List.rev xs) ls'
-
-(*----- File functions. -----*)
-
-let (//) = Filename.concat
-
-let rec input_all_lines chan =
- try
- let line = input_line chan in
- line :: input_all_lines chan
- with
- End_of_file -> []
-
-let input_all chan =
- let buf = Buffer.create 16384 in
- let tmpsize = 16384 in
- let tmp = String.create tmpsize in
- let n = ref 0 in
- while n := input chan tmp 0 tmpsize; !n > 0 do
- Buffer.add_substring buf tmp 0 !n;
- done;
- Buffer.contents buf
-
-let input_file filename =
- let chan = open_in_bin filename in
- let data = input_all chan in
- close_in chan;
- data
-
-let output_file filename data =
- let chan = open_out_bin filename in
- output_string chan data;
- close_out chan
-
-let output_tempfile data =
- let filename, chan = Filename.open_temp_file "tmp" ".tmp" in
- output_string chan data;
- close_out chan;
- filename
-
-(*----- Command functions. -----*)
-
-let cmd cmd =
- let code = Sys.command cmd in
- if code <> 0 then failwith (cmd ^ ": error code " ^ string_of_int code)
-
-let copy infile outfile =
- cmd (sprintf "cp %s %s" infile outfile)
-
-let pget cmd =
- let chan = Unix.open_process_in cmd in
- let lines = input_all_lines chan in
- let stat = Unix.close_process_in chan in
- (match stat with
- Unix.WEXITED 0 -> ()
- | Unix.WEXITED i ->
- failwith ("command failed with code " ^ string_of_int i)
- | Unix.WSIGNALED i ->
- failwith ("command killed by signal " ^ string_of_int i)
- | Unix.WSTOPPED i ->
- failwith ("command stopped by signal " ^ string_of_int i));
- lines
-
-let unlink file =
- try Unix.unlink file with Unix.Unix_error _ -> ()
-
-(*----- Meta-functions. -----*)
-let notf f =
- fun v -> not (f v)
-
-(*----- Time and date. -----*)
-let short_weekday = function
- | 0 -> "Sun" | 1 -> "Mon" | 2 -> "Tue" | 3 -> "Wed"
- | 4 -> "Thu" | 5 -> "Fri" | 6 -> "Sat" | 7 -> "Sun"
- | _ -> invalid_arg "short_weekday"
-
-let short_month = function
- | 1 -> "Jan" | 2 -> "Feb" | 3 -> "Mar" | 4 -> "Apr"
- | 5 -> "May" | 6 -> "Jun" | 7 -> "Jul" | 8 -> "Aug"
- | 9 -> "Sep" | 10 -> "Oct" | 11 -> "Nov" | 12 -> "Dec"
- | _ -> invalid_arg "short_month"
-
-(*----- Images. -----*)
-
-(* Find the format of an image. Uses the external 'identify' program,
- * part of ImageMagick. Returns (mime_type, width, height). Throws
- * Invalid_argument "image_identify" if the data is not an image.
- *)
-let image_identify_re = Pcre.regexp "^\\S+ ([A-Z]+) (\\d+)x(\\d+)"
-
-let image_identify data =
- let filename = output_tempfile data in
- let in_chan = Unix.open_process_in ("identify " ^ filename) in
- let line = input_line in_chan in
- let status = Unix.close_process_in in_chan in
- unlink filename;
- (match status with
- Unix.WEXITED 0 -> (* Identify was OK with it ... *)
- ()
- | Unix.WEXITED _ -> (* Couldn't identify the file type. *)
- raise (Invalid_argument "image_identify")
- | Unix.WSIGNALED n ->
- failwith ("image_identify: 'identify' killed by signal " ^
- string_of_int n)
- | Unix.WSTOPPED n ->
- failwith ("image_identify: 'identify' stopped by signal " ^
- string_of_int n));
- try
- let subs = Pcre.exec ~rex:image_identify_re line in
- let type_string = Pcre.get_substring subs 1 in
- let width = int_of_string (Pcre.get_substring subs 2) in
- let height = int_of_string (Pcre.get_substring subs 3) in
- let typ =
- match type_string with
- "JPEG" -> "image/jpeg"
- | "GIF" -> "image/gif"
- | "PNG" -> "image/png"
- | _ -> raise (Invalid_argument "image_identify") in
- typ, width, height
- with
- Not_found ->
- raise (Invalid_argument "image_identify")
-
-(* Make a thumbnail of an image. This uses the ImageMagick program 'convert'.
- *)
-let image_thumbnail data max_width max_height =
- let filename = output_tempfile data in
- let cmd = sprintf "convert -size %dx%d %s -resize %dx%d -"
- max_width max_height filename max_width max_height in
- let in_chan = Unix.open_process_in cmd in
- let thumbnail = input_all in_chan in
- let status = Unix.close_process_in in_chan in
- unlink filename;
- (match status with
- Unix.WEXITED 0 -> (* Convert was OK with it ... *)
- ()
- | Unix.WEXITED n -> (* Convert failed. *)
- failwith ("convert: fail with error code " ^ string_of_int n)
- | Unix.WSIGNALED n ->
- failwith ("convert: killed by signal " ^ string_of_int n)
- | Unix.WSTOPPED n ->
- failwith ("convert: stopped by signal " ^ string_of_int n));
- let mime_type, width, height = image_identify thumbnail in
- thumbnail, mime_type, width, height
-
-(*----- Files and MIME types. -----*)
-
-let ws_re = Pcre.regexp "\\s+"
-let ext_re = Pcre.regexp "\\.([a-z0-9]+)$"
-
-let mime_types =
- try
- let chan = open_in "/etc/mime.types" in
- let lines = input_all_lines chan in
- close_in chan;
- let lines = List.filter (fun line ->
- not (string_is_whitespace line) &&
- String.length line > 0 &&
- line.[0] <> '#') lines in
- let res = ref [] in
- List.iter (fun line ->
- let fields = Pcre.split ~rex:ws_re line in
- match fields with
- [] -> assert false
- | typ :: exts ->
- List.iter (fun ext ->
- res := (ext, typ) :: !res) exts) lines;
- !res
- with
- Sys_error _ -> []
-
-let mime_type_of_filename name =
- try
- let subs = Pcre.exec ~rex:ext_re name in
- let ext = Pcre.get_substring subs 1 in
- let ext = String.lowercase ext in
- List.assoc ext mime_types
- with
- Not_found -> "application/octet-stream"
+++ /dev/null
-(* Basic Merjis functions.
- * Copyright (C) 2004 Merjis Ltd.
- * Written By Richard W.M. Jones (rich@merjis.com)
- * $Id: merjisforwiki.mli,v 1.1 2004/09/07 10:14:09 rich Exp $
- *)
-
-(* This is a copy of an internal library which we use at Merjis. *)
-
-val identity : 'a -> 'a
-val unique : unit -> int
-val range : int -> int -> int list
-
-val string_contains : string -> string -> bool
-val string_of_char : char -> string
-val truncate : int -> string -> string
-val isspace : char -> bool
-val isalpha : char -> bool
-val isdigit : char -> bool
-val isalnum : char -> bool
-val islower : char -> bool
-val isupper : char -> bool
-val isxdigit : char -> bool
-val triml : ?test:(char -> bool) -> string -> string
-val trimr : ?test:(char -> bool) -> string -> string
-val trim : ?test:(char -> bool) -> string -> string
-val string_for_all : (char -> bool) -> string -> bool
-val string_exists : (char -> bool) -> string -> bool
-val string_is_whitespace : string -> bool
-
-val first : int -> 'a list -> 'a list
-val uniq : ?cmp:('a -> 'a -> int) -> 'b list -> 'b list
-val sort_uniq : ?cmp:('a -> 'a -> int) -> 'a list -> 'a list
-val frequency : ?cmp:('a -> 'a -> int) -> 'a list -> (int * 'a) list
-val group_by : ?cmp:('a -> 'a -> int) -> ('a * 'b) list -> ('a * 'b list) list
-
-val (//) : string -> string -> string
-val input_all_lines : in_channel -> string list
-val input_all : in_channel -> string
-val input_file : string -> string
-val output_file : string -> string -> unit
-val output_tempfile : string -> string
-
-val cmd : string -> unit
-val copy : string -> string -> unit
-val pget : string -> string list
-val unlink : string -> unit
-
-val notf : ('a -> bool) -> 'a -> bool
-
-val short_weekday : int -> string
-val short_month : int -> string
-
-val image_identify : string -> string * int * int
-val image_thumbnail : string -> int -> int -> string * string * int * int
-
-val mime_type_of_filename : string -> string
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: page.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: page.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open ExtString
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_template
open Cocanwiki_ok
+open Cocanwiki_date
let template_page = get_template "page.html"
let template_404 = get_template "page_404.html"
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: recent.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: recent.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cocanwiki
open Cocanwiki_template
+open Cocanwiki_date
let template = get_template "recent.html"
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: restore.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: restore.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_ok
open Cocanwiki_diff
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: restore_form.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: restore_form.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_template
open Cocanwiki_ok
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: sitemap.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: sitemap.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_template
+open Cocanwiki_date
+open Cocanwiki_strings
let template = get_template "sitemap.html"
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: undelete_file.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: undelete_file.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_template
open Cocanwiki_ok
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: undelete_file_form.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: undelete_file_form.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_template
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: undelete_image.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: undelete_image.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_template
open Cocanwiki_ok
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: undelete_image_form.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: undelete_image_form.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_template
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: upload_file.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: upload_file.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open ExtString
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_template
open Cocanwiki_ok
open Cocanwiki_emailnotify
+open Cocanwiki_images
let is_ws_re = Pcre.regexp "^\\s*$"
let is_whitespace str = Pcre.pmatch ~rex:is_ws_re str
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: upload_file_form.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: upload_file_form.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_template
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: upload_image.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: upload_image.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open ExtString
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_ok
open Cocanwiki_emailnotify
+open Cocanwiki_images
let is_ws_re = Pcre.regexp "^\\s*$"
let is_whitespace str = Pcre.pmatch ~rex:is_ws_re str
(* COCANWIKI scripts.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: upload_image_form.ml,v 1.2 2004/09/07 13:40:10 rich Exp $
+ * $Id: upload_image_form.ml,v 1.3 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open Cgi
open Printf
-open Merjisforwiki
-
open Cocanwiki
open Cocanwiki_template
(* Library of functions useful for people implementing a Wiki.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: wikilib.ml,v 1.1 2004/09/07 10:14:09 rich Exp $
+ * $Id: wikilib.ml,v 1.2 2004/09/07 14:58:34 rich Exp $
*)
open Apache
open ExtString
-open Merjisforwiki
-
(* Generate a URL for a new page with the given title. This code checks
* if the URL already exists in the database and can return one of several
* errors.