From 7f5eacecb9a0353de411c82bd35caf21f5a73060 Mon Sep 17 00:00:00 2001 From: rich Date: Wed, 22 Sep 2004 12:04:28 +0000 Subject: [PATCH] Edit all host-specific settings. Version 1.1.1. Updated deps. Updated MANIFEST. --- MANIFEST | 3 ++ Makefile.config | 4 +- debian/changelog | 2 +- scripts/.depend | 4 ++ scripts/Makefile | 4 +- scripts/edit_host_settings.ml | 65 ++++++++++++++++++++++++++ scripts/edit_host_settings_form.ml | 84 ++++++++++++++++++++++++++++++++++ templates/edit_host_settings_form.html | 72 +++++++++++++++++++++++++++++ templates/host_menu.html | 4 +- 9 files changed, 236 insertions(+), 6 deletions(-) create mode 100644 scripts/edit_host_settings.ml create mode 100644 scripts/edit_host_settings_form.ml create mode 100644 templates/edit_host_settings_form.html diff --git a/MANIFEST b/MANIFEST index 855208f..386294f 100644 --- a/MANIFEST +++ b/MANIFEST @@ -84,6 +84,8 @@ scripts/edit_contact.ml scripts/edit_contact_form.ml scripts/edit_host_css.ml scripts/edit_host_css_form.ml +scripts/edit_host_settings.ml +scripts/edit_host_settings_form.ml scripts/edit_page_css.ml scripts/edit_page_css_form.ml scripts/edit_sitemenu.ml @@ -149,6 +151,7 @@ templates/edit.html templates/edit_conflict.html templates/edit_contact_form.html templates/edit_host_css_form.html +templates/edit_host_settings_form.html templates/edit_page_css_form.html templates/edit_sitemenu.html templates/edit_user_form.html diff --git a/Makefile.config b/Makefile.config index aa3d97d..5adfcf9 100644 --- a/Makefile.config +++ b/Makefile.config @@ -1,7 +1,7 @@ -# $Id: Makefile.config,v 1.3 2004/09/09 12:07:10 rich Exp $ +# $Id: Makefile.config,v 1.4 2004/09/22 12:04:28 rich Exp $ PACKAGE := cocanwiki -VERSION := 1.1.0 +VERSION := 1.1.1 # Normally ignored. However, if you are installing centrally (using # 'make pkg-install'), then the components are installed in the diff --git a/debian/changelog b/debian/changelog index 6628b7b..ea459c1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -cocanwiki (1.1.0-9) unstable; urgency=low +cocanwiki (1.1.1-1) unstable; urgency=low * Initial Release. diff --git a/scripts/.depend b/scripts/.depend index 4d33eb5..dcae864 100644 --- a/scripts/.depend +++ b/scripts/.depend @@ -68,6 +68,10 @@ edit_host_css.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_strings.cmo edit_host_css.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_strings.cmx edit_host_css_form.cmo: cocanwiki.cmo cocanwiki_template.cmi edit_host_css_form.cmx: cocanwiki.cmx cocanwiki_template.cmx +edit_host_settings.cmo: cocanwiki.cmo cocanwiki_ok.cmo +edit_host_settings.cmx: cocanwiki.cmx cocanwiki_ok.cmx +edit_host_settings_form.cmo: cocanwiki.cmo cocanwiki_template.cmi +edit_host_settings_form.cmx: cocanwiki.cmx cocanwiki_template.cmx edit_page_css.cmo: cocanwiki.cmo cocanwiki_diff.cmo cocanwiki_emailnotify.cmo \ cocanwiki_ok.cmo cocanwiki_strings.cmo edit_page_css.cmx: cocanwiki.cmx cocanwiki_diff.cmx cocanwiki_emailnotify.cmx \ diff --git a/scripts/Makefile b/scripts/Makefile index 3b377ae..afcb3ad 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -1,5 +1,5 @@ # Makefile for COCANWIKI. -# $Id: Makefile,v 1.19 2004/09/22 11:41:03 rich Exp $ +# $Id: Makefile,v 1.20 2004/09/22 12:04:28 rich Exp $ include ../Makefile.config @@ -45,6 +45,8 @@ OBJS := 00-TEMPLATE.cmo \ edit_contact_form.cmo \ edit_host_css.cmo \ edit_host_css_form.cmo \ + edit_host_settings.cmo \ + edit_host_settings_form.cmo \ edit_page_css.cmo \ edit_page_css_form.cmo \ edit_sitemenu.cmo \ diff --git a/scripts/edit_host_settings.ml b/scripts/edit_host_settings.ml new file mode 100644 index 0000000..d743865 --- /dev/null +++ b/scripts/edit_host_settings.ml @@ -0,0 +1,65 @@ +(* COCANWIKI - a wiki written in Objective CAML. + * Written by Richard W.M. Jones . + * Copyright (C) 2004 Merjis Ltd. + * $Id: edit_host_settings.ml,v 1.1 2004/09/22 12:04:28 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_ok + +let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ = + (* Cancel? *) + if q#param_true "cancel" then ( + (* Request cancelled. *) + q#redirect ("http://" ^ hostname ^ "/_bin/host_menu.cmo"); + raise CgiExit + ); + + (* Get parameters. *) + let edit_anon = q#param_true "edit_anon" in + let create_account_anon = q#param_true "create_account_anon" in + let theme_css = q#param "theme_css" in + let feedback_email = q#param "feedback_email" in + + let theme_css = if theme_css = "" then `Null else `String theme_css in + let feedback_email = + if feedback_email = "" then `Null else `String feedback_email in + + (* Update the database. *) + let sth = dbh#prepare_cached "update hosts set edit_anon = ?, + create_account_anon = ?, theme_css = ?, + feedback_email = ? + where id = ?" in + sth#execute [`Bool edit_anon; `Bool create_account_anon; + theme_css; feedback_email; + `Int hostid]; + + dbh#commit (); + + (* Finish off. *) + ok ~title:"Global settings updated" + ~buttons:[ok_button "/_bin/host_menu.cmo"] + q "The global settings were updated." + +let () = + register_script ~restrict:[CanManageSite] run diff --git a/scripts/edit_host_settings_form.ml b/scripts/edit_host_settings_form.ml new file mode 100644 index 0000000..3153e00 --- /dev/null +++ b/scripts/edit_host_settings_form.ml @@ -0,0 +1,84 @@ +(* COCANWIKI - a wiki written in Objective CAML. + * Written by Richard W.M. Jones . + * Copyright (C) 2004 Merjis Ltd. + * $Id: edit_host_settings_form.ml,v 1.1 2004/09/22 12:04:28 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 + +let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ = + let template = get_template dbh hostid "edit_host_settings_form.html" in + + (* List of themes. *) + let sth = dbh#prepare_cached "select theme_css, name, description + from themes order by 2, 1" in + sth#execute []; + + let themes = + sth#map (function [`String theme_css; `String name; `String description] -> + theme_css, (name, description) + | _ -> assert false) in + + (* Get lots of host-specific stuff from the database. *) + let sth = + dbh#prepare_cached + "select canonical_hostname, edit_anon, create_account_anon, theme_css, + feedback_email + from hosts where id = ?" in + sth#execute [`Int hostid]; + + let canonical_hostname, edit_anon, create_account_anon, theme_css, + feedback_email = + match sth#fetch1 () with + [ `String canonical_hostname; + `Bool edit_anon; `Bool create_account_anon; + (`String _ | `Null) as theme_css; + (`String _ | `Null) as feedback_email ] -> + let theme_css = + match theme_css with `String s -> s | `Null -> "" in + let feedback_email = + match feedback_email with `String s -> s | `Null -> "" in + canonical_hostname, edit_anon, create_account_anon, theme_css, + feedback_email + | _ -> assert false in + + template#set "canonical_hostname" canonical_hostname; + template#conditional "edit_anon" edit_anon; + template#conditional "create_account_anon" create_account_anon; + template#set "feedback_email" feedback_email; + + (* Themes table. *) + let table = + List.map (fun (css, (name, description)) -> + let selected = css = theme_css in + [ "theme_css", Template.VarString css; + "name", Template.VarString name; + "description", Template.VarString description; + "selected", Template.VarConditional selected ]) themes in + template#table "themes" table; + + q#template template + +let () = + register_script ~restrict:[CanManageSite] run diff --git a/templates/edit_host_settings_form.html b/templates/edit_host_settings_form.html new file mode 100644 index 0000000..a9bae54 --- /dev/null +++ b/templates/edit_host_settings_form.html @@ -0,0 +1,72 @@ + + + +Edit global settings + + + + + +

Edit global settings

+ +
+ + + + + + + + + + + + + + + + + + + +
Global stylesheet: Edit global stylesheet ...
Global permissions: +
+ +
Theme: + +
Feedback email address:
+ + +
+ + + + + + + + + \ No newline at end of file diff --git a/templates/host_menu.html b/templates/host_menu.html index de86a3e..c19e0e7 100644 --- a/templates/host_menu.html +++ b/templates/host_menu.html @@ -9,7 +9,7 @@

Global settings

- +
@@ -29,7 +29,7 @@ - + -- 1.8.3.1
Canonical hostname: ::canonical_hostname_html::
Theme: ::if(has_theme_css)::::theme_name_html::
::theme_description_html:: ::else:: Standard theme ::end::
::if(has_theme_css)::::theme_name_html::
::theme_description_html:: ::else:: Standard wiki theme ::end::
Feedback email address: