Support for jsgo (not in the editor yet).
authorrich <rich>
Wed, 26 Jul 2006 13:11:24 +0000 (13:11 +0000)
committerrich <rich>
Wed, 26 Jul 2006 13:11:24 +0000 (13:11 +0000)
html/_css/basic.css
html/_js/go.js [new file with mode: 0644]
scripts/page.ml
templates/page.html
templates/page_header.html

index 8311ef2..920f8ac 100644 (file)
@@ -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 (file)
index 0000000..6745fda
--- /dev/null
@@ -0,0 +1,4 @@
+function go (url)
+{
+  location.href = url;
+}
index 7f7c0bf..7001a08 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: 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
index 123a401..2f40a89 100644 (file)
@@ -20,7 +20,7 @@
 
 <div id="content_div">
 ::table(sections)::
-::if(has_divname)::<div id="::divname_html_tag::">::end::::if(can_edit)::<p class="edit_link">[<a href="/::page_html_tag::/edit#::ordering::" title="Edit this section">edit</a>]</p>::end::::if(has_sectionname)::<a name="::linkname_html_tag::"></a><h2><span>::sectionname_html::</span></h2>::end::
+::if(has_divname)::<div id="::divname_html_tag::"::if(has_jsgo):: onclick="go('/::jsgo_html_tag::')" class="jsgo_div"::end::>::end::::if(can_edit)::<p class="edit_link">[<a href="/::page_html_tag::/edit#::ordering::" title="Edit this section">edit</a>]</p>::end::::if(has_sectionname)::<a name="::linkname_html_tag::"></a><h2><span>::sectionname_html::</span></h2>::end::
 ::content::
 ::if(has_divname)::</div>::end::::end::
 </div>
index cb4a2a3..2e06e52 100644 (file)
@@ -9,6 +9,7 @@
 <link rel="alternate stylesheet" href="/_css/easytoread.css" type="text/css" title="High contrast, big fonts"/>
 ::if(has_host_css)::<link rel="stylesheet" href="/_global.css" type="text/css" title="Standard"/>::end::
 ::if(has_page_css)::<link rel="stylesheet" href="/::page_html_tag::/styles.css::if(is_old_version)::?version=::old_version::::end::" type="text/css" title="Standard"/>::end::
+<script src="/_js/go.js" type="text/javascript"></script>
 <link rel="icon" href="/_graphics/favicon.png" type="image/png" />
 <link rel="SHORTCUT ICON" href="/favicon.ico" type="image/x-icon" />
 </head>