Author: hannes
Date: 2009-02-17 12:20:01 +0100 (Tue, 17 Feb 2009)
New Revision: 9507
Added:
apps/gobi/trunk/code/Page/skins/toc.skin
Modified:
apps/gobi/trunk/code/Global/WikiMarkup.js
apps/gobi/trunk/code/Page/skins/body.skin
Log:
Move auto-TOC generation into WikiMarkup.renderHeaders so we can position the toc correctly, and introduce a separate skin to control TOC layout.
Details at http://dev.helma.org/trac/helma/changeset/9507
Modified: apps/gobi/trunk/code/Global/WikiMarkup.js
===================================================================
--- apps/gobi/trunk/code/Global/WikiMarkup.js 2009-02-17 10:27:17 UTC (rev 9506)
+++ apps/gobi/trunk/code/Global/WikiMarkup.js 2009-02-17 11:20:01 UTC (rev 9507)
@@ -200,6 +200,7 @@
var chars = toJava(src).toCharArray();
var headers = [];
var max = 1, min = 6;
+ var tocPos = 0, tocPosFound = false;
while (match = re.exec(src)) {
if (buffer && match.index - written > 0)
buffer.append(chars, written, match.index - written);
@@ -211,6 +212,10 @@
min = Math.min(header.type, min);
headers[headers.length] = header;
if (buffer) {
+ if (!tocPosFound) {
+ tocPosFound = true;
+ tocPos = buffer.length();
+ }
buffer.append("<h").append(header.type).append(">");
buffer.append(header.title);
buffer.append("<a name='").append(header.anchorName);
@@ -226,6 +231,9 @@
if (written < chars.length) {
buffer.append(chars, written, chars.length - written);
}
+ if (tocPosFound) {
+ buffer.insert(tocPos, page.renderSkinAsString('toc'))
+ }
return buffer.toString();
}
}
Modified: apps/gobi/trunk/code/Page/skins/body.skin
===================================================================
--- apps/gobi/trunk/code/Page/skins/body.skin 2009-02-17 10:27:17 UTC (rev 9506)
+++ apps/gobi/trunk/code/Page/skins/body.skin 2009-02-17 11:20:01 UTC (rev 9507)
@@ -1,11 +1,4 @@
<h2><% this.name %></h2>
-<% this.toc prefix="<div class='toc'>
- <h3>Contents
- <span class='editlink'>
- [<% toggleLink id='toclist' %>]
- </span></h3>
- <ol id='toclist'>"
- suffix="</ol></div>" %>
<% this.body %>
Added: apps/gobi/trunk/code/Page/skins/toc.skin
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.