Add support for using {{macros}} (no support for editing yet).
authorrich <rich>
Wed, 26 Jul 2006 14:59:02 +0000 (14:59 +0000)
committerrich <rich>
Wed, 26 Jul 2006 14:59:02 +0000 (14:59 +0000)
Database schema update also includes enhanced check constraint on the
contents.jsgo field and a better trigger check on this same field.

schema/cocanwiki.sql
scripts/lib/wikilib.ml

index 37b5439..d9b4dae 100644 (file)
@@ -8,7 +8,7 @@ SET check_function_bodies = false;
 SET search_path = public, pg_catalog;
 
 --
--- TOC entry 195 (OID 14911565)
+-- TOC entry 198 (OID 14911565)
 -- Name: plpgsql_call_handler(); Type: FUNC PROCEDURAL LANGUAGE; Schema: public; Owner: postgres
 --
 
@@ -18,7 +18,7 @@ CREATE FUNCTION plpgsql_call_handler() RETURNS language_handler
 
 
 --
--- TOC entry 116 (OID 14911566)
+-- TOC entry 119 (OID 14911566)
 -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: public; Owner: 
 --
 
@@ -60,7 +60,7 @@ GRANT SELECT ON TABLE pg_ts_dict TO "www-data";
 
 
 --
--- TOC entry 117 (OID 11524574)
+-- TOC entry 120 (OID 11524574)
 -- Name: lexize(oid, text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -70,7 +70,7 @@ CREATE FUNCTION lexize(oid, text) RETURNS text[]
 
 
 --
--- TOC entry 118 (OID 11524575)
+-- TOC entry 121 (OID 11524575)
 -- Name: lexize(text, text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -80,7 +80,7 @@ CREATE FUNCTION lexize(text, text) RETURNS text[]
 
 
 --
--- TOC entry 119 (OID 11524576)
+-- TOC entry 122 (OID 11524576)
 -- Name: lexize(text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -90,7 +90,7 @@ CREATE FUNCTION lexize(text) RETURNS text[]
 
 
 --
--- TOC entry 120 (OID 11524577)
+-- TOC entry 123 (OID 11524577)
 -- Name: set_curdict(integer); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -100,7 +100,7 @@ CREATE FUNCTION set_curdict(integer) RETURNS void
 
 
 --
--- TOC entry 121 (OID 11524578)
+-- TOC entry 124 (OID 11524578)
 -- Name: set_curdict(text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -110,7 +110,7 @@ CREATE FUNCTION set_curdict(text) RETURNS void
 
 
 --
--- TOC entry 122 (OID 11524579)
+-- TOC entry 125 (OID 11524579)
 -- Name: dex_init(internal); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -120,7 +120,7 @@ CREATE FUNCTION dex_init(internal) RETURNS internal
 
 
 --
--- TOC entry 123 (OID 11524580)
+-- TOC entry 126 (OID 11524580)
 -- Name: dex_lexize(internal, internal, integer); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -130,7 +130,7 @@ CREATE FUNCTION dex_lexize(internal, internal, integer) RETURNS internal
 
 
 --
--- TOC entry 124 (OID 11524582)
+-- TOC entry 127 (OID 11524582)
 -- Name: snb_en_init(internal); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -140,7 +140,7 @@ CREATE FUNCTION snb_en_init(internal) RETURNS internal
 
 
 --
--- TOC entry 125 (OID 11524583)
+-- TOC entry 128 (OID 11524583)
 -- Name: snb_lexize(internal, internal, integer); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -150,7 +150,7 @@ CREATE FUNCTION snb_lexize(internal, internal, integer) RETURNS internal
 
 
 --
--- TOC entry 126 (OID 11524585)
+-- TOC entry 129 (OID 11524585)
 -- Name: snb_ru_init(internal); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -160,7 +160,7 @@ CREATE FUNCTION snb_ru_init(internal) RETURNS internal
 
 
 --
--- TOC entry 127 (OID 11524587)
+-- TOC entry 130 (OID 11524587)
 -- Name: spell_init(internal); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -170,7 +170,7 @@ CREATE FUNCTION spell_init(internal) RETURNS internal
 
 
 --
--- TOC entry 128 (OID 11524588)
+-- TOC entry 131 (OID 11524588)
 -- Name: spell_lexize(internal, internal, integer); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -180,7 +180,7 @@ CREATE FUNCTION spell_lexize(internal, internal, integer) RETURNS internal
 
 
 --
--- TOC entry 129 (OID 11524590)
+-- TOC entry 132 (OID 11524590)
 -- Name: syn_init(internal); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -190,7 +190,7 @@ CREATE FUNCTION syn_init(internal) RETURNS internal
 
 
 --
--- TOC entry 130 (OID 11524591)
+-- TOC entry 133 (OID 11524591)
 -- Name: syn_lexize(internal, internal, integer); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -238,7 +238,7 @@ CREATE TYPE tokentype AS (
 
 
 --
--- TOC entry 131 (OID 11524602)
+-- TOC entry 134 (OID 11524602)
 -- Name: token_type(integer); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -248,7 +248,7 @@ CREATE FUNCTION token_type(integer) RETURNS SETOF tokentype
 
 
 --
--- TOC entry 132 (OID 11524603)
+-- TOC entry 135 (OID 11524603)
 -- Name: token_type(text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -258,7 +258,7 @@ CREATE FUNCTION token_type(text) RETURNS SETOF tokentype
 
 
 --
--- TOC entry 133 (OID 11524604)
+-- TOC entry 136 (OID 11524604)
 -- Name: token_type(); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -268,7 +268,7 @@ CREATE FUNCTION token_type() RETURNS SETOF tokentype
 
 
 --
--- TOC entry 134 (OID 11524605)
+-- TOC entry 137 (OID 11524605)
 -- Name: set_curprs(integer); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -278,7 +278,7 @@ CREATE FUNCTION set_curprs(integer) RETURNS void
 
 
 --
--- TOC entry 135 (OID 11524606)
+-- TOC entry 138 (OID 11524606)
 -- Name: set_curprs(text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -299,7 +299,7 @@ CREATE TYPE tokenout AS (
 
 
 --
--- TOC entry 136 (OID 11524609)
+-- TOC entry 139 (OID 11524609)
 -- Name: parse(oid, text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -309,7 +309,7 @@ CREATE FUNCTION parse(oid, text) RETURNS SETOF tokenout
 
 
 --
--- TOC entry 137 (OID 11524610)
+-- TOC entry 140 (OID 11524610)
 -- Name: parse(text, text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -319,7 +319,7 @@ CREATE FUNCTION parse(text, text) RETURNS SETOF tokenout
 
 
 --
--- TOC entry 138 (OID 11524611)
+-- TOC entry 141 (OID 11524611)
 -- Name: parse(text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -329,7 +329,7 @@ CREATE FUNCTION parse(text) RETURNS SETOF tokenout
 
 
 --
--- TOC entry 139 (OID 11524612)
+-- TOC entry 142 (OID 11524612)
 -- Name: prsd_start(internal, integer); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -339,7 +339,7 @@ CREATE FUNCTION prsd_start(internal, integer) RETURNS internal
 
 
 --
--- TOC entry 140 (OID 11524613)
+-- TOC entry 143 (OID 11524613)
 -- Name: prsd_getlexeme(internal, internal, internal); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -349,7 +349,7 @@ CREATE FUNCTION prsd_getlexeme(internal, internal, internal) RETURNS integer
 
 
 --
--- TOC entry 141 (OID 11524614)
+-- TOC entry 144 (OID 11524614)
 -- Name: prsd_end(internal); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -359,7 +359,7 @@ CREATE FUNCTION prsd_end(internal) RETURNS void
 
 
 --
--- TOC entry 142 (OID 11524615)
+-- TOC entry 145 (OID 11524615)
 -- Name: prsd_lextype(internal); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -369,7 +369,7 @@ CREATE FUNCTION prsd_lextype(internal) RETURNS internal
 
 
 --
--- TOC entry 143 (OID 11524616)
+-- TOC entry 146 (OID 11524616)
 -- Name: prsd_headline(internal, internal, internal); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -423,7 +423,7 @@ GRANT SELECT ON TABLE pg_ts_cfgmap TO "www-data";
 
 
 --
--- TOC entry 144 (OID 11524632)
+-- TOC entry 147 (OID 11524632)
 -- Name: set_curcfg(integer); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -433,7 +433,7 @@ CREATE FUNCTION set_curcfg(integer) RETURNS void
 
 
 --
--- TOC entry 145 (OID 11524633)
+-- TOC entry 148 (OID 11524633)
 -- Name: set_curcfg(text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -443,7 +443,7 @@ CREATE FUNCTION set_curcfg(text) RETURNS void
 
 
 --
--- TOC entry 146 (OID 11524634)
+-- TOC entry 149 (OID 11524634)
 -- Name: show_curcfg(); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -453,7 +453,7 @@ CREATE FUNCTION show_curcfg() RETURNS oid
 
 
 --
--- TOC entry 147 (OID 11524696)
+-- TOC entry 150 (OID 11524696)
 -- Name: tsvector_in(cstring); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -463,7 +463,7 @@ CREATE FUNCTION tsvector_in(cstring) RETURNS tsvector
 
 
 --
--- TOC entry 148 (OID 11524697)
+-- TOC entry 151 (OID 11524697)
 -- Name: tsvector_out(tsvector); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -487,7 +487,7 @@ CREATE TYPE tsvector (
 
 
 --
--- TOC entry 149 (OID 11524699)
+-- TOC entry 152 (OID 11524699)
 -- Name: length(tsvector); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -497,7 +497,7 @@ CREATE FUNCTION length(tsvector) RETURNS integer
 
 
 --
--- TOC entry 150 (OID 11524700)
+-- TOC entry 153 (OID 11524700)
 -- Name: to_tsvector(oid, text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -507,7 +507,7 @@ CREATE FUNCTION to_tsvector(oid, text) RETURNS tsvector
 
 
 --
--- TOC entry 151 (OID 11524701)
+-- TOC entry 154 (OID 11524701)
 -- Name: to_tsvector(text, text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -517,7 +517,7 @@ CREATE FUNCTION to_tsvector(text, text) RETURNS tsvector
 
 
 --
--- TOC entry 152 (OID 11524702)
+-- TOC entry 155 (OID 11524702)
 -- Name: to_tsvector(text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -527,7 +527,7 @@ CREATE FUNCTION to_tsvector(text) RETURNS tsvector
 
 
 --
--- TOC entry 153 (OID 11524703)
+-- TOC entry 156 (OID 11524703)
 -- Name: strip(tsvector); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -537,7 +537,7 @@ CREATE FUNCTION strip(tsvector) RETURNS tsvector
 
 
 --
--- TOC entry 154 (OID 11524704)
+-- TOC entry 157 (OID 11524704)
 -- Name: setweight(tsvector, "char"); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -547,7 +547,7 @@ CREATE FUNCTION setweight(tsvector, "char") RETURNS tsvector
 
 
 --
--- TOC entry 155 (OID 11524705)
+-- TOC entry 158 (OID 11524705)
 -- Name: concat(tsvector, tsvector); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -557,7 +557,7 @@ CREATE FUNCTION concat(tsvector, tsvector) RETURNS tsvector
 
 
 --
--- TOC entry 197 (OID 11524706)
+-- TOC entry 200 (OID 11524706)
 -- Name: ||; Type: OPERATOR; Schema: public; Owner: postgres
 --
 
@@ -569,7 +569,7 @@ CREATE OPERATOR || (
 
 
 --
--- TOC entry 156 (OID 11524708)
+-- TOC entry 159 (OID 11524708)
 -- Name: tsquery_in(cstring); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -579,7 +579,7 @@ CREATE FUNCTION tsquery_in(cstring) RETURNS tsquery
 
 
 --
--- TOC entry 157 (OID 11524709)
+-- TOC entry 160 (OID 11524709)
 -- Name: tsquery_out(tsquery); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -603,7 +603,7 @@ CREATE TYPE tsquery (
 
 
 --
--- TOC entry 158 (OID 11524711)
+-- TOC entry 161 (OID 11524711)
 -- Name: querytree(tsquery); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -613,7 +613,7 @@ CREATE FUNCTION querytree(tsquery) RETURNS text
 
 
 --
--- TOC entry 159 (OID 11524712)
+-- TOC entry 162 (OID 11524712)
 -- Name: to_tsquery(oid, text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -623,7 +623,7 @@ CREATE FUNCTION to_tsquery(oid, text) RETURNS tsquery
 
 
 --
--- TOC entry 160 (OID 11524713)
+-- TOC entry 163 (OID 11524713)
 -- Name: to_tsquery(text, text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -633,7 +633,7 @@ CREATE FUNCTION to_tsquery(text, text) RETURNS tsquery
 
 
 --
--- TOC entry 161 (OID 11524714)
+-- TOC entry 164 (OID 11524714)
 -- Name: to_tsquery(text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -643,7 +643,7 @@ CREATE FUNCTION to_tsquery(text) RETURNS tsquery
 
 
 --
--- TOC entry 162 (OID 11524715)
+-- TOC entry 165 (OID 11524715)
 -- Name: exectsq(tsvector, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -653,7 +653,7 @@ CREATE FUNCTION exectsq(tsvector, tsquery) RETURNS boolean
 
 
 --
--- TOC entry 164 (OID 11524716)
+-- TOC entry 167 (OID 11524716)
 -- Name: rexectsq(tsquery, tsvector); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -663,7 +663,7 @@ CREATE FUNCTION rexectsq(tsquery, tsvector) RETURNS boolean
 
 
 --
--- TOC entry 199 (OID 11524717)
+-- TOC entry 202 (OID 11524717)
 -- Name: @@; Type: OPERATOR; Schema: public; Owner: postgres
 --
 
@@ -678,7 +678,7 @@ CREATE OPERATOR @@ (
 
 
 --
--- TOC entry 198 (OID 11524718)
+-- TOC entry 201 (OID 11524718)
 -- Name: @@; Type: OPERATOR; Schema: public; Owner: postgres
 --
 
@@ -693,7 +693,7 @@ CREATE OPERATOR @@ (
 
 
 --
--- TOC entry 166 (OID 11524719)
+-- TOC entry 169 (OID 11524719)
 -- Name: tsearch2(); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -703,7 +703,7 @@ CREATE FUNCTION tsearch2() RETURNS "trigger"
 
 
 --
--- TOC entry 167 (OID 11524720)
+-- TOC entry 170 (OID 11524720)
 -- Name: rank(real[], tsvector, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -713,7 +713,7 @@ CREATE FUNCTION rank(real[], tsvector, tsquery) RETURNS real
 
 
 --
--- TOC entry 168 (OID 11524721)
+-- TOC entry 171 (OID 11524721)
 -- Name: rank(real[], tsvector, tsquery, integer); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -723,7 +723,7 @@ CREATE FUNCTION rank(real[], tsvector, tsquery, integer) RETURNS real
 
 
 --
--- TOC entry 169 (OID 11524722)
+-- TOC entry 172 (OID 11524722)
 -- Name: rank(tsvector, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -733,7 +733,7 @@ CREATE FUNCTION rank(tsvector, tsquery) RETURNS real
 
 
 --
--- TOC entry 170 (OID 11524723)
+-- TOC entry 173 (OID 11524723)
 -- Name: rank(tsvector, tsquery, integer); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -743,7 +743,7 @@ CREATE FUNCTION rank(tsvector, tsquery, integer) RETURNS real
 
 
 --
--- TOC entry 171 (OID 11524724)
+-- TOC entry 174 (OID 11524724)
 -- Name: rank_cd(integer, tsvector, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -753,7 +753,7 @@ CREATE FUNCTION rank_cd(integer, tsvector, tsquery) RETURNS real
 
 
 --
--- TOC entry 172 (OID 11524725)
+-- TOC entry 175 (OID 11524725)
 -- Name: rank_cd(integer, tsvector, tsquery, integer); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -763,7 +763,7 @@ CREATE FUNCTION rank_cd(integer, tsvector, tsquery, integer) RETURNS real
 
 
 --
--- TOC entry 173 (OID 11524726)
+-- TOC entry 176 (OID 11524726)
 -- Name: rank_cd(tsvector, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -773,7 +773,7 @@ CREATE FUNCTION rank_cd(tsvector, tsquery) RETURNS real
 
 
 --
--- TOC entry 174 (OID 11524727)
+-- TOC entry 177 (OID 11524727)
 -- Name: rank_cd(tsvector, tsquery, integer); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -783,7 +783,7 @@ CREATE FUNCTION rank_cd(tsvector, tsquery, integer) RETURNS real
 
 
 --
--- TOC entry 175 (OID 11524728)
+-- TOC entry 178 (OID 11524728)
 -- Name: headline(oid, text, tsquery, text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -793,7 +793,7 @@ CREATE FUNCTION headline(oid, text, tsquery, text) RETURNS text
 
 
 --
--- TOC entry 176 (OID 11524729)
+-- TOC entry 179 (OID 11524729)
 -- Name: headline(oid, text, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -803,7 +803,7 @@ CREATE FUNCTION headline(oid, text, tsquery) RETURNS text
 
 
 --
--- TOC entry 177 (OID 11524730)
+-- TOC entry 180 (OID 11524730)
 -- Name: headline(text, text, tsquery, text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -813,7 +813,7 @@ CREATE FUNCTION headline(text, text, tsquery, text) RETURNS text
 
 
 --
--- TOC entry 178 (OID 11524731)
+-- TOC entry 181 (OID 11524731)
 -- Name: headline(text, text, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -823,7 +823,7 @@ CREATE FUNCTION headline(text, text, tsquery) RETURNS text
 
 
 --
--- TOC entry 179 (OID 11524732)
+-- TOC entry 182 (OID 11524732)
 -- Name: headline(text, tsquery, text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -833,7 +833,7 @@ CREATE FUNCTION headline(text, tsquery, text) RETURNS text
 
 
 --
--- TOC entry 180 (OID 11524733)
+-- TOC entry 183 (OID 11524733)
 -- Name: headline(text, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -843,7 +843,7 @@ CREATE FUNCTION headline(text, tsquery) RETURNS text
 
 
 --
--- TOC entry 181 (OID 11524735)
+-- TOC entry 184 (OID 11524735)
 -- Name: gtsvector_in(cstring); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -853,7 +853,7 @@ CREATE FUNCTION gtsvector_in(cstring) RETURNS gtsvector
 
 
 --
--- TOC entry 182 (OID 11524736)
+-- TOC entry 185 (OID 11524736)
 -- Name: gtsvector_out(gtsvector); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -877,7 +877,7 @@ CREATE TYPE gtsvector (
 
 
 --
--- TOC entry 183 (OID 11524738)
+-- TOC entry 186 (OID 11524738)
 -- Name: gtsvector_consistent(gtsvector, internal, integer); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -887,7 +887,7 @@ CREATE FUNCTION gtsvector_consistent(gtsvector, internal, integer) RETURNS boole
 
 
 --
--- TOC entry 184 (OID 11524739)
+-- TOC entry 187 (OID 11524739)
 -- Name: gtsvector_compress(internal); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -897,7 +897,7 @@ CREATE FUNCTION gtsvector_compress(internal) RETURNS internal
 
 
 --
--- TOC entry 185 (OID 11524740)
+-- TOC entry 188 (OID 11524740)
 -- Name: gtsvector_decompress(internal); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -907,7 +907,7 @@ CREATE FUNCTION gtsvector_decompress(internal) RETURNS internal
 
 
 --
--- TOC entry 186 (OID 11524741)
+-- TOC entry 189 (OID 11524741)
 -- Name: gtsvector_penalty(internal, internal, internal); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -917,7 +917,7 @@ CREATE FUNCTION gtsvector_penalty(internal, internal, internal) RETURNS internal
 
 
 --
--- TOC entry 187 (OID 11524742)
+-- TOC entry 190 (OID 11524742)
 -- Name: gtsvector_picksplit(internal, internal); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -927,7 +927,7 @@ CREATE FUNCTION gtsvector_picksplit(internal, internal) RETURNS internal
 
 
 --
--- TOC entry 188 (OID 11524743)
+-- TOC entry 191 (OID 11524743)
 -- Name: gtsvector_union(bytea, internal); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -937,7 +937,7 @@ CREATE FUNCTION gtsvector_union(bytea, internal) RETURNS integer[]
 
 
 --
--- TOC entry 189 (OID 11524744)
+-- TOC entry 192 (OID 11524744)
 -- Name: gtsvector_same(gtsvector, gtsvector, internal); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -947,7 +947,7 @@ CREATE FUNCTION gtsvector_same(gtsvector, gtsvector, internal) RETURNS internal
 
 
 --
--- TOC entry 200 (OID 11524745)
+-- TOC entry 203 (OID 11524745)
 -- Name: gist_tsvector_ops; Type: OPERATOR CLASS; Schema: public; Owner: postgres
 --
 
@@ -977,7 +977,7 @@ CREATE TYPE statinfo AS (
 
 
 --
--- TOC entry 190 (OID 11524748)
+-- TOC entry 193 (OID 11524748)
 -- Name: stat(text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -987,7 +987,7 @@ CREATE FUNCTION stat(text) RETURNS SETOF statinfo
 
 
 --
--- TOC entry 191 (OID 11524749)
+-- TOC entry 194 (OID 11524749)
 -- Name: reset_tsearch(); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -997,7 +997,7 @@ CREATE FUNCTION reset_tsearch() RETURNS void
 
 
 --
--- TOC entry 192 (OID 11524750)
+-- TOC entry 195 (OID 11524750)
 -- Name: get_covers(tsvector, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -1022,7 +1022,7 @@ CREATE TYPE tsdebug AS (
 
 
 --
--- TOC entry 193 (OID 11524753)
+-- TOC entry 196 (OID 11524753)
 -- Name: _get_parser_from_curcfg(); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -1032,7 +1032,7 @@ CREATE FUNCTION _get_parser_from_curcfg() RETURNS text
 
 
 --
--- TOC entry 194 (OID 11524754)
+-- TOC entry 197 (OID 11524754)
 -- Name: ts_debug(text); Type: FUNCTION; Schema: public; Owner: postgres
 --
 
@@ -1091,7 +1091,7 @@ GRANT ALL ON TABLE pages TO "www-data";
 
 
 --
--- TOC entry 65 (OID 11524757)
+-- TOC entry 67 (OID 11524757)
 -- Name: pages_id_seq; Type: ACL; Schema: public; Owner: rich
 --
 
@@ -1112,7 +1112,8 @@ CREATE TABLE contents (
     content text NOT NULL,
     divname text,
     content_fti tsvector NOT NULL,
-    jsgo text
+    jsgo text,
+    CONSTRAINT "$2" CHECK (((jsgo IS NULL) OR (divname IS NOT NULL)))
 );
 
 
@@ -1126,7 +1127,7 @@ GRANT ALL ON TABLE contents TO "www-data";
 
 
 --
--- TOC entry 66 (OID 11524767)
+-- TOC entry 68 (OID 11524767)
 -- Name: contents_id_seq; Type: ACL; Schema: public; Owner: rich
 --
 
@@ -1170,7 +1171,7 @@ GRANT ALL ON TABLE hosts TO "www-data";
 
 
 --
--- TOC entry 67 (OID 11524775)
+-- TOC entry 69 (OID 11524775)
 -- Name: hosts_id_seq; Type: ACL; Schema: public; Owner: rich
 --
 
@@ -1234,7 +1235,7 @@ GRANT ALL ON TABLE images TO "www-data";
 
 
 --
--- TOC entry 68 (OID 11524795)
+-- TOC entry 70 (OID 11524795)
 -- Name: images_id_seq; Type: ACL; Schema: public; Owner: rich
 --
 
@@ -1269,7 +1270,7 @@ GRANT ALL ON TABLE files TO "www-data";
 
 
 --
--- TOC entry 69 (OID 11524804)
+-- TOC entry 71 (OID 11524804)
 -- Name: files_id_seq; Type: ACL; Schema: public; Owner: rich
 --
 
@@ -1311,7 +1312,7 @@ GRANT ALL ON TABLE users TO "www-data";
 
 
 --
--- TOC entry 70 (OID 11524813)
+-- TOC entry 72 (OID 11524813)
 -- Name: users_id_seq; Type: ACL; Schema: public; Owner: rich
 --
 
@@ -1384,7 +1385,7 @@ GRANT ALL ON TABLE contacts TO "www-data";
 
 
 --
--- TOC entry 71 (OID 11524840)
+-- TOC entry 73 (OID 11524840)
 -- Name: contacts_id_seq; Type: ACL; Schema: public; Owner: rich
 --
 
@@ -1549,7 +1550,7 @@ GRANT SELECT ON TABLE templates TO "www-data";
 
 
 --
--- TOC entry 72 (OID 11524882)
+-- TOC entry 74 (OID 11524882)
 -- Name: templates_id_seq; Type: ACL; Schema: public; Owner: rich
 --
 
@@ -1602,7 +1603,7 @@ GRANT ALL ON TABLE messages TO "www-data";
 
 
 --
--- TOC entry 73 (OID 11524896)
+-- TOC entry 75 (OID 11524896)
 -- Name: messages_id_seq; Type: ACL; Schema: public; Owner: rich
 --
 
@@ -1675,7 +1676,7 @@ GRANT ALL ON TABLE pending_email_changes TO "www-data";
 
 
 --
--- TOC entry 196 (OID 14911567)
+-- TOC entry 199 (OID 14911567)
 -- Name: contents_jsgo_check_tg(); Type: FUNCTION; Schema: public; Owner: rich
 --
 
@@ -1696,7 +1697,9 @@ begin
                select into my_count count(p.*)
                  from pages p
                 where p.hostid = my_hostid
-                  and p.url = new.jsgo;
+                   and p.url is not null
+                  and p.url = new.jsgo
+                   and p.redirect is null;
                if my_count < 1 then
                        raise exception ''contents.jsgo points to non-existent page (%, %)'',
                          my_hostid, new.jsgo;
@@ -1712,7 +1715,28 @@ end;
 
 
 --
--- TOC entry 88 (OID 11576669)
+-- TOC entry 65 (OID 14911929)
+-- Name: macros; Type: TABLE; Schema: public; Owner: rich
+--
+
+CREATE TABLE macros (
+    hostid integer NOT NULL,
+    name text NOT NULL,
+    content text NOT NULL
+);
+
+
+--
+-- TOC entry 66 (OID 14911929)
+-- Name: macros; Type: ACL; Schema: public; Owner: rich
+--
+
+REVOKE ALL ON TABLE macros FROM PUBLIC;
+GRANT ALL ON TABLE macros TO "www-data";
+
+
+--
+-- TOC entry 90 (OID 11576669)
 -- Name: hostnames_hostid_name_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1720,7 +1744,7 @@ CREATE UNIQUE INDEX hostnames_hostid_name_uq ON hostnames USING btree (hostid, n
 
 
 --
--- TOC entry 83 (OID 11576670)
+-- TOC entry 85 (OID 11576670)
 -- Name: pages_url_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1728,7 +1752,7 @@ CREATE UNIQUE INDEX pages_url_uq ON pages USING btree (hostid, url);
 
 
 --
--- TOC entry 90 (OID 11576671)
+-- TOC entry 92 (OID 11576671)
 -- Name: images_name_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1736,7 +1760,7 @@ CREATE UNIQUE INDEX images_name_uq ON images USING btree (hostid, name);
 
 
 --
--- TOC entry 92 (OID 11576672)
+-- TOC entry 94 (OID 11576672)
 -- Name: files_name_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1744,7 +1768,7 @@ CREATE UNIQUE INDEX files_name_uq ON files USING btree (hostid, name);
 
 
 --
--- TOC entry 95 (OID 11576673)
+-- TOC entry 97 (OID 11576673)
 -- Name: users_name_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1752,7 +1776,7 @@ CREATE UNIQUE INDEX users_name_uq ON users USING btree (hostid, name);
 
 
 --
--- TOC entry 94 (OID 11576674)
+-- TOC entry 96 (OID 11576674)
 -- Name: users_id_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1760,7 +1784,7 @@ CREATE UNIQUE INDEX users_id_uq ON users USING btree (hostid, id);
 
 
 --
--- TOC entry 98 (OID 11576675)
+-- TOC entry 100 (OID 11576675)
 -- Name: sitemenu_ordering_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1768,7 +1792,7 @@ CREATE UNIQUE INDEX sitemenu_ordering_uq ON sitemenu USING btree (hostid, orderi
 
 
 --
--- TOC entry 99 (OID 11576676)
+-- TOC entry 101 (OID 11576676)
 -- Name: sitemenu_url_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1776,7 +1800,7 @@ CREATE UNIQUE INDEX sitemenu_url_uq ON sitemenu USING btree (hostid, url);
 
 
 --
--- TOC entry 102 (OID 11576677)
+-- TOC entry 104 (OID 11576677)
 -- Name: contact_emails_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1784,7 +1808,7 @@ CREATE UNIQUE INDEX contact_emails_uq ON contact_emails USING btree (contactid,
 
 
 --
--- TOC entry 103 (OID 11576678)
+-- TOC entry 105 (OID 11576678)
 -- Name: themes_theme_css_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1792,7 +1816,7 @@ CREATE UNIQUE INDEX themes_theme_css_uq ON themes USING btree (theme_css);
 
 
 --
--- TOC entry 104 (OID 11576679)
+-- TOC entry 106 (OID 11576679)
 -- Name: page_emails_email_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1800,7 +1824,7 @@ CREATE UNIQUE INDEX page_emails_email_uq ON page_emails USING btree (hostid, url
 
 
 --
--- TOC entry 105 (OID 11576680)
+-- TOC entry 107 (OID 11576680)
 -- Name: mailing_lists_email_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1808,7 +1832,7 @@ CREATE UNIQUE INDEX mailing_lists_email_uq ON mailing_lists USING btree (hostid,
 
 
 --
--- TOC entry 100 (OID 11576681)
+-- TOC entry 102 (OID 11576681)
 -- Name: contacts_name_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1816,7 +1840,7 @@ CREATE UNIQUE INDEX contacts_name_uq ON contacts USING btree (hostid, name);
 
 
 --
--- TOC entry 106 (OID 11576682)
+-- TOC entry 108 (OID 11576682)
 -- Name: links_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1824,7 +1848,7 @@ CREATE UNIQUE INDEX links_uq ON links USING btree (hostid, from_url, to_url);
 
 
 --
--- TOC entry 107 (OID 11576683)
+-- TOC entry 109 (OID 11576683)
 -- Name: templates_ext_ord_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1832,7 +1856,7 @@ CREATE UNIQUE INDEX templates_ext_ord_uq ON templates USING btree (extension, or
 
 
 --
--- TOC entry 109 (OID 11576684)
+-- TOC entry 111 (OID 11576684)
 -- Name: templates_title_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1840,7 +1864,7 @@ CREATE UNIQUE INDEX templates_title_uq ON templates USING btree (title_regexp);
 
 
 --
--- TOC entry 110 (OID 11576685)
+-- TOC entry 112 (OID 11576685)
 -- Name: templates_url_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1848,7 +1872,7 @@ CREATE UNIQUE INDEX templates_url_uq ON templates USING btree (url_regexp);
 
 
 --
--- TOC entry 111 (OID 11576686)
+-- TOC entry 113 (OID 11576686)
 -- Name: recently_visited_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1856,7 +1880,7 @@ CREATE UNIQUE INDEX recently_visited_uq ON recently_visited USING btree (userid,
 
 
 --
--- TOC entry 112 (OID 11576687)
+-- TOC entry 114 (OID 11576687)
 -- Name: messages_inet_message_id_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1864,7 +1888,7 @@ CREATE UNIQUE INDEX messages_inet_message_id_uq ON messages USING btree (hostid,
 
 
 --
--- TOC entry 82 (OID 11576688)
+-- TOC entry 84 (OID 11576688)
 -- Name: pages_url_ix; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1872,7 +1896,7 @@ CREATE INDEX pages_url_ix ON pages USING btree (url);
 
 
 --
--- TOC entry 81 (OID 11576689)
+-- TOC entry 83 (OID 11576689)
 -- Name: pages_redirect_ix; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1880,7 +1904,7 @@ CREATE INDEX pages_redirect_ix ON pages USING btree (redirect);
 
 
 --
--- TOC entry 78 (OID 11576690)
+-- TOC entry 80 (OID 11576690)
 -- Name: pages_fti_idx; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1888,7 +1912,7 @@ CREATE INDEX pages_fti_idx ON pages USING gist (title_description_fti);
 
 
 --
--- TOC entry 84 (OID 11576691)
+-- TOC entry 86 (OID 11576691)
 -- Name: contents_fti_idx; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1896,7 +1920,7 @@ CREATE INDEX contents_fti_idx ON contents USING gist (content_fti);
 
 
 --
--- TOC entry 85 (OID 11576692)
+-- TOC entry 87 (OID 11576692)
 -- Name: contents_pageid_idx; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1904,7 +1928,7 @@ CREATE INDEX contents_pageid_idx ON contents USING btree (pageid);
 
 
 --
--- TOC entry 89 (OID 11576693)
+-- TOC entry 91 (OID 11576693)
 -- Name: hostnames_name_uq; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1912,7 +1936,7 @@ CREATE UNIQUE INDEX hostnames_name_uq ON hostnames USING btree (name);
 
 
 --
--- TOC entry 97 (OID 11576694)
+-- TOC entry 99 (OID 11576694)
 -- Name: usercookies_cookie_idx; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1920,7 +1944,7 @@ CREATE INDEX usercookies_cookie_idx ON usercookies USING btree (cookie);
 
 
 --
--- TOC entry 79 (OID 11576695)
+-- TOC entry 81 (OID 11576695)
 -- Name: pages_lc_title; Type: INDEX; Schema: public; Owner: rich
 --
 
@@ -1928,7 +1952,7 @@ CREATE INDEX pages_lc_title ON pages USING btree (lower(title));
 
 
 --
--- TOC entry 74 (OID 11524572)
+-- TOC entry 76 (OID 11524572)
 -- Name: pg_ts_dict_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
 --
 
@@ -1937,7 +1961,7 @@ ALTER TABLE ONLY pg_ts_dict
 
 
 --
--- TOC entry 75 (OID 11524598)
+-- TOC entry 77 (OID 11524598)
 -- Name: pg_ts_parser_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
 --
 
@@ -1946,7 +1970,7 @@ ALTER TABLE ONLY pg_ts_parser
 
 
 --
--- TOC entry 76 (OID 11524623)
+-- TOC entry 78 (OID 11524623)
 -- Name: pg_ts_cfg_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
 --
 
@@ -1955,7 +1979,7 @@ ALTER TABLE ONLY pg_ts_cfg
 
 
 --
--- TOC entry 77 (OID 11524630)
+-- TOC entry 79 (OID 11524630)
 -- Name: pg_ts_cfgmap_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
 --
 
@@ -1964,7 +1988,7 @@ ALTER TABLE ONLY pg_ts_cfgmap
 
 
 --
--- TOC entry 80 (OID 11576696)
+-- TOC entry 82 (OID 11576696)
 -- Name: pages_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -1973,7 +1997,7 @@ ALTER TABLE ONLY pages
 
 
 --
--- TOC entry 86 (OID 11576698)
+-- TOC entry 88 (OID 11576698)
 -- Name: contents_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -1982,7 +2006,7 @@ ALTER TABLE ONLY contents
 
 
 --
--- TOC entry 87 (OID 11576700)
+-- TOC entry 89 (OID 11576700)
 -- Name: hosts_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -1991,7 +2015,7 @@ ALTER TABLE ONLY hosts
 
 
 --
--- TOC entry 91 (OID 11576702)
+-- TOC entry 93 (OID 11576702)
 -- Name: images_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2000,7 +2024,7 @@ ALTER TABLE ONLY images
 
 
 --
--- TOC entry 93 (OID 11576704)
+-- TOC entry 95 (OID 11576704)
 -- Name: files_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2009,7 +2033,7 @@ ALTER TABLE ONLY files
 
 
 --
--- TOC entry 96 (OID 11576706)
+-- TOC entry 98 (OID 11576706)
 -- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2018,7 +2042,7 @@ ALTER TABLE ONLY users
 
 
 --
--- TOC entry 101 (OID 11576708)
+-- TOC entry 103 (OID 11576708)
 -- Name: contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2027,7 +2051,7 @@ ALTER TABLE ONLY contacts
 
 
 --
--- TOC entry 108 (OID 11576710)
+-- TOC entry 110 (OID 11576710)
 -- Name: templates_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2036,7 +2060,7 @@ ALTER TABLE ONLY templates
 
 
 --
--- TOC entry 113 (OID 11576712)
+-- TOC entry 115 (OID 11576712)
 -- Name: messages_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2045,7 +2069,7 @@ ALTER TABLE ONLY messages
 
 
 --
--- TOC entry 114 (OID 11576714)
+-- TOC entry 116 (OID 11576714)
 -- Name: powered_by_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2054,7 +2078,7 @@ ALTER TABLE ONLY powered_by
 
 
 --
--- TOC entry 115 (OID 11576716)
+-- TOC entry 117 (OID 11576716)
 -- Name: pending_email_changes_pkey; Type: CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2063,7 +2087,16 @@ ALTER TABLE ONLY pending_email_changes
 
 
 --
--- TOC entry 205 (OID 11576718)
+-- TOC entry 118 (OID 14911934)
+-- Name: macros_hostid_key; Type: CONSTRAINT; Schema: public; Owner: rich
+--
+
+ALTER TABLE ONLY macros
+    ADD CONSTRAINT macros_hostid_key UNIQUE (hostid, name);
+
+
+--
+-- TOC entry 208 (OID 11576718)
 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2072,7 +2105,7 @@ ALTER TABLE ONLY contents
 
 
 --
--- TOC entry 209 (OID 11576722)
+-- TOC entry 212 (OID 11576722)
 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2081,7 +2114,7 @@ ALTER TABLE ONLY hostnames
 
 
 --
--- TOC entry 206 (OID 11576726)
+-- TOC entry 209 (OID 11576726)
 -- Name: hosts_hostname_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2090,7 +2123,7 @@ ALTER TABLE ONLY hosts
 
 
 --
--- TOC entry 201 (OID 11576730)
+-- TOC entry 204 (OID 11576730)
 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2099,7 +2132,7 @@ ALTER TABLE ONLY pages
 
 
 --
--- TOC entry 210 (OID 11576734)
+-- TOC entry 213 (OID 11576734)
 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2108,7 +2141,7 @@ ALTER TABLE ONLY images
 
 
 --
--- TOC entry 211 (OID 11576738)
+-- TOC entry 214 (OID 11576738)
 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2117,7 +2150,7 @@ ALTER TABLE ONLY files
 
 
 --
--- TOC entry 202 (OID 11576742)
+-- TOC entry 205 (OID 11576742)
 -- Name: pages_redirect_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2126,7 +2159,7 @@ ALTER TABLE ONLY pages
 
 
 --
--- TOC entry 212 (OID 11576746)
+-- TOC entry 215 (OID 11576746)
 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2135,7 +2168,7 @@ ALTER TABLE ONLY users
 
 
 --
--- TOC entry 213 (OID 11576750)
+-- TOC entry 216 (OID 11576750)
 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2144,7 +2177,7 @@ ALTER TABLE ONLY usercookies
 
 
 --
--- TOC entry 203 (OID 11576754)
+-- TOC entry 206 (OID 11576754)
 -- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2153,7 +2186,7 @@ ALTER TABLE ONLY pages
 
 
 --
--- TOC entry 204 (OID 11576758)
+-- TOC entry 207 (OID 11576758)
 -- Name: pages_user_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2162,7 +2195,7 @@ ALTER TABLE ONLY pages
 
 
 --
--- TOC entry 214 (OID 11576762)
+-- TOC entry 217 (OID 11576762)
 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2171,7 +2204,7 @@ ALTER TABLE ONLY sitemenu
 
 
 --
--- TOC entry 215 (OID 11576766)
+-- TOC entry 218 (OID 11576766)
 -- Name: sitemenu_url_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2180,7 +2213,7 @@ ALTER TABLE ONLY sitemenu
 
 
 --
--- TOC entry 216 (OID 11576770)
+-- TOC entry 219 (OID 11576770)
 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2189,7 +2222,7 @@ ALTER TABLE ONLY contacts
 
 
 --
--- TOC entry 217 (OID 11576774)
+-- TOC entry 220 (OID 11576774)
 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2198,7 +2231,7 @@ ALTER TABLE ONLY contact_emails
 
 
 --
--- TOC entry 207 (OID 11576778)
+-- TOC entry 210 (OID 11576778)
 -- Name: hosts_theme_css_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2207,7 +2240,7 @@ ALTER TABLE ONLY hosts
 
 
 --
--- TOC entry 218 (OID 11576782)
+-- TOC entry 221 (OID 11576782)
 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2216,7 +2249,7 @@ ALTER TABLE ONLY page_emails
 
 
 --
--- TOC entry 219 (OID 11576786)
+-- TOC entry 222 (OID 11576786)
 -- Name: page_emails_url_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2225,7 +2258,7 @@ ALTER TABLE ONLY page_emails
 
 
 --
--- TOC entry 220 (OID 11576790)
+-- TOC entry 223 (OID 11576790)
 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2234,7 +2267,7 @@ ALTER TABLE ONLY mailing_lists
 
 
 --
--- TOC entry 221 (OID 11576794)
+-- TOC entry 224 (OID 11576794)
 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2243,7 +2276,7 @@ ALTER TABLE ONLY links
 
 
 --
--- TOC entry 222 (OID 11576798)
+-- TOC entry 225 (OID 11576798)
 -- Name: links_from_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2252,7 +2285,7 @@ ALTER TABLE ONLY links
 
 
 --
--- TOC entry 223 (OID 11576802)
+-- TOC entry 226 (OID 11576802)
 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2261,7 +2294,7 @@ ALTER TABLE ONLY recently_visited
 
 
 --
--- TOC entry 224 (OID 11576806)
+-- TOC entry 227 (OID 11576806)
 -- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2270,7 +2303,7 @@ ALTER TABLE ONLY recently_visited
 
 
 --
--- TOC entry 225 (OID 11576810)
+-- TOC entry 228 (OID 11576810)
 -- Name: recently_visited_url_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2279,7 +2312,7 @@ ALTER TABLE ONLY recently_visited
 
 
 --
--- TOC entry 226 (OID 11576814)
+-- TOC entry 229 (OID 11576814)
 -- Name: recently_visited_userid_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2288,7 +2321,7 @@ ALTER TABLE ONLY recently_visited
 
 
 --
--- TOC entry 228 (OID 11576818)
+-- TOC entry 231 (OID 11576818)
 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2297,7 +2330,7 @@ ALTER TABLE ONLY msg_references
 
 
 --
--- TOC entry 227 (OID 11576822)
+-- TOC entry 230 (OID 11576822)
 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2306,7 +2339,7 @@ ALTER TABLE ONLY messages
 
 
 --
--- TOC entry 208 (OID 11576826)
+-- TOC entry 211 (OID 11576826)
 -- Name: hosts_powered_by_cn; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2315,7 +2348,7 @@ ALTER TABLE ONLY hosts
 
 
 --
--- TOC entry 229 (OID 11576830)
+-- TOC entry 232 (OID 11576830)
 -- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
 --
 
@@ -2324,7 +2357,16 @@ ALTER TABLE ONLY pending_email_changes
 
 
 --
--- TOC entry 230 (OID 11576834)
+-- TOC entry 233 (OID 14911936)
+-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: rich
+--
+
+ALTER TABLE ONLY macros
+    ADD CONSTRAINT "$1" FOREIGN KEY (hostid) REFERENCES hosts(id);
+
+
+--
+-- TOC entry 234 (OID 11576834)
 -- Name: pages_fti_tr; Type: TRIGGER; Schema: public; Owner: rich
 --
 
@@ -2335,7 +2377,7 @@ CREATE TRIGGER pages_fti_tr
 
 
 --
--- TOC entry 231 (OID 11576835)
+-- TOC entry 235 (OID 11576835)
 -- Name: contents_fti_tr; Type: TRIGGER; Schema: public; Owner: rich
 --
 
@@ -2346,7 +2388,7 @@ CREATE TRIGGER contents_fti_tr
 
 
 --
--- TOC entry 232 (OID 14911568)
+-- TOC entry 236 (OID 14911568)
 -- Name: contents_jsgo_check_tg; Type: TRIGGER; Schema: public; Owner: rich
 --
 
@@ -2365,7 +2407,7 @@ COMMENT ON SCHEMA public IS 'Standard public namespace';
 
 
 --
--- TOC entry 163 (OID 11524715)
+-- TOC entry 166 (OID 11524715)
 -- Name: FUNCTION exectsq(tsvector, tsquery); Type: COMMENT; Schema: public; Owner: postgres
 --
 
@@ -2373,7 +2415,7 @@ COMMENT ON FUNCTION exectsq(tsvector, tsquery) IS 'boolean operation with text i
 
 
 --
--- TOC entry 165 (OID 11524716)
+-- TOC entry 168 (OID 11524716)
 -- Name: FUNCTION rexectsq(tsquery, tsvector); Type: COMMENT; Schema: public; Owner: postgres
 --
 
index 557d7a9..a4a8e77 100644 (file)
@@ -1,7 +1,7 @@
 (* COCANWIKI - a wiki written in Objective CAML.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * Copyright (C) 2004 Merjis Ltd.
- * $Id: wikilib.ml,v 1.5 2006/03/27 16:43:44 rich Exp $
+ * $Id: wikilib.ml,v 1.6 2006/07/26 14:59:04 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
@@ -348,10 +348,10 @@ let _markup_paragraph dbh hostid text =
               (* close tags ignored *)
               escape_html first :: "&lt;/" :: escape_html elem :: "&gt;" ::
                 loop (rest, [])
-          | FoundOpen (first, elem, rest) when elem = "nowiki" ->
+          | FoundOpen (first, "nowiki", rest) ->
               (* handle <nowiki> specially ... *)
-              escape_html first :: loop (rest, elem :: [])
-          | FoundOpen (first, elem, rest) when elem = "br" ->
+              escape_html first :: loop (rest, "nowiki" :: [])
+          | FoundOpen (first, "br", rest) ->
               (* handle <br> specially ... *)
               escape_html first :: "<br/>" :: loop (rest, [])
           | FoundOpen (first, elem, rest) ->
@@ -374,10 +374,10 @@ let _markup_paragraph dbh hostid text =
           | FoundClose (first, elem, rest, elem_rest) ->
               (* non-matching close tag *)
               escape_html first :: "</" :: x :: ">" :: loop (elem_rest, xs)
-          | FoundOpen (first, elem, rest) when elem = "nowiki" ->
+          | FoundOpen (first, "nowiki", rest) ->
               (* handle <nowiki> specially ... *)
-              escape_html first :: loop (rest, elem :: stack)
-          | FoundOpen (first, elem, rest) when elem = "br" ->
+              escape_html first :: loop (rest, "nowiki" :: stack)
+          | FoundOpen (first, "br", rest) ->
               (* handle <br> specially ... *)
               escape_html first :: "<br/>" :: loop (rest, stack)
           | FoundOpen (first, elem, rest) ->
@@ -640,11 +640,53 @@ let numbered_re = Pcre.regexp "^(\\#)\\s+(.*)"
 let preformatted_re = Pcre.regexp "^ (.*)"
 let html_open_re = Pcre.regexp "^<html>\\s*$"
 let html_close_re = Pcre.regexp "^</html>\\s*$"
+let macro_re = Pcre.regexp "^{{(\\w+)}}$"
 
 let xhtml_of_content dbh hostid text =
   (* Split the text into lines. *)
   let lines = Pcre.split ~rex:split_lines_re text in
 
+  (* Do macro expansion before anything else, because macros could
+   * contain <html> sections, etc.
+   *)
+  let is_macro line =
+    try
+      let subs = Pcre.exec ~rex:macro_re line in
+      let name = Pcre.get_substring subs 1 in
+      let rows = PGSQL(dbh) "select 1 from macros
+                              where hostid = $hostid and name = $name" in
+      (match rows with
+       | [] -> false (* Not an actual macro name from the database. *)
+       | [_] -> true (* Is an actual macro name. *)
+       | _ -> assert false (* Uniqueness should stop this from happening. *)
+      )
+    with
+      Not_found -> false
+  in
+  let expand_macro line =
+    try
+      let subs = Pcre.exec ~rex:macro_re line in
+      let name = Pcre.get_substring subs 1 in
+      let content =
+       List.hd (
+         PGSQL(dbh) "select content from macros
+                       where hostid = $hostid and name = $name"
+       ) in
+      (* Split the content into lines of text. *)
+      let lines = Pcre.split ~rex:split_lines_re content in
+      lines
+    with
+      (Not_found | Failure "hd" | ExtList.List.Empty_list) as exn ->
+       failwith ("Wikilib: expand_macro: you should never see this: " ^
+                   Printexc.to_string exn)
+  in
+  let rec loop = function
+    | [] -> []
+    | line :: xs when is_macro line -> expand_macro line @ loop xs
+    | x :: xs -> x :: loop xs
+  in
+  let lines = loop lines in
+
   (* HTML blocks span multiple lines, so isolate these out first. *)
   let rec loop = function
     | [] -> []
@@ -670,36 +712,37 @@ let xhtml_of_content dbh hostid text =
 
   (* Iterate over the lines to isolate headers and paragraphs. *)
   let lines =
-    List.map
-      (function
-        | STpLine line ->
-            if Pcre.pmatch ~rex:preformatted_re line then (
-              let subs = Pcre.exec ~rex:preformatted_re line in
-              let line = Pcre.get_substring subs 1 in
-              STPreformatted [line]
-            )
-             else if Pcre.pmatch ~rex:blank_re line then
-               STBlank
-             else if Pcre.pmatch ~rex:heading_re line then (
-               let subs = Pcre.exec ~rex:heading_re line in
-               let count = String.length (Pcre.get_substring subs 1) + 2 in
-               let line = Pcre.get_substring subs 2 in
-               STHeading (count, line)
-             )
-             else if Pcre.pmatch ~rex:unnumbered_re line then (
-               let subs = Pcre.exec ~rex:unnumbered_re line in
-               let line = Pcre.get_substring subs 2 in
-               STUnnumbered [line]
-             )
-             else if Pcre.pmatch ~rex:numbered_re line then (
-               let subs = Pcre.exec ~rex:numbered_re line in
-               let line = Pcre.get_substring subs 2 in
-               STNumbered [line]
-             ) else
-               STParagraph line
-        | STpHTML html ->
-            STHTML html
-      ) lines in
+    List.map (
+      function
+      | STpLine line ->
+         if Pcre.pmatch ~rex:preformatted_re line then (
+           let subs = Pcre.exec ~rex:preformatted_re line in
+           let line = Pcre.get_substring subs 1 in
+           STPreformatted [line]
+         )
+          else if Pcre.pmatch ~rex:blank_re line then
+            STBlank
+          else if Pcre.pmatch ~rex:heading_re line then (
+            let subs = Pcre.exec ~rex:heading_re line in
+            let count = String.length (Pcre.get_substring subs 1) + 2 in
+            let line = Pcre.get_substring subs 2 in
+            STHeading (count, line)
+          )
+          else if Pcre.pmatch ~rex:unnumbered_re line then (
+            let subs = Pcre.exec ~rex:unnumbered_re line in
+            let line = Pcre.get_substring subs 2 in
+            STUnnumbered [line]
+          )
+          else if Pcre.pmatch ~rex:numbered_re line then (
+            let subs = Pcre.exec ~rex:numbered_re line in
+            let line = Pcre.get_substring subs 2 in
+            STNumbered [line]
+         )
+         else
+            STParagraph line
+      | STpHTML html ->
+         STHTML html
+    ) lines in
 
   (* Aggregate paragraphs and lists. *)
   let rec loop = function