/* Stylesheet for COCANWIKI editor, derived from EWM.
- * $Id: editor.css,v 1.7 2006/07/26 13:41:31 rich Exp $
+ * $Id: editor.css,v 1.8 2006/08/17 09:11:29 rich Exp $
*/
body {
font-size: 70%;
}
+abbr.css_class {
+ font-size: 70%;
+}
+
+input.css_class {
+ font-size: 70%;
+}
+
abbr.js_onclick {
font-size: 70%;
}
divname text,
content_fti tsvector NOT NULL,
jsgo text,
- CONSTRAINT "$2" CHECK (((jsgo IS NULL) OR (divname IS NOT NULL)))
+ divclass text,
+ CONSTRAINT "$2" CHECK (((jsgo IS NULL) OR ((divname IS NOT NULL) OR (divclass IS NOT NULL))))
);
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit.ml,v 1.36 2006/08/14 11:36:50 rich Exp $
+ * $Id: edit.ml,v 1.37 2006/08/17 09:11:31 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
let divname = q#param ("divname_" ^ string_of_int !i) in
let divname =
if string_is_whitespace divname then None else Some divname in
+ let divclass = q#param ("divclass_" ^ string_of_int !i) in
+ let divclass =
+ if string_is_whitespace divclass then None else Some divclass in
let jsgo = q#param ("jsgo_" ^ string_of_int !i) in
let jsgo = if string_is_whitespace jsgo then None else Some jsgo in
- contents := (sectionname, divname, jsgo, content) :: !contents;
+ contents := (sectionname, divname, divclass, jsgo, content) :: !contents;
incr i
done;
let contents = List.rev !contents in
*)
if model.contents_ <> [] then
List.iter (function
- | (None, _, _, _) ->
+ | (None, _, _, _, _) ->
add_error
"Every section except the first must have a title.";
| _ -> ())
(List.tl model.contents_);
(* There are two constraints on any non-null jsgo's:
- * (1) Must only be present if divname is non-null.
+ * (1) Must only be present if divname or divclass is non-null.
* (2) Must point to a valid URL on the current host.
*)
List.iter (
function
- | (_, None, Some _, _) ->
+ | (_, None, None, Some _, _) ->
add_error
- "Javascript onclick can only be used with a CSS id."
- | (_, _, Some jsgo, _) ->
+ "Javascript onclick can only be used with a CSS id/class."
+ | (_, _, _, Some jsgo, _) ->
let rows =
PGSQL(dbh) "select 1 from pages
where hostid = $hostid
let ordering = ref 0 in
let table =
List.map
- (fun (sectionname, divname, jsgo, content) ->
+ (fun (sectionname, divname, divclass, jsgo, content) ->
incr ordering; let ordering = Int32.of_int !ordering in
let sectionname = match sectionname with None -> "" | Some s -> s in
let divname = match divname with None -> "" | Some s -> s in
+ let divclass = match divclass with None -> "" | Some s -> s in
let jsgo = match jsgo with None -> "" | Some s -> s in
[ "ordering", Template.VarString (Int32.to_string ordering);
"sectionname", Template.VarString sectionname;
"divname", Template.VarString divname;
+ "divclass", Template.VarString divclass;
"jsgo", Template.VarString jsgo;
"content", Template.VarString content ]) model.contents_ in
template#table "contents" table;
let posn = get_action "insert" in
let item =
Some "The title of this section",
- None, None,
+ None, None, None,
"Write something here." in
model := action_insert !model posn item
) else if is_action "moveup" then (
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit_page_css.ml,v 1.23 2006/08/14 11:36:50 rich Exp $
+ * $Id: edit_page_css.ml,v 1.24 2006/08/17 09:11:31 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
let pageid = PGOCaml.serial4 dbh "pages_id_seq" in
PGSQL(dbh) "insert into contents (pageid, ordering,
- sectionname, content, divname, jsgo)
+ sectionname, content, divname, divclass,
+ jsgo)
select $pageid as pageid, ordering, sectionname,
- content, divname, jsgo
+ content, divname, divclass, jsgo
from contents
where pageid = $oldpageid";
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_create_host.ml,v 1.6 2006/08/14 11:36:50 rich Exp $
+ * $Id: cocanwiki_create_host.ml,v 1.7 2006/08/17 09:11:31 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
(* Copy page contents. *)
PGSQL(dbh)
"insert into contents (pageid, ordering, sectionname, content,
- divname, jsgo)
+ divname, divclass, jsgo)
select (select id from pages where hostid = $hostid and url = p.url),
- c.ordering, c.sectionname, c.content, c.divname, c.jsgo
+ c.ordering, c.sectionname, c.content, c.divname, c.divclass,
+ c.jsgo
from contents c, pages p
where c.pageid = p.id and p.hostid = $template and p.url is not null";
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_diff.ml,v 1.8 2006/08/14 11:36:50 rich Exp $
+ * $Id: cocanwiki_diff.ml,v 1.9 2006/08/17 09:11:31 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
| Some noodp -> string_of_bool noodp) ^ "\n\n" ^
(String.concat ""
(List.map (
- fun (sectionname, divname, jsgo, content) ->
+ fun (sectionname, divname, divclass, jsgo, content) ->
(match sectionname with
| None -> ""
| Some sectionname -> "HEADING: " ^ sectionname ^ "\n\n") ^
(match divname with
| None -> ""
| Some divname -> "CSS Id: " ^ divname ^ "\n") ^
+ (match divclass with
+ | None -> ""
+ | Some divclass -> "CSS Class: " ^ divclass ^ "\n") ^
(match jsgo with
| None -> ""
| Some jsgo -> "Javascript Onclick: " ^ jsgo ^ "\n") ^
) in
let contents_ = PGSQL(dbh)
- "select sectionname, divname, jsgo, content
+ "select sectionname, divname, divclass, jsgo, content
from contents where pageid = $version
order by ordering" in
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_mail.ml,v 1.4 2006/07/27 16:46:55 rich Exp $
+ * $Id: cocanwiki_mail.ml,v 1.5 2006/08/17 09:11:31 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
template#to_string
in
- (Some sectionname, None, None, content)
+ (Some sectionname, None, None, None, content)
in
let contents =
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_pages.ml,v 1.10 2006/08/14 11:36:50 rich Exp $
+ * $Id: cocanwiki_pages.ml,v 1.11 2006/08/17 09:11:31 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
type pt = Page of string | Title of string
type section =
- string option * string option * string option * string
- (* (sectionname, divname, jsgo, content) *)
+ string option * string option * string option * string option * string
+ (* (sectionname, divname, divclass, jsgo, content) *)
type model = {
id : int32; (* Original page ID (0 = none). *)
let new_page_with_title title =
(* Initial page contents. *)
- let contents = [ None, None, None, "<b>" ^ title ^ "</b> is " ] in
+ let contents = [ None, None, None, None, "<b>" ^ title ^ "</b> is " ] in
let model = { id = 0l;
pt = Title title;
description = title;
(* Get the sections. *)
let contents = PGSQL(dbh)
- "select sectionname, divname, jsgo, content
+ "select sectionname, divname, divclass, jsgo, content
from contents
where pageid = $pageid
order by ordering" in
(* Create the page contents. *)
let ordering = ref 0 in (* Creating new ordering. *)
List.iter (
- fun (sectionname, divname, jsgo, content) ->
+ fun (sectionname, divname, divclass, jsgo, content) ->
incr ordering; let ordering = Int32.of_int !ordering in
PGSQL(dbh)
"insert into contents (pageid, ordering, sectionname, divname,
- jsgo, content)
+ divclass, jsgo, content)
values ($pageid, $ordering,
- $?sectionname, $?divname, $?jsgo, $content)"
+ $?sectionname, $?divname, $?divclass, $?jsgo, $content)"
) model.contents_;
url, pageid
(* Create the page contents. *)
let ordering = ref 0 in (* Creating new ordering. *)
List.iter (
- fun (sectionname, divname, jsgo, content) ->
+ fun (sectionname, divname, divclass, jsgo, content) ->
incr ordering; let ordering = Int32.of_int !ordering in
PGSQL(dbh) "insert into contents (pageid,
- ordering, sectionname, divname, jsgo, content)
+ ordering, sectionname, divname, divclass,
+ jsgo, content)
values ($pageid, $ordering, $?sectionname,
- $?divname, $?jsgo, $content)"
+ $?divname, $?divclass, $?jsgo, $content)"
) model.contents_;
url, pageid
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_pages.mli,v 1.7 2006/08/14 11:36:50 rich Exp $
+ * $Id: cocanwiki_pages.mli,v 1.8 2006/08/17 09:11:31 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
type pt = Page of string | Title of string
type section =
- string option * string option * string option * string
- (* (sectionname, divname, jsgo, content) *)
+ string option * string option * string option * string option * string
+ (* (sectionname, divname, divclass, jsgo, content) *)
type model = {
id : int32; (* Original page ID (0 = none). *)
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: mail_import.ml,v 1.15 2006/08/16 15:27:02 rich Exp $
+ * $Id: mail_import.ml,v 1.16 2006/08/17 09:11:31 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
hdr_template#to_string
in
- None, Some "mail_header", None, content in
+ None, Some "mail_header", None, None, content in
(* Create the second section (mail body).
* XXX Very simple. Should be extended to understand attachments and
with
Not_found ->
"No plain text message body found" in
- Some "Message", Some "mail_body", None, content in
+ Some "Message", Some "mail_body", None, None, content in
(* Overwrite the first two sections of the current page, regardless of
* what they contain.
(* 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.57 2006/08/16 15:27:02 rich Exp $
+ * $Id: page.ml,v 1.58 2006/08/17 09:11:31 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
None -> []
| Some pageid ->
let rows = PGSQL(dbh)
- "select ordering, sectionname, content, divname, jsgo
+ "select ordering, sectionname, content, divname, divclass, jsgo
from contents where pageid = $pageid order by ordering" in
List.map
- (fun (ordering, sectionname, content, divname, jsgo) ->
+ (fun (ordering, sectionname, content, divname, divclass, jsgo) ->
let divname, has_divname =
match divname with
| None -> "", false
| Some divname -> divname, true in
+ let divclass, has_divclass =
+ match divclass with
+ | None -> "", false
+ | Some divclass -> divclass, true in
let jsgo, has_jsgo =
match jsgo with
| None -> "", false
| Some jsgo -> jsgo, true in
+
+ let has_divclass, divclass =
+ if has_jsgo then
+ (true,
+ if divclass = "" then "jsgo_div"
+ else divclass ^ " jsgo_div")
+ else
+ has_divclass, divclass in
+ let has_div = has_divname || has_divclass in
+
let sectionname, has_sectionname =
match sectionname with
| None -> "", false
(Wikilib.xhtml_of_content r dbh hostid content);
"has_divname", Template.VarConditional has_divname;
"divname", Template.VarString divname;
+ "has_divclass", Template.VarConditional has_divclass;
+ "divclass", Template.VarString divclass;
+ "has_div", Template.VarConditional has_div;
"has_jsgo", Template.VarConditional has_jsgo;
"jsgo", Template.VarString jsgo ]) rows in
"content", Template.VarString content;
"has_divname", Template.VarConditional true;
"divname", Template.VarString "form_div";
+ "has_divclass", Template.VarConditional false;
+ "divclass", Template.VarString "";
+ "has_div", Template.VarConditional true;
"has_jsgo", Template.VarConditional false;
"jsgo", Template.VarString "";
] in
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: restore.ml,v 1.25 2006/08/14 11:36:50 rich Exp $
+ * $Id: restore.ml,v 1.26 2006/08/17 09:11:31 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
let pageid = PGOCaml.serial4 dbh "pages_id_seq" in
PGSQL(dbh) "insert into contents (pageid, ordering,
- sectionname, content, divname, jsgo)
- select $pageid, ordering, sectionname, content, divname, jsgo
+ sectionname, content, divname, divclass,
+ jsgo)
+ select $pageid, ordering, sectionname, content,
+ divname, divclass, jsgo
from contents
where pageid = $version";
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: source.ml,v 1.6 2006/07/26 13:41:37 rich Exp $
+ * $Id: source.ml,v 1.7 2006/08/17 09:11:31 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
(* Now write out the sections. *)
if model.redirect = None then
List.iteri
- (fun i (sectionname, divname, jsgo, content) ->
+ (fun i (sectionname, divname, divclass, jsgo, content) ->
write "Section-Id" (string_of_int i);
(match sectionname with None -> () | Some sectionname ->
write "Section-Header" sectionname);
(match divname with None -> () | Some divname ->
write "Css-Id" divname);
+ (match divclass with None -> () | Some divclass ->
+ write "Css-Class" divclass);
(match jsgo with None -> () | Some jsgo ->
write "Javascript-Onclick" jsgo);
write "Content" content;
synch_update ('content_::ordering::', 'preview_::ordering::');
init_edit_buttons ('edit_buttons_::ordering::', 'content_::ordering::', 'preview_::ordering::');
//--></script>
-<abbr class="css_id" title="Assign a stylesheet ID to this block of text to enable further styling">CSS id</abbr>: <input class="css_id" name="divname_::ordering::" value="::divname_html_tag::" size="8"/> <abbr class="js_onclick" title="Assign a destination URL on the site where clicks in this whole region go to. (Requires Javascript)">Javascript onclick</abbr>: <input class="js_onclick" name="jsgo_::ordering::" value="::jsgo_html_tag::" size="16"/>
+<abbr class="css_id" title="Assign a stylesheet ID to this block of text to enable further styling">CSS id</abbr>: <input class="css_id" name="divname_::ordering::" value="::divname_html_tag::" size="8"/>
+<abbr class="css_id" title="Assign a stylesheet class to this block of text to enable further styling">CSS class</abbr>: <input class="css_class" name="divclass_::ordering::" value="::divclass_html_tag::" size="8"/>
+<abbr class="js_onclick" title="Assign a destination URL on the site where clicks in this whole region go to. (Requires Javascript)">Javascript onclick</abbr>: <input class="js_onclick" name="jsgo_::ordering::" value="::jsgo_html_tag::" size="16"/>
<p class="insert">
<input class="insert" type="submit" name="action_insert_::ordering::" value="Insert new section here"/>
::end::
</ul>
</div>::end::<div id="content_div">
-::table(sections)::::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::
+::table(sections)::::if(has_div)::<div::if(has_divname):: id="::divname_html_tag::"::end::::if(has_divclass):: class="::divclass_html_tag::"::end::::if(has_jsgo):: onclick="go('/::jsgo_html_tag::')"::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::
+::if(has_div)::</div>::end::::end::
</div>
<ul id="topmenu" class="menu">
(* Copy a page from one host to another. Note that this only copies
* the text, not any images which may be present.
- * $Id: copy_page.ml,v 1.4 2006/08/14 11:36:50 rich Exp $
+ * $Id: copy_page.ml,v 1.5 2006/08/17 09:11:31 rich Exp $
*
* Usage: copy_page hostid url new_hostid new_url
*)
let sth = dbh#prepare_cached
"insert into contents (pageid, ordering, sectionname, content,
- divname, jsgo)
- select ? as pageid, ordering, sectionname, content, divname, jsgo
+ divname, divclass, jsgo)
+ select ? as pageid, ordering, sectionname, content,
+ divname, divclass, jsgo
from contents
where pageid = ?" in
sth#execute [`Int new_pageid; `Int old_pageid];