From 5de1a8f3d78350fbe870749f26c3ad0f5f9519dd Mon Sep 17 00:00:00 2001 From: rich Date: Sat, 23 Oct 2004 10:13:20 +0000 Subject: [PATCH] Added the 'powered by' tag at the bottom of the page. --- cocanwiki.sql | 176 +++++++++++++++++++++++--------------- scripts/lib/cocanwiki_template.ml | 30 +++++-- templates/footer.html | 2 +- templates/page.html | 2 +- 4 files changed, 134 insertions(+), 76 deletions(-) diff --git a/cocanwiki.sql b/cocanwiki.sql index 51d9e71..0f720f3 100644 --- a/cocanwiki.sql +++ b/cocanwiki.sql @@ -48,7 +48,7 @@ GRANT ALL ON TABLE pages TO "www-data"; -- --- TOC entry 46 (OID 536004) +-- TOC entry 48 (OID 536004) -- Name: pages_id_seq; Type: ACL; Schema: public; Owner: rich -- @@ -81,7 +81,7 @@ GRANT ALL ON TABLE contents TO "www-data"; -- --- TOC entry 47 (OID 536021) +-- TOC entry 49 (OID 536021) -- Name: contents_id_seq; Type: ACL; Schema: public; Owner: rich -- @@ -106,7 +106,8 @@ CREATE TABLE hosts ( is_template boolean DEFAULT false NOT NULL, search_box boolean DEFAULT true NOT NULL, view_anon boolean DEFAULT true NOT NULL, - navigation boolean DEFAULT false NOT NULL + navigation boolean DEFAULT false NOT NULL, + powered_by integer ); @@ -120,7 +121,7 @@ GRANT ALL ON TABLE hosts TO "www-data"; -- --- TOC entry 48 (OID 536371) +-- TOC entry 50 (OID 536371) -- Name: hosts_id_seq; Type: ACL; Schema: public; Owner: rich -- @@ -184,7 +185,7 @@ GRANT ALL ON TABLE images TO "www-data"; -- --- TOC entry 49 (OID 537151) +-- TOC entry 51 (OID 537151) -- Name: images_id_seq; Type: ACL; Schema: public; Owner: rich -- @@ -219,7 +220,7 @@ GRANT ALL ON TABLE files TO "www-data"; -- --- TOC entry 50 (OID 537166) +-- TOC entry 52 (OID 537166) -- Name: files_id_seq; Type: ACL; Schema: public; Owner: rich -- @@ -260,7 +261,7 @@ GRANT ALL ON TABLE users TO "www-data"; -- --- TOC entry 51 (OID 540816) +-- TOC entry 53 (OID 540816) -- Name: users_id_seq; Type: ACL; Schema: public; Owner: rich -- @@ -333,7 +334,7 @@ GRANT ALL ON TABLE contacts TO "www-data"; -- --- TOC entry 52 (OID 542605) +-- TOC entry 54 (OID 542605) -- Name: contacts_id_seq; Type: ACL; Schema: public; Owner: rich -- @@ -498,7 +499,7 @@ GRANT SELECT ON TABLE templates TO "www-data"; -- --- TOC entry 53 (OID 547939) +-- TOC entry 55 (OID 547939) -- Name: templates_id_seq; Type: ACL; Schema: public; Owner: rich -- @@ -551,7 +552,7 @@ GRANT ALL ON TABLE messages TO "www-data"; -- --- TOC entry 54 (OID 551675) +-- TOC entry 56 (OID 551675) -- Name: messages_id_seq; Type: ACL; Schema: public; Owner: rich -- @@ -581,7 +582,28 @@ GRANT ALL ON TABLE msg_references TO "www-data"; -- --- TOC entry 61 (OID 536388) +-- TOC entry 46 (OID 607075) +-- Name: powered_by; Type: TABLE; Schema: public; Owner: rich +-- + +CREATE TABLE powered_by ( + id serial NOT NULL, + name text NOT NULL, + url text NOT NULL +); + + +-- +-- TOC entry 47 (OID 607075) +-- Name: powered_by; Type: ACL; Schema: public; Owner: rich +-- + +REVOKE ALL ON TABLE powered_by FROM PUBLIC; +GRANT SELECT ON TABLE powered_by TO "www-data"; + + +-- +-- TOC entry 63 (OID 536388) -- Name: hostnames_hostid_name_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -589,7 +611,7 @@ CREATE UNIQUE INDEX hostnames_hostid_name_uq ON hostnames USING btree (hostid, n -- --- TOC entry 62 (OID 536389) +-- TOC entry 64 (OID 536389) -- Name: hostnams_name_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -597,7 +619,7 @@ CREATE UNIQUE INDEX hostnams_name_uq ON hostnames USING btree (name); -- --- TOC entry 58 (OID 536419) +-- TOC entry 60 (OID 536419) -- Name: pages_url_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -605,7 +627,7 @@ CREATE UNIQUE INDEX pages_url_uq ON pages USING btree (hostid, url); -- --- TOC entry 63 (OID 540251) +-- TOC entry 65 (OID 540251) -- Name: images_name_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -613,7 +635,7 @@ CREATE UNIQUE INDEX images_name_uq ON images USING btree (hostid, name); -- --- TOC entry 65 (OID 540252) +-- TOC entry 67 (OID 540252) -- Name: files_name_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -621,7 +643,7 @@ CREATE UNIQUE INDEX files_name_uq ON files USING btree (hostid, name); -- --- TOC entry 68 (OID 540831) +-- TOC entry 70 (OID 540831) -- Name: users_name_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -629,7 +651,7 @@ CREATE UNIQUE INDEX users_name_uq ON users USING btree (hostid, name); -- --- TOC entry 67 (OID 540946) +-- TOC entry 69 (OID 540946) -- Name: users_id_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -637,7 +659,7 @@ CREATE UNIQUE INDEX users_id_uq ON users USING btree (hostid, id); -- --- TOC entry 70 (OID 540970) +-- TOC entry 72 (OID 540970) -- Name: sitemenu_ordering_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -645,7 +667,7 @@ CREATE UNIQUE INDEX sitemenu_ordering_uq ON sitemenu USING btree (hostid, orderi -- --- TOC entry 71 (OID 540971) +-- TOC entry 73 (OID 540971) -- Name: sitemenu_url_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -653,7 +675,7 @@ CREATE UNIQUE INDEX sitemenu_url_uq ON sitemenu USING btree (hostid, url); -- --- TOC entry 74 (OID 542626) +-- TOC entry 76 (OID 542626) -- Name: contact_emails_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -661,7 +683,7 @@ CREATE UNIQUE INDEX contact_emails_uq ON contact_emails USING btree (contactid, -- --- TOC entry 75 (OID 543505) +-- TOC entry 77 (OID 543505) -- Name: themes_theme_css_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -669,7 +691,7 @@ CREATE UNIQUE INDEX themes_theme_css_uq ON themes USING btree (theme_css); -- --- TOC entry 76 (OID 543763) +-- TOC entry 78 (OID 543763) -- Name: page_emails_email_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -677,7 +699,7 @@ CREATE UNIQUE INDEX page_emails_email_uq ON page_emails USING btree (hostid, url -- --- TOC entry 77 (OID 543795) +-- TOC entry 79 (OID 543795) -- Name: mailing_lists_email_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -685,7 +707,7 @@ CREATE UNIQUE INDEX mailing_lists_email_uq ON mailing_lists USING btree (hostid, -- --- TOC entry 72 (OID 543880) +-- TOC entry 74 (OID 543880) -- Name: contacts_name_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -693,7 +715,7 @@ CREATE UNIQUE INDEX contacts_name_uq ON contacts USING btree (hostid, name); -- --- TOC entry 78 (OID 544454) +-- TOC entry 80 (OID 544454) -- Name: links_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -701,7 +723,7 @@ CREATE UNIQUE INDEX links_uq ON links USING btree (hostid, from_url, to_url); -- --- TOC entry 79 (OID 547951) +-- TOC entry 81 (OID 547951) -- Name: templates_ext_ord_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -709,7 +731,7 @@ CREATE UNIQUE INDEX templates_ext_ord_uq ON templates USING btree (extension, or -- --- TOC entry 81 (OID 547952) +-- TOC entry 83 (OID 547952) -- Name: templates_title_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -717,7 +739,7 @@ CREATE UNIQUE INDEX templates_title_uq ON templates USING btree (title_regexp); -- --- TOC entry 82 (OID 547953) +-- TOC entry 84 (OID 547953) -- Name: templates_url_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -725,7 +747,7 @@ CREATE UNIQUE INDEX templates_url_uq ON templates USING btree (url_regexp); -- --- TOC entry 83 (OID 551151) +-- TOC entry 85 (OID 551151) -- Name: recently_visited_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -733,7 +755,7 @@ CREATE UNIQUE INDEX recently_visited_uq ON recently_visited USING btree (userid, -- --- TOC entry 84 (OID 552155) +-- TOC entry 86 (OID 552155) -- Name: messages_inet_message_id_uq; Type: INDEX; Schema: public; Owner: rich -- @@ -741,7 +763,7 @@ CREATE UNIQUE INDEX messages_inet_message_id_uq ON messages USING btree (hostid, -- --- TOC entry 57 (OID 552684) +-- TOC entry 59 (OID 552684) -- Name: pages_url_ix; Type: INDEX; Schema: public; Owner: rich -- @@ -749,7 +771,7 @@ CREATE INDEX pages_url_ix ON pages USING btree (url); -- --- TOC entry 56 (OID 552685) +-- TOC entry 58 (OID 552685) -- Name: pages_redirect_ix; Type: INDEX; Schema: public; Owner: rich -- @@ -757,7 +779,7 @@ CREATE INDEX pages_redirect_ix ON pages USING btree (redirect); -- --- TOC entry 55 (OID 536012) +-- TOC entry 57 (OID 536012) -- Name: pages_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -766,7 +788,7 @@ ALTER TABLE ONLY pages -- --- TOC entry 59 (OID 536027) +-- TOC entry 61 (OID 536027) -- Name: contents_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -775,7 +797,7 @@ ALTER TABLE ONLY contents -- --- TOC entry 60 (OID 536377) +-- TOC entry 62 (OID 536377) -- Name: hosts_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -784,7 +806,7 @@ ALTER TABLE ONLY hosts -- --- TOC entry 64 (OID 537158) +-- TOC entry 66 (OID 537158) -- Name: images_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -793,7 +815,7 @@ ALTER TABLE ONLY images -- --- TOC entry 66 (OID 537173) +-- TOC entry 68 (OID 537173) -- Name: files_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -802,7 +824,7 @@ ALTER TABLE ONLY files -- --- TOC entry 69 (OID 540825) +-- TOC entry 71 (OID 540825) -- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -811,7 +833,7 @@ ALTER TABLE ONLY users -- --- TOC entry 73 (OID 542611) +-- TOC entry 75 (OID 542611) -- Name: contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -820,7 +842,7 @@ ALTER TABLE ONLY contacts -- --- TOC entry 80 (OID 547945) +-- TOC entry 82 (OID 547945) -- Name: templates_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -829,7 +851,7 @@ ALTER TABLE ONLY templates -- --- TOC entry 85 (OID 551681) +-- TOC entry 87 (OID 551681) -- Name: messages_pkey; Type: CONSTRAINT; Schema: public; Owner: rich -- @@ -838,7 +860,16 @@ ALTER TABLE ONLY messages -- --- TOC entry 90 (OID 536029) +-- TOC entry 88 (OID 607081) +-- Name: powered_by_pkey; Type: CONSTRAINT; Schema: public; Owner: rich +-- + +ALTER TABLE ONLY powered_by + ADD CONSTRAINT powered_by_pkey PRIMARY KEY (id); + + +-- +-- TOC entry 93 (OID 536029) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -847,7 +878,7 @@ ALTER TABLE ONLY contents -- --- TOC entry 93 (OID 536384) +-- TOC entry 97 (OID 536384) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -856,7 +887,7 @@ ALTER TABLE ONLY hostnames -- --- TOC entry 91 (OID 536394) +-- TOC entry 94 (OID 536394) -- Name: hosts_hostname_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -865,7 +896,7 @@ ALTER TABLE ONLY hosts -- --- TOC entry 86 (OID 536404) +-- TOC entry 89 (OID 536404) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -874,7 +905,7 @@ ALTER TABLE ONLY pages -- --- TOC entry 94 (OID 537160) +-- TOC entry 98 (OID 537160) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -883,7 +914,7 @@ ALTER TABLE ONLY images -- --- TOC entry 95 (OID 537175) +-- TOC entry 99 (OID 537175) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -892,7 +923,7 @@ ALTER TABLE ONLY files -- --- TOC entry 87 (OID 539155) +-- TOC entry 90 (OID 539155) -- Name: pages_redirect_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -901,7 +932,7 @@ ALTER TABLE ONLY pages -- --- TOC entry 96 (OID 540827) +-- TOC entry 100 (OID 540827) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -910,7 +941,7 @@ ALTER TABLE ONLY users -- --- TOC entry 97 (OID 540837) +-- TOC entry 101 (OID 540837) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -919,7 +950,7 @@ ALTER TABLE ONLY usercookies -- --- TOC entry 88 (OID 540942) +-- TOC entry 91 (OID 540942) -- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -928,7 +959,7 @@ ALTER TABLE ONLY pages -- --- TOC entry 89 (OID 540947) +-- TOC entry 92 (OID 540947) -- Name: pages_user_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -937,7 +968,7 @@ ALTER TABLE ONLY pages -- --- TOC entry 98 (OID 540966) +-- TOC entry 102 (OID 540966) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -946,7 +977,7 @@ ALTER TABLE ONLY sitemenu -- --- TOC entry 99 (OID 540972) +-- TOC entry 103 (OID 540972) -- Name: sitemenu_url_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -955,7 +986,7 @@ ALTER TABLE ONLY sitemenu -- --- TOC entry 100 (OID 542613) +-- TOC entry 104 (OID 542613) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -964,7 +995,7 @@ ALTER TABLE ONLY contacts -- --- TOC entry 101 (OID 542622) +-- TOC entry 105 (OID 542622) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -973,7 +1004,7 @@ ALTER TABLE ONLY contact_emails -- --- TOC entry 92 (OID 543506) +-- TOC entry 95 (OID 543506) -- Name: hosts_theme_css_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -982,7 +1013,7 @@ ALTER TABLE ONLY hosts -- --- TOC entry 102 (OID 543759) +-- TOC entry 106 (OID 543759) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -991,7 +1022,7 @@ ALTER TABLE ONLY page_emails -- --- TOC entry 103 (OID 543764) +-- TOC entry 107 (OID 543764) -- Name: page_emails_url_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1000,7 +1031,7 @@ ALTER TABLE ONLY page_emails -- --- TOC entry 104 (OID 543791) +-- TOC entry 108 (OID 543791) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1009,7 +1040,7 @@ ALTER TABLE ONLY mailing_lists -- --- TOC entry 105 (OID 544450) +-- TOC entry 109 (OID 544450) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1018,7 +1049,7 @@ ALTER TABLE ONLY links -- --- TOC entry 106 (OID 544455) +-- TOC entry 110 (OID 544455) -- Name: links_from_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1027,7 +1058,7 @@ ALTER TABLE ONLY links -- --- TOC entry 107 (OID 551129) +-- TOC entry 111 (OID 551129) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1036,7 +1067,7 @@ ALTER TABLE ONLY recently_visited -- --- TOC entry 108 (OID 551133) +-- TOC entry 112 (OID 551133) -- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1045,7 +1076,7 @@ ALTER TABLE ONLY recently_visited -- --- TOC entry 109 (OID 551137) +-- TOC entry 113 (OID 551137) -- Name: recently_visited_url_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1054,7 +1085,7 @@ ALTER TABLE ONLY recently_visited -- --- TOC entry 110 (OID 551141) +-- TOC entry 114 (OID 551141) -- Name: recently_visited_userid_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1063,7 +1094,7 @@ ALTER TABLE ONLY recently_visited -- --- TOC entry 112 (OID 551690) +-- TOC entry 116 (OID 551690) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1072,7 +1103,7 @@ ALTER TABLE ONLY msg_references -- --- TOC entry 111 (OID 551694) +-- TOC entry 115 (OID 551694) -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich -- @@ -1081,6 +1112,15 @@ ALTER TABLE ONLY messages -- +-- TOC entry 96 (OID 607083) +-- Name: hosts_powered_by_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich +-- + +ALTER TABLE ONLY hosts + ADD CONSTRAINT hosts_powered_by_cn FOREIGN KEY (powered_by) REFERENCES powered_by(id); + + +-- -- TOC entry 3 (OID 2200) -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- diff --git a/scripts/lib/cocanwiki_template.ml b/scripts/lib/cocanwiki_template.ml index c647845..524255b 100644 --- a/scripts/lib/cocanwiki_template.ml +++ b/scripts/lib/cocanwiki_template.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: cocanwiki_template.ml,v 1.1 2004/10/21 11:42:05 rich Exp $ + * $Id: cocanwiki_template.ml,v 1.2 2004/10/23 10:13:20 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 @@ -81,17 +81,35 @@ let get_template ?page (dbh : Dbi.connection) hostid filename = let template = _get_template filename in (* Get standard fields concerning this host from the database. *) - let sth = dbh#prepare_cached "select theme_css from hosts - where id = ?" in + let sth = + dbh#prepare_cached + "select h.theme_css, p.name, p.url + from hosts h left outer join powered_by p on h.powered_by = p.id + where h.id = ?" in sth#execute [`Int hostid]; - let theme_css = + let theme_css, powered_by_name, powered_by_url = match sth#fetch1 () with - [ `Null ] -> "/_css/standard.css" - | [ `String file ] -> file + | [ a; b; c] -> a, b, c + | _ -> assert false in + let theme_css = + match theme_css with + | `Null -> "/_css/standard.css" + | `String file -> file + | _ -> assert false in + let powered_by_name, powered_by_url = + match powered_by_name, powered_by_url with + | `Null, `Null -> + let url = "http://sandbox.merjis.com/" in + let name = Cocanwiki_version.package ^ " " ^ + Cocanwiki_version.version in + name, url + | `String name, `String url -> name, url | _ -> assert false in template#set "theme_css" theme_css; + template#set "powered_by_name" powered_by_name; + template#set "powered_by_url" powered_by_url; (* Site menu. *) let sth = dbh#prepare_cached "select url, label, ordering from sitemenu diff --git a/templates/footer.html b/templates/footer.html index d8ff69a..513d08f 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -18,6 +18,6 @@ \ No newline at end of file diff --git a/templates/page.html b/templates/page.html index e63c3f6..c15b307 100644 --- a/templates/page.html +++ b/templates/page.html @@ -132,7 +132,7 @@ ::if(has_feedback_email)::
  • Send feedback
  • ::end:: -
  • Powered by ::cocanwiki_package_html:: ::cocanwiki_version_html::
  • +
  • Powered by ::powered_by_name_html::
  • -- 1.8.3.1