From 34a5c44488bdcede056885c7a3831bd5b37b37a3 Mon Sep 17 00:00:00 2001 From: rich Date: Wed, 22 Sep 2004 11:41:03 +0000 Subject: [PATCH 1/1] Global settings display. Edit global CSS. Database: - Added themes table. - Constraint hosts.theme_css to be in themes table. Updated MANIFEST. --- MANIFEST | 5 ++ cocanwiki.sql | 122 +++++++++++++++++++++++++------------- scripts/.depend | 10 +++- scripts/Makefile | 5 +- scripts/edit_host_css.ml | 57 ++++++++++++++++++ scripts/edit_host_css_form.ml | 47 +++++++++++++++ scripts/host_menu.ml | 78 ++++++++++++++++++++++++ templates/edit_host_css_form.html | 49 +++++++++++++++ templates/host_menu.html | 69 +++++++++++++++++++++ templates/page.html | 2 +- 10 files changed, 399 insertions(+), 45 deletions(-) create mode 100644 scripts/edit_host_css.ml create mode 100644 scripts/edit_host_css_form.ml create mode 100644 scripts/host_menu.ml create mode 100644 templates/edit_host_css_form.html create mode 100644 templates/host_menu.html diff --git a/MANIFEST b/MANIFEST index 1d0591c..855208f 100644 --- a/MANIFEST +++ b/MANIFEST @@ -82,6 +82,8 @@ scripts/diff.ml scripts/edit.ml scripts/edit_contact.ml scripts/edit_contact_form.ml +scripts/edit_host_css.ml +scripts/edit_host_css_form.ml scripts/edit_page_css.ml scripts/edit_page_css_form.ml scripts/edit_sitemenu.ml @@ -92,6 +94,7 @@ scripts/files.ml scripts/forgot_password.ml scripts/forgot_password_form.ml scripts/history.ml +scripts/host_menu.ml scripts/hoststyle.ml scripts/image.ml scripts/images.ml @@ -145,12 +148,14 @@ templates/diff.html templates/edit.html templates/edit_conflict.html templates/edit_contact_form.html +templates/edit_host_css_form.html templates/edit_page_css_form.html templates/edit_sitemenu.html templates/edit_user_form.html templates/files.html templates/forgot_password_form.html templates/history.html +templates/host_menu.html templates/images.html templates/largest_pages.html templates/login_form.html diff --git a/cocanwiki.sql b/cocanwiki.sql index f919920..119ba0f 100644 --- a/cocanwiki.sql +++ b/cocanwiki.sql @@ -54,7 +54,7 @@ GRANT ALL ON TABLE pages TO "www-data"; SET SESSION AUTHORIZATION 'rich'; -- --- TOC entry 29 (OID 536004) +-- TOC entry 31 (OID 536004) -- Name: pages_id_seq; Type: ACL; Schema: public; Owner: rich -- @@ -91,7 +91,7 @@ GRANT ALL ON TABLE contents TO "www-data"; SET SESSION AUTHORIZATION 'rich'; -- --- TOC entry 30 (OID 536021) +-- TOC entry 32 (OID 536021) -- Name: contents_id_seq; Type: ACL; Schema: public; Owner: rich -- @@ -129,7 +129,7 @@ GRANT ALL ON TABLE hosts TO "www-data"; SET SESSION AUTHORIZATION 'rich'; -- --- TOC entry 31 (OID 536371) +-- TOC entry 33 (OID 536371) -- Name: hosts_id_seq; Type: ACL; Schema: public; Owner: rich -- @@ -222,7 +222,7 @@ GRANT ALL ON TABLE images TO "www-data"; SET SESSION AUTHORIZATION 'rich'; -- --- TOC entry 32 (OID 537151) +-- TOC entry 34 (OID 537151) -- Name: images_id_seq; Type: ACL; Schema: public; Owner: rich -- @@ -261,7 +261,7 @@ GRANT ALL ON TABLE files TO "www-data"; SET SESSION AUTHORIZATION 'rich'; -- --- TOC entry 33 (OID 537166) +-- TOC entry 35 (OID 537166) -- Name: files_id_seq; Type: ACL; Schema: public; Owner: rich -- @@ -303,7 +303,7 @@ GRANT ALL ON TABLE users TO "www-data"; SET SESSION AUTHORIZATION 'rich'; -- --- TOC entry 34 (OID 540816) +-- TOC entry 36 (OID 540816) -- Name: users_id_seq; Type: ACL; Schema: public; Owner: rich -- @@ -384,7 +384,7 @@ GRANT ALL ON TABLE contacts TO "www-data"; SET SESSION AUTHORIZATION 'rich'; -- --- TOC entry 35 (OID 542605) +-- TOC entry 37 (OID 542605) -- Name: contacts_id_seq; Type: ACL; Schema: public; Owner: rich -- @@ -417,7 +417,30 @@ GRANT ALL ON TABLE contact_emails TO "www-data"; SET SESSION AUTHORIZATION 'rich'; -- --- TOC entry 40 (OID 536388) +-- TOC entry 29 (OID 543499) +-- Name: themes; Type: TABLE; Schema: public; Owner: rich +-- + +CREATE TABLE themes ( + theme_css text NOT NULL, + name text NOT NULL, + description text NOT NULL +); + + +-- +-- TOC entry 30 (OID 543499) +-- Name: themes; Type: ACL; Schema: public; Owner: rich +-- + +REVOKE ALL ON TABLE themes FROM PUBLIC; +GRANT SELECT ON TABLE themes TO "www-data"; + + +SET SESSION AUTHORIZATION 'rich'; + +-- +-- TOC entry 42 (OID 536388) -- Name: hostnames_hostid_name_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -425,7 +448,7 @@ CREATE UNIQUE INDEX hostnames_hostid_name_uq ON hostnames USING btree (hostid, n -- --- TOC entry 41 (OID 536389) +-- TOC entry 43 (OID 536389) -- Name: hostnams_name_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -433,7 +456,7 @@ CREATE UNIQUE INDEX hostnams_name_uq ON hostnames USING btree (name); -- --- TOC entry 37 (OID 536419) +-- TOC entry 39 (OID 536419) -- Name: pages_url_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -441,7 +464,7 @@ CREATE UNIQUE INDEX pages_url_uq ON pages USING btree (hostid, url); -- --- TOC entry 42 (OID 536924) +-- TOC entry 44 (OID 536924) -- Name: email_notify_email_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -449,7 +472,7 @@ CREATE UNIQUE INDEX email_notify_email_uq ON email_notify USING btree (hostid, e -- --- TOC entry 43 (OID 540251) +-- TOC entry 45 (OID 540251) -- Name: images_name_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -457,7 +480,7 @@ CREATE UNIQUE INDEX images_name_uq ON images USING btree (hostid, name); -- --- TOC entry 45 (OID 540252) +-- TOC entry 47 (OID 540252) -- Name: files_name_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -465,7 +488,7 @@ CREATE UNIQUE INDEX files_name_uq ON files USING btree (hostid, name); -- --- TOC entry 48 (OID 540831) +-- TOC entry 50 (OID 540831) -- Name: users_name_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -473,7 +496,7 @@ CREATE UNIQUE INDEX users_name_uq ON users USING btree (hostid, name); -- --- TOC entry 47 (OID 540946) +-- TOC entry 49 (OID 540946) -- Name: users_id_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -481,7 +504,7 @@ CREATE UNIQUE INDEX users_id_uq ON users USING btree (hostid, id); -- --- TOC entry 50 (OID 540970) +-- TOC entry 52 (OID 540970) -- Name: sitemenu_ordering_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -489,7 +512,7 @@ CREATE UNIQUE INDEX sitemenu_ordering_uq ON sitemenu USING btree (hostid, orderi -- --- TOC entry 51 (OID 540971) +-- TOC entry 53 (OID 540971) -- Name: sitemenu_url_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -497,7 +520,7 @@ CREATE UNIQUE INDEX sitemenu_url_uq ON sitemenu USING btree (hostid, url); -- --- TOC entry 53 (OID 542626) +-- TOC entry 55 (OID 542626) -- Name: contact_emails_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -505,7 +528,15 @@ CREATE UNIQUE INDEX contact_emails_uq ON contact_emails USING btree (contactid, -- --- TOC entry 36 (OID 536012) +-- TOC entry 56 (OID 543505) +-- Name: themes_theme_css_uq; Type: INDEX; Schema: public; Owner: rich +-- + +CREATE UNIQUE INDEX themes_theme_css_uq ON themes USING btree (theme_css); + + +-- +-- TOC entry 38 (OID 536012) -- Name: pages_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -514,7 +545,7 @@ ALTER TABLE ONLY pages -- --- TOC entry 38 (OID 536027) +-- TOC entry 40 (OID 536027) -- Name: contents_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -523,7 +554,7 @@ ALTER TABLE ONLY contents -- --- TOC entry 39 (OID 536377) +-- TOC entry 41 (OID 536377) -- Name: hosts_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -532,7 +563,7 @@ ALTER TABLE ONLY hosts -- --- TOC entry 44 (OID 537158) +-- TOC entry 46 (OID 537158) -- Name: images_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -541,7 +572,7 @@ ALTER TABLE ONLY images -- --- TOC entry 46 (OID 537173) +-- TOC entry 48 (OID 537173) -- Name: files_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -550,7 +581,7 @@ ALTER TABLE ONLY files -- --- TOC entry 49 (OID 540825) +-- TOC entry 51 (OID 540825) -- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -559,7 +590,7 @@ ALTER TABLE ONLY users -- --- TOC entry 52 (OID 542611) +-- TOC entry 54 (OID 542611) -- Name: contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -568,7 +599,7 @@ ALTER TABLE ONLY contacts -- --- TOC entry 58 (OID 536029) +-- TOC entry 61 (OID 536029) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -577,7 +608,7 @@ ALTER TABLE ONLY contents -- --- TOC entry 60 (OID 536384) +-- TOC entry 64 (OID 536384) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -586,7 +617,7 @@ ALTER TABLE ONLY hostnames -- --- TOC entry 59 (OID 536394) +-- TOC entry 62 (OID 536394) -- Name: hosts_hostname_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -595,7 +626,7 @@ ALTER TABLE ONLY hosts -- --- TOC entry 54 (OID 536404) +-- TOC entry 57 (OID 536404) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -604,7 +635,7 @@ ALTER TABLE ONLY pages -- --- TOC entry 61 (OID 536920) +-- TOC entry 65 (OID 536920) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -613,7 +644,7 @@ ALTER TABLE ONLY email_notify -- --- TOC entry 62 (OID 537160) +-- TOC entry 66 (OID 537160) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -622,7 +653,7 @@ ALTER TABLE ONLY images -- --- TOC entry 63 (OID 537175) +-- TOC entry 67 (OID 537175) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -631,7 +662,7 @@ ALTER TABLE ONLY files -- --- TOC entry 55 (OID 539155) +-- TOC entry 58 (OID 539155) -- Name: pages_redirect_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -640,7 +671,7 @@ ALTER TABLE ONLY pages -- --- TOC entry 64 (OID 540827) +-- TOC entry 68 (OID 540827) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -649,7 +680,7 @@ ALTER TABLE ONLY users -- --- TOC entry 65 (OID 540837) +-- TOC entry 69 (OID 540837) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -658,7 +689,7 @@ ALTER TABLE ONLY usercookies -- --- TOC entry 56 (OID 540942) +-- TOC entry 59 (OID 540942) -- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -667,7 +698,7 @@ ALTER TABLE ONLY pages -- --- TOC entry 57 (OID 540947) +-- TOC entry 60 (OID 540947) -- Name: pages_user_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -676,7 +707,7 @@ ALTER TABLE ONLY pages -- --- TOC entry 66 (OID 540966) +-- TOC entry 70 (OID 540966) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -685,7 +716,7 @@ ALTER TABLE ONLY sitemenu -- --- TOC entry 67 (OID 540972) +-- TOC entry 71 (OID 540972) -- Name: sitemenu_url_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -694,7 +725,7 @@ ALTER TABLE ONLY sitemenu -- --- TOC entry 68 (OID 542613) +-- TOC entry 72 (OID 542613) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -703,7 +734,7 @@ ALTER TABLE ONLY contacts -- --- TOC entry 69 (OID 542622) +-- TOC entry 73 (OID 542622) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -711,6 +742,15 @@ ALTER TABLE ONLY contact_emails ADD CONSTRAINT "$1" FOREIGN KEY (contactid) REFERENCES contacts(id); +-- +-- TOC entry 63 (OID 543506) +-- Name: hosts_theme_css_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich +-- + +ALTER TABLE ONLY hosts + ADD CONSTRAINT hosts_theme_css_cn FOREIGN KEY (theme_css) REFERENCES themes(theme_css); + + SET SESSION AUTHORIZATION 'postgres'; -- diff --git a/scripts/.depend b/scripts/.depend index d32b9d8..4d33eb5 100644 --- a/scripts/.depend +++ b/scripts/.depend @@ -60,10 +60,14 @@ edit.cmo: cocanwiki.cmo cocanwiki_diff.cmo cocanwiki_emailnotify.cmo \ cocanwiki_ok.cmo cocanwiki_strings.cmo cocanwiki_template.cmi edit.cmx: cocanwiki.cmx cocanwiki_diff.cmx cocanwiki_emailnotify.cmx \ cocanwiki_ok.cmx cocanwiki_strings.cmx cocanwiki_template.cmx -edit_contact.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_template.cmi -edit_contact.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_template.cmx +edit_contact.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_strings.cmo +edit_contact.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_strings.cmx edit_contact_form.cmo: cocanwiki.cmo cocanwiki_template.cmi edit_contact_form.cmx: cocanwiki.cmx cocanwiki_template.cmx +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_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 \ @@ -88,6 +92,8 @@ forgot_password_form.cmo: cocanwiki.cmo cocanwiki_template.cmi forgot_password_form.cmx: cocanwiki.cmx cocanwiki_template.cmx history.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_template.cmi history.cmx: cocanwiki.cmx cocanwiki_date.cmx cocanwiki_template.cmx +host_menu.cmo: cocanwiki.cmo cocanwiki_template.cmi +host_menu.cmx: cocanwiki.cmx cocanwiki_template.cmx hoststyle.cmo: cgi_expires.cmo cocanwiki.cmo cocanwiki_template.cmi hoststyle.cmx: cgi_expires.cmx cocanwiki.cmx cocanwiki_template.cmx image.cmo: cgi_expires.cmo cocanwiki.cmo diff --git a/scripts/Makefile b/scripts/Makefile index fdeaedf..3b377ae 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -1,5 +1,5 @@ # Makefile for COCANWIKI. -# $Id: Makefile,v 1.18 2004/09/21 18:24:15 rich Exp $ +# $Id: Makefile,v 1.19 2004/09/22 11:41:03 rich Exp $ include ../Makefile.config @@ -43,6 +43,8 @@ OBJS := 00-TEMPLATE.cmo \ edit.cmo \ edit_contact.cmo \ edit_contact_form.cmo \ + edit_host_css.cmo \ + edit_host_css_form.cmo \ edit_page_css.cmo \ edit_page_css_form.cmo \ edit_sitemenu.cmo \ @@ -54,6 +56,7 @@ OBJS := 00-TEMPLATE.cmo \ forgot_password_form.cmo \ history.cmo \ hoststyle.cmo \ + host_menu.cmo \ image.cmo \ images.cmo \ largest_pages.cmo \ diff --git a/scripts/edit_host_css.ml b/scripts/edit_host_css.ml new file mode 100644 index 0000000..4f036e7 --- /dev/null +++ b/scripts/edit_host_css.ml @@ -0,0 +1,57 @@ +(* COCANWIKI - a wiki written in Objective CAML. + * Written by Richard W.M. Jones . + * Copyright (C) 2004 Merjis Ltd. + * $Id: edit_host_css.ml,v 1.1 2004/09/22 11:41:03 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 +open Cocanwiki_strings + +let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ = + let css = q#param "css" in + + let css = if string_is_whitespace css then `Null else `String css in + + (* XXX We should version the global stylesheet. However this requires + * some fairly non-trivial coding. + *) + let sth = dbh#prepare_cached "update hosts set css = ? where id = ?" in + sth#execute [css; `Int hostid]; + + dbh#commit (); + + let buttons = [ + ok_button "/_bin/host_menu.cmo"; + { StdPages.label = "Edit stylesheet again"; + StdPages.link = "/_bin/edit_host_css_form.cmo"; + StdPages.method_ = None; + StdPages.params = [] } + ] in + + ok ~title:"Global stylesheet changed" ~buttons + q ("The stylesheet was changed successfully. " ^ + "Note: You must RELOAD the page to see changes to stylesheets.") + +let () = + register_script run diff --git a/scripts/edit_host_css_form.ml b/scripts/edit_host_css_form.ml new file mode 100644 index 0000000..7a673c6 --- /dev/null +++ b/scripts/edit_host_css_form.ml @@ -0,0 +1,47 @@ +(* COCANWIKI - a wiki written in Objective CAML. + * Written by Richard W.M. Jones . + * Copyright (C) 2004 Merjis Ltd. + * $Id: edit_host_css_form.ml,v 1.1 2004/09/22 11:41:03 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_css_form.html" in + + let sth = dbh#prepare_cached "select css from hosts where id = ?" in + sth#execute [`Int hostid]; + + let css = + match sth#fetch1 () with + | [ `Null ] -> "" + | [ `String css ] -> css + | _ -> assert false in + + template#set "css" css; + + q#template template + +let () = + register_script run diff --git a/scripts/host_menu.ml b/scripts/host_menu.ml new file mode 100644 index 0000000..2583e07 --- /dev/null +++ b/scripts/host_menu.ml @@ -0,0 +1,78 @@ +(* COCANWIKI - a wiki written in Objective CAML. + * Written by Richard W.M. Jones . + * Copyright (C) 2004 Merjis Ltd. + * $Id: host_menu.ml,v 1.1 2004/09/22 11:41:03 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 "host_menu.html" in + + (* Get lots of host-specific stuff from the database. *) + let sth = + dbh#prepare_cached + "select h.canonical_hostname, h.css is not null, h.edit_anon, + h.create_account_anon, h.theme_css is not null, + t.name, t.description, h.feedback_email + from hosts h left outer join themes t on h.theme_css = t.theme_css + where h.id = ?" in + sth#execute [`Int hostid]; + + let canonical_hostname, has_global_css, edit_anon, create_account_anon, + has_theme_css, theme_name, theme_description, has_feedback_email, + feedback_email = + match sth#fetch1 () with + [ `String canonical_hostname; `Bool has_global_css; + `Bool edit_anon; `Bool create_account_anon; `Bool has_theme_css; + (`String _ | `Null) as theme_name; + (`String _ | `Null) as theme_description; + (`String _ | `Null) as feedback_email ] -> + let theme_name = + match theme_name with `String s -> s | `Null -> "" in + let theme_description = + match theme_description with `String s -> s | `Null -> "" in + let feedback_email, has_feedback_email = + match feedback_email with + `String s -> s, true + | `Null -> "", false in + canonical_hostname, has_global_css, edit_anon, create_account_anon, + has_theme_css, theme_name, theme_description, has_feedback_email, + feedback_email + | _ -> assert false in + + template#set "canonical_hostname" canonical_hostname; + template#conditional "has_global_css" has_global_css; + template#conditional "edit_anon" edit_anon; + template#conditional "create_account_anon" create_account_anon; + template#conditional "has_theme_css" has_theme_css; + template#set "theme_name" theme_name; + template#set "theme_description" theme_description; + template#conditional "has_feedback_email" has_feedback_email; + template#set "feedback_email" feedback_email; + + q#template template + +let () = + register_script ~restrict:[CanManageSite] run diff --git a/templates/edit_host_css_form.html b/templates/edit_host_css_form.html new file mode 100644 index 0000000..533ffd9 --- /dev/null +++ b/templates/edit_host_css_form.html @@ -0,0 +1,49 @@ + + + +Edit global stylesheet + + + + +

Edit global stylesheet

+ +
+

+Editing the global stylesheet: +

+ +

+ +

+ +

+ +

+
+ + + + + + + + + \ No newline at end of file diff --git a/templates/host_menu.html b/templates/host_menu.html new file mode 100644 index 0000000..de86a3e --- /dev/null +++ b/templates/host_menu.html @@ -0,0 +1,69 @@ + + + +Global settings + + + + + +

Global settings

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Canonical hostname: ::canonical_hostname_html::
Global stylesheet: ::if(has_global_css)::View global stylesheet::else::No global stylesheet for this site.::end::
+Edit global stylesheet ...
Allow anonymous edits: ::if(edit_anon)::Yes::else::No::end::
Allow anyone to create accounts: ::if(create_account_anon)::Yes::else::No::end::
Theme: ::if(has_theme_css)::::theme_name_html::
::theme_description_html:: ::else:: Standard theme ::end::
Feedback email address: ::if(has_feedback_email):: ::feedback_email_html:: ::else:: None set up yet. ::end::
+ +

+Edit these settings ... +

+ + + + + + + + + \ No newline at end of file diff --git a/templates/page.html b/templates/page.html index 77075fa..af35198 100644 --- a/templates/page.html +++ b/templates/page.html @@ -74,7 +74,7 @@
  • Contact forms
  • ::end:: ::if(can_manage_site):: -
  • Global settings
  • +
  • Global settings
  • ::end:: ::if(can_edit_global_css)::
  • Edit global stylesheet
  • -- 1.8.3.1