From d5e16b1ffdc77f6212666db32314b5b5f4f457a2 Mon Sep 17 00:00:00 2001 From: rich Date: Fri, 24 Sep 2004 17:07:10 +0000 Subject: [PATCH] View/download the mailing list. --- MANIFEST | 3 ++ conf/cocanwiki.conf | 3 +- scripts/Makefile | 3 +- scripts/mailing_list_view.ml | 59 ++++++++++++++++++++++++++++++++++++++++ templates/mailing_list_view.html | 54 ++++++++++++++++++++++++++++++++++++ templates/mailing_list_view.txt | 3 ++ 6 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 scripts/mailing_list_view.ml create mode 100644 templates/mailing_list_view.html create mode 100644 templates/mailing_list_view.txt diff --git a/MANIFEST b/MANIFEST index ab45561..0260904 100644 --- a/MANIFEST +++ b/MANIFEST @@ -110,6 +110,7 @@ scripts/mailing_list_confirm.ml scripts/mailing_list_form.ml scripts/mailing_list_send.ml scripts/mailing_list_unsubscribe.ml +scripts/mailing_list_view.ml scripts/page.ml scripts/page_email_confirm.ml scripts/page_email_form.ml @@ -177,6 +178,8 @@ templates/largest_pages.html templates/login_form.html templates/mailing_list_form.html templates/mailing_list_send.txt +templates/mailing_list_view.html +templates/mailing_list_view.txt templates/ok_error.html templates/page.html templates/page_404.html diff --git a/conf/cocanwiki.conf b/conf/cocanwiki.conf index 17e2b18..0731e9c 100644 --- a/conf/cocanwiki.conf +++ b/conf/cocanwiki.conf @@ -1,5 +1,5 @@ # Apache configuration for COCANWIKI. -# $Id: cocanwiki.conf,v 1.9 2004/09/24 16:41:16 rich Exp $ +# $Id: cocanwiki.conf,v 1.10 2004/09/24 17:07:10 rich Exp $ # Uncomment the following lines if necessary. You will probably need # to adjust the paths to reflect where cocanwiki is really installed. @@ -54,6 +54,7 @@ RewriteRule ^/_global.css$ /_bin/hoststyle.cmo [PT,L,QSA] RewriteRule ^/_images$ /_bin/images.cmo [PT,L,QSA] RewriteRule ^/_login$ /_bin/login_form.cmo [PT,L] RewriteRule ^/_logout$ /_bin/logout.cmo [PT,L,QSA] +RewriteRule ^/_mailing_list.csv$ /_bin/mailing_list_view.cmo?csv=1 [PT,L] RewriteRule ^/_ml_confirm$ /_bin/mailing_list_confirm.cmo [PT,L,QSA] RewriteRule ^/_ml_unsub$ /_bin/mailing_list_unsubscribe.cmo [PT,L,QSA] RewriteRule ^/_pe_confirm$ /_bin/page_email_confirm.cmo [PT,L,QSA] diff --git a/scripts/Makefile b/scripts/Makefile index d8529ef..1b92ab5 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -1,5 +1,5 @@ # Makefile for COCANWIKI. -# $Id: Makefile,v 1.24 2004/09/24 16:41:16 rich Exp $ +# $Id: Makefile,v 1.25 2004/09/24 17:07:10 rich Exp $ include ../Makefile.config @@ -71,6 +71,7 @@ OBJS := 00-TEMPLATE.cmo \ mailing_list_form.cmo \ mailing_list_send.cmo \ mailing_list_unsubscribe.cmo \ + mailing_list_view.cmo \ page.cmo \ page_email_confirm.cmo \ page_email_form.cmo \ diff --git a/scripts/mailing_list_view.ml b/scripts/mailing_list_view.ml new file mode 100644 index 0000000..1df4b0f --- /dev/null +++ b/scripts/mailing_list_view.ml @@ -0,0 +1,59 @@ +(* COCANWIKI - a wiki written in Objective CAML. + * Written by Richard W.M. Jones . + * Copyright (C) 2004 Merjis Ltd. + * $Id: mailing_list_view.ml,v 1.1 2004/09/24 17:07:10 rich Exp $ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + *) + +open Apache +open Registry +open Cgi +open Printf + +open Cocanwiki +open Cocanwiki_template +open Cocanwiki_date + +let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ = + let template = get_template dbh hostid "mailing_list_view.html" in + let template_csv = get_template dbh hostid "mailing_list_view.txt" in + + (* CSV format? *) + let csv = q#param_true "csv" in + + let content_type, template = + if csv then "text/comma-separated-values", template_csv + else "text/html", template in + + (* Get the mailing list. *) + let sth = dbh#prepare_cached "select email, entry_date from mailing_lists + where hostid = ? and pending is null + order by 1" in + sth#execute [`Int hostid]; + + let table = sth#map (function [`String email; `Date entry_date] -> + let entry_date = printable_date' entry_date in + [ "email", Template.VarString email; + "entry_date", Template.VarString entry_date ] + | _ -> assert false) in + + template#table "emails" table; + + q#template ~content_type template + +let () = + register_script ~restrict:[CanManageSite] run diff --git a/templates/mailing_list_view.html b/templates/mailing_list_view.html new file mode 100644 index 0000000..b29f4b0 --- /dev/null +++ b/templates/mailing_list_view.html @@ -0,0 +1,54 @@ + + + +View or download mailing list + + + + + +

View or download mailing list

+ + + +::table(emails):: + +::end:: +
Email address Joining date
::email_html:: ::entry_date_html::
+ +

+Download this list as a spreadsheet file, +suitable for loading into most spreadsheets. +

+ +

+NB: Right click on the above link and choose +Save Target As ... +

+ + + + + + + + + \ No newline at end of file diff --git a/templates/mailing_list_view.txt b/templates/mailing_list_view.txt new file mode 100644 index 0000000..3f6b4ea --- /dev/null +++ b/templates/mailing_list_view.txt @@ -0,0 +1,3 @@ +"Email address","Joining date" +::table(emails)::"::email::","::entry_date::" +::end:: \ No newline at end of file -- 1.8.3.1