wikilib.cmi cocanwiki_pages.cmi
cocanwiki_pages.cmx: cocanwiki.cmx cocanwiki_links.cmx cocanwiki_strings.cmx \
wikilib.cmx cocanwiki_pages.cmi
-cocanwiki_template.cmo: cocanwiki_files.cmo cocanwiki_version.cmo \
- cocanwiki_template.cmi
-cocanwiki_template.cmx: cocanwiki_files.cmx cocanwiki_version.cmx \
- cocanwiki_template.cmi
+cocanwiki_template.cmo: cocanwiki.cmo cocanwiki_files.cmo \
+ cocanwiki_strings.cmo cocanwiki_version.cmo cocanwiki_template.cmi
+cocanwiki_template.cmx: cocanwiki.cmx cocanwiki_files.cmx \
+ cocanwiki_strings.cmx cocanwiki_version.cmx cocanwiki_template.cmi
contact.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_template.cmi
contact.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_template.cmx
contact_show.cmo: cocanwiki.cmo cocanwiki_template.cmi
# Makefile for COCANWIKI.
-# $Id: Makefile,v 1.40 2004/10/14 15:57:15 rich Exp $
+# $Id: Makefile,v 1.41 2004/10/17 19:43:19 rich Exp $
include ../Makefile.config
cocanwiki_files.cmo \
cocanwiki_strings.cmo \
cocanwiki_images.cmo \
+ cocanwiki_server_settings.cmo \
cocanwiki_template.cmo \
cocanwiki_ok.cmo \
- cocanwiki_server_settings.cmo \
cocanwiki.cmo \
cocanwiki_diff.cmo \
cocanwiki_emailnotify.cmo \
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_template.ml,v 1.5 2004/09/09 12:21:22 rich Exp $
+ * $Id: cocanwiki_template.ml,v 1.6 2004/10/17 19:43:19 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
open Unix
open Cocanwiki_files
+open Cocanwiki_strings
+open Cocanwiki
+
+(* This is used to generate the id fields from URLs on the site menu. *)
+let id_of_url str =
+ let str = String.copy str in
+ for i = 0 to String.length str - 1 do
+ if not (isalnum str.[i]) then str.[i] <- '_'
+ done;
+ str
let base =
let base =
Hashtbl.replace cache path (template, mtime);
template
-let get_template (dbh : Dbi.connection) hostid filename =
+let get_template ?page (dbh : Dbi.connection) hostid filename =
let template = _get_template filename in
(* Get standard fields concerning this host from the database. *)
where hostid = ? order by ordering" in
sth#execute [`Int hostid];
+ let is_homepage =
+ match page with
+ | None -> false
+ | Some "index" -> true
+ | _ -> false in
+ template#conditional "is_homepage" is_homepage;
+
let table = sth#map (function [`String url; `String label; _] ->
+ let is_linked =
+ match page with
+ | None -> true
+ | Some page when page = url -> false
+ | _ -> true in
+ let id = id_of_url url in
[ "url", Template.VarString url;
- "label", Template.VarString label ]
+ "label", Template.VarString label;
+ "is_linked", Template.VarConditional is_linked;
+ "id", Template.VarString id ]
| _ -> assert false) in
template#table "sitemenu" table;
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_template.mli,v 1.2 2004/09/09 12:21:22 rich Exp $
+ * $Id: cocanwiki_template.mli,v 1.3 2004/10/17 19:43:19 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
(** Get template from filename, with no host-specific substitutions. *)
val _get_template : string -> Template.template
-(** Get template from filename, with host-specific substitutions. *)
-val get_template : Dbi.connection -> int -> string -> Template.template
+(** Get template from filename, with host-specific substitutions.
+ * The special ~page parameter is only used by [page.ml].
+ *)
+val get_template : ?page:string -> Dbi.connection -> int -> string -> Template.template
(* 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.32 2004/10/10 19:19:58 rich Exp $
+ * $Id: page.ml,v 1.33 2004/10/17 19:43:19 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
({ edit_anon = edit_anon;
view_anon = view_anon } as host)
user =
- let template_page = get_template dbh hostid "page.html" in
- let template_404 = get_template dbh hostid "page_404.html" in
-
let page = q#param "page" in
let page = if page = "" then "index" else page in
+ let template_page = get_template ~page dbh hostid "page.html" in
+ let template_404 = get_template dbh hostid "page_404.html" in
+
(* Host-specific fields. *)
let sth = dbh#prepare_cached "select css is not null,
feedback_email is not null,
<div id="menu_div">
<ul id="bottommenu" class="menu">
-<li class="first"> <a href="/">Home page</a> </li>
-::table(sitemenu)::<li> <a href="/::url_html_tag::">::label_html::</a> </li>
+<li id="index_li" class="first"> ::if(is_homepage)::::else::<a href="/">::end::Home page::if(is_homepage)::::else::</a>::end:: </li>
+::table(sitemenu)::<li id="::url::_li"> ::if(is_linked)::<a href="/::url_html_tag::">::end::::label_html::::if(is_linked)::</a>::end:: </li>
::end::
<li> <a href="/_sitemap">Sitemap</a> </li>
</ul>