From: rich Date: Tue, 7 Sep 2004 14:58:34 +0000 (+0000) Subject: Removed dependency on imported merjislib. X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=afe5e5f759988c04d9b3bcee7cf75e2c15e1d1d5;p=cocanwiki.git Removed dependency on imported merjislib. --- diff --git a/scripts/.depend b/scripts/.depend index 9ad65e0..037b575 100644 --- a/scripts/.depend +++ b/scripts/.depend @@ -1,122 +1,122 @@ -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 diff --git a/scripts/Makefile b/scripts/Makefile index 9ffd52f..9de6072 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -1,5 +1,5 @@ # 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 @@ -8,12 +8,14 @@ OCAMLCFLAGS := -w s -I +apache -I +pcre -I +dbi -I +extlib 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 \ diff --git a/scripts/admin/admin.ml b/scripts/admin/admin.ml index 78c93f5..907d00b 100644 --- a/scripts/admin/admin.ml +++ b/scripts/admin/admin.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,10 +9,9 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki open Cocanwiki_template +open Cocanwiki_date let template = get_template "admin/admin.html" diff --git a/scripts/admin/create_host.ml b/scripts/admin/create_host.ml index 62c55af..a2e9ccd 100644 --- a/scripts/admin/create_host.ml +++ b/scripts/admin/create_host.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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. @@ -13,7 +13,7 @@ open Registry open Cgi open Printf -open Merjisforwiki +open Cocanwiki_strings let split_re = Pcre.regexp "[\\s,;]+" diff --git a/scripts/admin/edit_emails.ml b/scripts/admin/edit_emails.ml index a3b39ea..4f5abb8 100644 --- a/scripts/admin/edit_emails.ml +++ b/scripts/admin/edit_emails.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,10 +9,9 @@ open Registry 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 "(.*)<(.*)>" diff --git a/scripts/admin/edit_host_css.ml b/scripts/admin/edit_host_css.ml index 4a25b66..8287fac 100644 --- a/scripts/admin/edit_host_css.ml +++ b/scripts/admin/edit_host_css.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,10 +9,9 @@ open Registry 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 diff --git a/scripts/admin/edit_hostnames.ml b/scripts/admin/edit_hostnames.ml index bff0fa8..f572cb9 100644 --- a/scripts/admin/edit_hostnames.ml +++ b/scripts/admin/edit_hostnames.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,10 +9,9 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki open Cocanwiki_ok +open Cocanwiki_strings let split_re = Pcre.regexp "[\\s,;]+" diff --git a/scripts/admin/host.ml b/scripts/admin/host.ml index 95056ab..5058722 100644 --- a/scripts/admin/host.ml +++ b/scripts/admin/host.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,10 +9,9 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki open Cocanwiki_template +open Cocanwiki_date let template = get_template "admin/host.html" diff --git a/scripts/cgi_expires.ml b/scripts/cgi_expires.ml index 48d6b8e..a9f248e 100644 --- a/scripts/cgi_expires.ml +++ b/scripts/cgi_expires.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -10,7 +10,7 @@ open Cgi open Printf -open Merjisforwiki +open Cocanwiki_date (* This library should eventually be integrated with mod_caml. XXX *) diff --git a/scripts/cocanwiki.ml b/scripts/cocanwiki.ml index cfe43f7..be6ce98 100644 --- a/scripts/cocanwiki.ml +++ b/scripts/cocanwiki.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,20 +9,10 @@ open Registry 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. *) diff --git a/scripts/cocanwiki_date.ml b/scripts/cocanwiki_date.ml index ba42c74..754fac4 100644 --- a/scripts/cocanwiki_date.ml +++ b/scripts/cocanwiki_date.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,7 +9,16 @@ open Registry 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, _) = diff --git a/scripts/cocanwiki_diff.ml b/scripts/cocanwiki_diff.ml index 0da7f42..7a10085 100644 --- a/scripts/cocanwiki_diff.ml +++ b/scripts/cocanwiki_diff.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,7 +9,7 @@ open Registry 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. diff --git a/scripts/cocanwiki_emailnotify.ml b/scripts/cocanwiki_emailnotify.ml index 79ca5e7..95121c7 100644 --- a/scripts/cocanwiki_emailnotify.ml +++ b/scripts/cocanwiki_emailnotify.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,8 +9,6 @@ open Registry open Cgi open Printf -open Merjisforwiki - (* This is where we coordinate email notification from various * scripts which create or update the wiki. *) diff --git a/scripts/cocanwiki_files.ml b/scripts/cocanwiki_files.ml new file mode 100644 index 0000000..ec53db4 --- /dev/null +++ b/scripts/cocanwiki_files.ml @@ -0,0 +1,71 @@ +(* 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 _ -> () diff --git a/scripts/cocanwiki_images.ml b/scripts/cocanwiki_images.ml new file mode 100644 index 0000000..e1a8089 --- /dev/null +++ b/scripts/cocanwiki_images.ml @@ -0,0 +1,106 @@ +(* COCANWIKI scripts. + * Written by Richard W.M. Jones . + * 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" diff --git a/scripts/cocanwiki_images.mli b/scripts/cocanwiki_images.mli new file mode 100644 index 0000000..6293bc1 --- /dev/null +++ b/scripts/cocanwiki_images.mli @@ -0,0 +1,10 @@ +(* COCANWIKI scripts. + * Written by Richard W.M. Jones . + * 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 diff --git a/scripts/cocanwiki_ok.ml b/scripts/cocanwiki_ok.ml index a7fe4ed..a1e43b6 100644 --- a/scripts/cocanwiki_ok.ml +++ b/scripts/cocanwiki_ok.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,8 +9,6 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki_template (* Override StdPages.ok and StdPages.error with out our versions. diff --git a/scripts/cocanwiki_strings.ml b/scripts/cocanwiki_strings.ml new file mode 100644 index 0000000..7e9abcb --- /dev/null +++ b/scripts/cocanwiki_strings.ml @@ -0,0 +1,86 @@ +(* 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 diff --git a/scripts/cocanwiki_template.ml b/scripts/cocanwiki_template.ml index ca0f915..2f39581 100644 --- a/scripts/cocanwiki_template.ml +++ b/scripts/cocanwiki_template.ml @@ -1,13 +1,13 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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. diff --git a/scripts/delete_file.ml b/scripts/delete_file.ml index 7159e01..430d008 100644 --- a/scripts/delete_file.ml +++ b/scripts/delete_file.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -13,8 +13,6 @@ open Cocanwiki 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 diff --git a/scripts/delete_file_form.ml b/scripts/delete_file_form.ml index 49814ed..11d2362 100644 --- a/scripts/delete_file_form.ml +++ b/scripts/delete_file_form.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -12,8 +12,6 @@ open Printf open Cocanwiki open Cocanwiki_template -open Merjisforwiki - let template = get_template "delete_file_form.html" let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ = diff --git a/scripts/delete_image.ml b/scripts/delete_image.ml index 04c7f6f..1480e86 100644 --- a/scripts/delete_image.ml +++ b/scripts/delete_image.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -13,8 +13,6 @@ open Cocanwiki 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 diff --git a/scripts/delete_image_form.ml b/scripts/delete_image_form.ml index 3c87e27..f004f08 100644 --- a/scripts/delete_image_form.ml +++ b/scripts/delete_image_form.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,8 +9,6 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki open Cocanwiki_template diff --git a/scripts/diff.ml b/scripts/diff.ml index 24ffd4f..bf5eb42 100644 --- a/scripts/diff.ml +++ b/scripts/diff.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,8 +9,6 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki open Cocanwiki_template open Cocanwiki_diff diff --git a/scripts/edit.ml b/scripts/edit.ml index 19324f9..c00c79d 100644 --- a/scripts/edit.ml +++ b/scripts/edit.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -11,13 +11,12 @@ open Printf 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" diff --git a/scripts/edit_page_css.ml b/scripts/edit_page_css.ml index ff26ada..43219aa 100644 --- a/scripts/edit_page_css.ml +++ b/scripts/edit_page_css.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,12 +9,11 @@ open Registry 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 diff --git a/scripts/file.ml b/scripts/file.ml index ce5a83c..9b9f9a1 100644 --- a/scripts/file.ml +++ b/scripts/file.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,8 +9,6 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ = diff --git a/scripts/files.ml b/scripts/files.ml index 6421bb7..3deb0f2 100644 --- a/scripts/files.ml +++ b/scripts/files.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,8 +9,6 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki open Cocanwiki_template diff --git a/scripts/history.ml b/scripts/history.ml index 7acbd86..bc008c4 100644 --- a/scripts/history.ml +++ b/scripts/history.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,10 +9,9 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki open Cocanwiki_template +open Cocanwiki_date let template = get_template "history.html" diff --git a/scripts/image.ml b/scripts/image.ml index b6a1f4d..e81165d 100644 --- a/scripts/image.ml +++ b/scripts/image.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,9 +9,6 @@ open Registry open Cgi open Printf -open Merjisforwiki - -open Cocanwiki open Cocanwiki let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ = diff --git a/scripts/images.ml b/scripts/images.ml index 79c7db9..30f585f 100644 --- a/scripts/images.ml +++ b/scripts/images.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,8 +9,6 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki open Cocanwiki_template diff --git a/scripts/merjisforwiki.ml b/scripts/merjisforwiki.ml deleted file mode 100644 index 6182ab9..0000000 --- a/scripts/merjisforwiki.ml +++ /dev/null @@ -1,334 +0,0 @@ -(* 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" diff --git a/scripts/merjisforwiki.mli b/scripts/merjisforwiki.mli deleted file mode 100644 index ca7b2fd..0000000 --- a/scripts/merjisforwiki.mli +++ /dev/null @@ -1,56 +0,0 @@ -(* 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 diff --git a/scripts/page.ml b/scripts/page.ml index 900b8b2..6c7bb75 100644 --- a/scripts/page.ml +++ b/scripts/page.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -11,11 +11,10 @@ open Printf 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" diff --git a/scripts/recent.ml b/scripts/recent.ml index a1b53be..f726245 100644 --- a/scripts/recent.ml +++ b/scripts/recent.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -11,6 +11,7 @@ open Printf open Cocanwiki open Cocanwiki_template +open Cocanwiki_date let template = get_template "recent.html" diff --git a/scripts/restore.ml b/scripts/restore.ml index 64b5f47..c8f9d3f 100644 --- a/scripts/restore.ml +++ b/scripts/restore.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,8 +9,6 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki open Cocanwiki_ok open Cocanwiki_diff diff --git a/scripts/restore_form.ml b/scripts/restore_form.ml index 820bac6..b7dde16 100644 --- a/scripts/restore_form.ml +++ b/scripts/restore_form.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,8 +9,6 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki open Cocanwiki_template open Cocanwiki_ok diff --git a/scripts/sitemap.ml b/scripts/sitemap.ml index 39e1791..ecf0d81 100644 --- a/scripts/sitemap.ml +++ b/scripts/sitemap.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,10 +9,10 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki open Cocanwiki_template +open Cocanwiki_date +open Cocanwiki_strings let template = get_template "sitemap.html" diff --git a/scripts/undelete_file.ml b/scripts/undelete_file.ml index 054fa55..f95c1e9 100644 --- a/scripts/undelete_file.ml +++ b/scripts/undelete_file.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,8 +9,6 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki open Cocanwiki_template open Cocanwiki_ok diff --git a/scripts/undelete_file_form.ml b/scripts/undelete_file_form.ml index 6560285..152842d 100644 --- a/scripts/undelete_file_form.ml +++ b/scripts/undelete_file_form.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,8 +9,6 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki open Cocanwiki_template diff --git a/scripts/undelete_image.ml b/scripts/undelete_image.ml index c258730..e0d9f57 100644 --- a/scripts/undelete_image.ml +++ b/scripts/undelete_image.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,8 +9,6 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki open Cocanwiki_template open Cocanwiki_ok diff --git a/scripts/undelete_image_form.ml b/scripts/undelete_image_form.ml index 7ccd30f..a287e42 100644 --- a/scripts/undelete_image_form.ml +++ b/scripts/undelete_image_form.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,8 +9,6 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki open Cocanwiki_template diff --git a/scripts/upload_file.ml b/scripts/upload_file.ml index 0f90e19..77c5e9e 100644 --- a/scripts/upload_file.ml +++ b/scripts/upload_file.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -11,12 +11,11 @@ open Printf 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 diff --git a/scripts/upload_file_form.ml b/scripts/upload_file_form.ml index 93e8242..24f8e22 100644 --- a/scripts/upload_file_form.ml +++ b/scripts/upload_file_form.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,8 +9,6 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki open Cocanwiki_template diff --git a/scripts/upload_image.ml b/scripts/upload_image.ml index 64eb357..579f609 100644 --- a/scripts/upload_image.ml +++ b/scripts/upload_image.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -11,11 +11,10 @@ open Printf 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 diff --git a/scripts/upload_image_form.ml b/scripts/upload_image_form.ml index 6ad7c7f..bdd18f3 100644 --- a/scripts/upload_image_form.ml +++ b/scripts/upload_image_form.ml @@ -1,7 +1,7 @@ (* COCANWIKI scripts. * Written by Richard W.M. Jones . * 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 @@ -9,8 +9,6 @@ open Registry open Cgi open Printf -open Merjisforwiki - open Cocanwiki open Cocanwiki_template diff --git a/scripts/wikilib.ml b/scripts/wikilib.ml index 2599f0e..f9e8fda 100644 --- a/scripts/wikilib.ml +++ b/scripts/wikilib.ml @@ -1,7 +1,7 @@ (* Library of functions useful for people implementing a Wiki. * Written by Richard W.M. Jones . * 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 @@ -12,8 +12,6 @@ open Printf 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.