Templating package now adds the standard stuff to every page.
authorrich <rich>
Wed, 8 Sep 2004 17:07:24 +0000 (17:07 +0000)
committerrich <rich>
Wed, 8 Sep 2004 17:07:24 +0000 (17:07 +0000)
Added outline script and template to use as starting points.
Switchable themes - added an 'easyweb' theme.

html/_css/easyweb.css [new file with mode: 0644]
html/_css/standard.css
scripts/00-TEMPLATE.ml [new file with mode: 0644]
scripts/Makefile
scripts/cocanwiki_template.ml
scripts/page.ml
templates/00-TEMPLATE.html [new file with mode: 0644]

diff --git a/html/_css/easyweb.css b/html/_css/easyweb.css
new file mode 100644 (file)
index 0000000..574ede7
--- /dev/null
@@ -0,0 +1,6 @@
+/* Stylesheet for EWM.
+ * $Id: easyweb.css,v 1.1 2004/09/08 17:07:24 rich Exp $
+ */
+
+/* Based on the standard stylesheet. */
+@import url("/_css/standard.css");
\ No newline at end of file
index 83ba185..efcdfbd 100644 (file)
@@ -1,5 +1,5 @@
-/* Stylesheet for COCANWIKI, derived from EWM.
- * $Id: standard.css,v 1.2 2004/09/08 14:01:17 rich Exp $
+/* Stylesheet for COCANWIKI.
+ * $Id: standard.css,v 1.3 2004/09/08 17:07:24 rich Exp $
  */
 
 body {
  */
 
 body {
diff --git a/scripts/00-TEMPLATE.ml b/scripts/00-TEMPLATE.ml
new file mode 100644 (file)
index 0000000..50a4c41
--- /dev/null
@@ -0,0 +1,25 @@
+(* COCANWIKI scripts.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * Copyright (C) 2004 Merjis Ltd.
+ * $Id: 00-TEMPLATE.ml,v 1.1 2004/09/08 17:07:24 rich Exp $
+ *)
+
+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 "00-TEMPLATE.html" in
+
+
+
+
+
+  q#template template
+
+let () =
+  register_script ~restrict:[CanManageUsers] run
index 423e712..3d87b3f 100644 (file)
@@ -1,5 +1,5 @@
 # Makefile for COCANWIKI.
 # Makefile for COCANWIKI.
-# $Id: Makefile,v 1.9 2004/09/08 14:47:47 rich Exp $
+# $Id: Makefile,v 1.10 2004/09/08 17:07:24 rich Exp $
 
 include ../Makefile.config
 
 
 include ../Makefile.config
 
@@ -21,7 +21,8 @@ LIB_OBJS := \
        wikilib.cmo \
        cgi_expires.cmo
 
        wikilib.cmo \
        cgi_expires.cmo
 
-OBJS := create.cmo \
+OBJS := 00-TEMPLATE.cmo \
+       create.cmo \
        create_form.cmo \
        delete_file.cmo \
        delete_file_form.cmo \
        create_form.cmo \
        delete_file.cmo \
        delete_file_form.cmo \
index 9e267da..58d45bb 100644 (file)
@@ -1,7 +1,7 @@
 (* COCANWIKI scripts.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * Copyright (C) 2004 Merjis Ltd.
 (* COCANWIKI scripts.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_template.ml,v 1.3 2004/09/08 15:46:52 rich Exp $
+ * $Id: cocanwiki_template.ml,v 1.4 2004/09/08 17:07:24 rich Exp $
  *
  * This module wraps around the Template library.  It provides caching
  * of templates and fills in standard fields on a host-specific basis.
  *
  * This module wraps around the Template library.  It provides caching
  * of templates and fills in standard fields on a host-specific basis.
@@ -25,6 +25,10 @@ let base =
              "(see README file for more details)");
   base
 
              "(see README file for more details)");
   base
 
+(* The webserver gets restarted regularly enough that this is reasonable. *)
+let { tm_year = year } = gmtime (time ())
+let year = year + 1900
+
 (* Cache of precompiled templates, arranged by full path. *)
 let cache = Hashtbl.create 32
 
 (* Cache of precompiled templates, arranged by full path. *)
 let cache = Hashtbl.create 32
 
@@ -53,6 +57,35 @@ let get_template (dbh : Dbi.connection) hostid filename =
   let template = _get_template filename in
 
   (* Get standard fields concerning this host from the database. *)
   let template = _get_template filename in
 
   (* Get standard fields concerning this host from the database. *)
-  (* XXX *)
+  let sth = dbh#prepare_cached "select theme_css from hosts
+                                 where id = ?" in
+  sth#execute [`Int hostid];
+
+  let theme_css =
+    match sth#fetch1 () with
+       [ `Null ] -> "/_css/standard.css"
+      | [ `String file ] -> file
+      | _ -> assert false in
+
+  template#set "theme_css" theme_css;
+
+  (* Site menu. *)
+  let sth = dbh#prepare_cached "select url, label, ordering from sitemenu
+                                 where hostid = ? order by ordering" in
+  sth#execute [`Int hostid];
+
+  let table = sth#map (function [`String url; `String label; _] ->
+                        [ "url", Template.VarString url;
+                          "label", Template.VarString label ]
+                        | _ -> assert false) in
+
+  template#table "sitemenu" table;
+
+  (* Wiki version. *)
+  template#set "cocanwiki_package" Cocanwiki_version.package;
+  template#set "cocanwiki_version" Cocanwiki_version.version;
+
+  (* Copyright year. *)
+  template#set "year" (string_of_int year);
 
   template
 
   template
index 38eb595..c0979f0 100644 (file)
@@ -1,7 +1,7 @@
 (* COCANWIKI scripts.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * Copyright (C) 2004 Merjis Ltd.
 (* COCANWIKI scripts.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * Copyright (C) 2004 Merjis Ltd.
- * $Id: page.ml,v 1.8 2004/09/08 15:46:53 rich Exp $
+ * $Id: page.ml,v 1.9 2004/09/08 17:07:24 rich Exp $
  *)
 
 open Apache
  *)
 
 open Apache
@@ -51,8 +51,6 @@ let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, edit_anon) user =
     t#set "description" description;
     t#set "pageid" (string_of_int pageid);
     t#set "last_modified_date" (printable_date last_modified_date);
     t#set "description" description;
     t#set "pageid" (string_of_int pageid);
     t#set "last_modified_date" (printable_date last_modified_date);
-    t#set "cocanwiki_package" Cocanwiki_version.package;
-    t#set "cocanwiki_version" Cocanwiki_version.version;
 
     if page <> page' then (* redirection *) (
       t#set "page" page';
 
     if page <> page' then (* redirection *) (
       t#set "page" page';
@@ -112,18 +110,6 @@ let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, edit_anon) user =
           t#conditional "user_logged_in" true;
           t#set "username" username);
 
           t#conditional "user_logged_in" true;
           t#set "username" username);
 
-    (* Site menu. *)
-    let sth = dbh#prepare_cached "select url, label, ordering from sitemenu
-                                   where hostid = ? order by ordering" in
-    sth#execute [`Int hostid];
-
-    let table = sth#map (function [`String url; `String label; _] ->
-                          [ "url", Template.VarString url;
-                            "label", Template.VarString label ]
-                          | _ -> assert false) in
-
-    t#table "sitemenu" table;
-
     q#template t
   in
 
     q#template t
   in
 
@@ -147,18 +133,6 @@ let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, edit_anon) user =
     t#conditional "can_edit" can_edit;
     t#conditional "can_manage_users" can_manage_users;
 
     t#conditional "can_edit" can_edit;
     t#conditional "can_manage_users" can_manage_users;
 
-    (* Site menu. *)
-    let sth = dbh#prepare_cached "select url, label, ordering from sitemenu
-                                   where hostid = ? order by ordering" in
-    sth#execute [`Int hostid];
-
-    let table = sth#map (function [`String url; `String label; _] ->
-                          [ "url", Template.VarString url;
-                            "label", Template.VarString label ]
-                          | _ -> assert false) in
-
-    t#table "sitemenu" table;
-
     q#template t
   in
 
     q#template t
   in
 
diff --git a/templates/00-TEMPLATE.html b/templates/00-TEMPLATE.html
new file mode 100644 (file)
index 0000000..4d9b283
--- /dev/null
@@ -0,0 +1,33 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<title>XXX TITLE XXX</title>
+<meta name="robots" content="noindex,nofollow"/>
+<meta name="author" content="http://www.merjis.com/" />
+<link rel="stylesheet" href="::theme_css_html_tag::" type="text/css" title="Standard"/>
+</head><body>
+
+<h1>XXX TITLE XXX</h1>
+
+<ul id="topmenu" class="menu">
+<li class="first"> <a href="/">Home&nbsp;page</a> </li>
+<li> <a href="/_sitemap">Sitemap</a> </li>
+<li> <a href="/_recent">Recent&nbsp;changes</a> </li>
+</ul>
+
+<ul id="bottommenu" class="menu">
+<li class="first"> <a href="/">Home&nbsp;page</a> </li>
+::table(sitemenu)::<li> <a href="/::url_html_tag::">::label_html::</a> </li>
+::end::
+<li> <a href="/_sitemap">Sitemap</a> </li>
+</ul>
+
+<hr/>
+
+<ul id="footer" class="menu">
+<li class="first"> <a href="/copyright">Copyright &copy; ::year::</a> </li>
+<li> Powered by <a href="http://sandbox.merjis.com/">::cocanwiki_package_html:: ::cocanwiki_version_html::</a> </li>
+</ul>
+
+</body>
+</html>
\ No newline at end of file