View/download the mailing list.
authorrich <rich>
Fri, 24 Sep 2004 17:07:10 +0000 (17:07 +0000)
committerrich <rich>
Fri, 24 Sep 2004 17:07:10 +0000 (17:07 +0000)
MANIFEST
conf/cocanwiki.conf
scripts/Makefile
scripts/mailing_list_view.ml [new file with mode: 0644]
templates/mailing_list_view.html [new file with mode: 0644]
templates/mailing_list_view.txt [new file with mode: 0644]

index ab45561..0260904 100644 (file)
--- 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
index 17e2b18..0731e9c 100644 (file)
@@ -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]
index d8529ef..1b92ab5 100644 (file)
@@ -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 (file)
index 0000000..1df4b0f
--- /dev/null
@@ -0,0 +1,59 @@
+(* COCANWIKI - a wiki written in Objective CAML.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * 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 (file)
index 0000000..b29f4b0
--- /dev/null
@@ -0,0 +1,54 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<title>View or download mailing list</title>
+<meta name="robots" content="noindex,nofollow"/>
+<meta name="author" content="http://www.merjis.com/" />
+<link rel="stylesheet" href="::theme_css_html_tag::" type="text/css" title="Standard"/>
+</head><body>
+
+<h1>View or download mailing list</h1>
+
+<table class="top_table">
+<tr><th> Email address </th> <th> Joining date </th></tr>
+::table(emails)::
+<tr><td> ::email_html:: </td> <td> ::entry_date_html:: </td> </tr>
+::end::
+</table>
+
+<p>
+<a href="/_mailing_list.csv">Download this list as a spreadsheet file,
+suitable for loading into most spreadsheets.</a>
+</p>
+
+<p>
+NB: Right click on the above link and choose
+<strong>Save Target As ...</strong>
+</p>
+
+<ul id="topmenu" class="menu">
+<li class="first"> <a href="/">Home&nbsp;page</a> </li>
+<li> <a href="/_sitemap">Sitemap</a> </li>
+<li> <a href="/_recent">Recent&nbsp;changes</a> </li>
+</ul>
+
+<div id="menu_div">
+<ul id="bottommenu" class="menu">
+<li class="first"> <a href="/">Home&nbsp;page</a> </li>
+::table(sitemenu)::<li> <a href="/::url_html_tag::">::label_html::</a> </li>
+::end::
+<li> <a href="/_sitemap">Sitemap</a> </li>
+</ul>
+</div>
+
+<div id="footer_div">
+<hr/>
+
+<ul id="footer" class="menu">
+<li class="first"> <a href="/copyright">Copyright &copy; ::year::</a> </li>
+<li> Powered by <a href="http://sandbox.merjis.com/">::cocanwiki_package_html:: ::cocanwiki_version_html::</a> </li>
+</ul>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/templates/mailing_list_view.txt b/templates/mailing_list_view.txt
new file mode 100644 (file)
index 0000000..3f6b4ea
--- /dev/null
@@ -0,0 +1,3 @@
+"Email address","Joining date"
+::table(emails)::"::email::","::entry_date::"
+::end::
\ No newline at end of file