From 2a6bcc45857dc44c6cd231043b1bcf994fec51e7 Mon Sep 17 00:00:00 2001 From: rich Date: Wed, 26 Jul 2006 13:11:24 +0000 Subject: [PATCH] Support for jsgo (not in the editor yet). --- html/_css/basic.css | 7 ++++++- html/_js/go.js | 4 ++++ scripts/page.ml | 21 ++++++++++++++------- templates/page.html | 2 +- templates/page_header.html | 1 + 5 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 html/_js/go.js diff --git a/html/_css/basic.css b/html/_css/basic.css index 8311ef2..920f8ac 100644 --- a/html/_css/basic.css +++ b/html/_css/basic.css @@ -1,5 +1,5 @@ /* Minimal list of CSS required for all COCANWIKIs. - * $Id: basic.css,v 1.3 2005/04/02 17:30:54 rich Exp $ + * $Id: basic.css,v 1.4 2006/07/26 13:11:25 rich Exp $ */ /* Links. */ @@ -47,3 +47,8 @@ span.search_term { border: 1px solid #eeb; } +/* Javascript go (jsgo) divs. */ +div.jsgo_div { + cursor: pointer; + cursor: hand; +} diff --git a/html/_js/go.js b/html/_js/go.js new file mode 100644 index 0000000..6745fda --- /dev/null +++ b/html/_js/go.js @@ -0,0 +1,4 @@ +function go (url) +{ + location.href = url; +} diff --git a/scripts/page.ml b/scripts/page.ml index 7f7c0bf..7001a08 100644 --- a/scripts/page.ml +++ b/scripts/page.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: page.ml,v 1.45 2006/03/28 16:24:07 rich Exp $ + * $Id: page.ml,v 1.46 2006/07/26 13:11:25 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 @@ -240,15 +240,19 @@ let run r (q : cgi) dbh hostid None -> [] | Some pageid -> let rows = PGSQL(dbh) - "select ordering, sectionname, content, divname + "select ordering, sectionname, content, divname, jsgo from contents where pageid = $pageid order by ordering" in List.map - (fun (ordering, sectionname, content, divname) -> + (fun (ordering, sectionname, content, divname, jsgo) -> let divname, has_divname = match divname with | None -> "", false | Some divname -> divname, true in + let jsgo, has_jsgo = + match jsgo with + | None -> "", false + | Some jsgo -> jsgo, true in let sectionname, has_sectionname = match sectionname with | None -> "", false @@ -263,7 +267,9 @@ let run r (q : cgi) dbh hostid Template.VarString (Wikilib.xhtml_of_content dbh hostid content); "has_divname", Template.VarConditional has_divname; - "divname", Template.VarString divname ]) rows in + "divname", Template.VarString divname; + "has_jsgo", Template.VarConditional has_jsgo; + "jsgo", Template.VarString jsgo ]) rows in (* Call an extension to generate the first section in this page? *) let sections = @@ -278,6 +284,8 @@ let run r (q : cgi) dbh hostid "content", Template.VarString content; "has_divname", Template.VarConditional true; "divname", Template.VarString "form_div"; + "has_jsgo", Template.VarConditional false; + "jsgo", Template.VarString ""; ] in section :: sections in @@ -480,11 +488,10 @@ let run r (q : cgi) dbh hostid | FPInternalRedirect page' -> loop page' (i+1) | FPExternalRedirect page' -> - (* This normally happens when a user has request an uppercase + (* This normally happens when a user has requested an uppercase * page name. We redirect to the true (lowercase) version. *) - q#redirect ("http://" ^ host.hostname ^ "/" ^ page'); - return () + q#redirect ("http://" ^ host.hostname ^ "/" ^ page') | FPNotFound -> (* Might be a templated page with no content in it. *) let extension = get_extension page' in diff --git a/templates/page.html b/templates/page.html index 123a401..2f40a89 100644 --- a/templates/page.html +++ b/templates/page.html @@ -20,7 +20,7 @@
::table(sections):: -::if(has_divname)::
::end::::if(can_edit)::::end::::if(has_sectionname)::

::sectionname_html::

::end:: +::if(has_divname)::
::end::::if(can_edit)::::end::::if(has_sectionname)::

::sectionname_html::

::end:: ::content:: ::if(has_divname)::
::end::::end::
diff --git a/templates/page_header.html b/templates/page_header.html index cb4a2a3..2e06e52 100644 --- a/templates/page_header.html +++ b/templates/page_header.html @@ -9,6 +9,7 @@ ::if(has_host_css)::::end:: ::if(has_page_css)::::end:: + -- 1.8.3.1