diff options
Diffstat (limited to 'org/madore')
-rw-r--r-- | org/madore/damlengine/Context.java | 1 | ||||
-rw-r--r-- | org/madore/damlengine/TodoComments.java | 7 | ||||
-rw-r--r-- | org/madore/damlengine/TodoCommentsScript.java | 26 | ||||
-rw-r--r-- | org/madore/damlengine/TodoWeblogElement.java | 8 | ||||
-rw-r--r-- | org/madore/damlengine/TodoWeblogSelectElement.java | 6 |
5 files changed, 47 insertions, 1 deletions
diff --git a/org/madore/damlengine/Context.java b/org/madore/damlengine/Context.java index 12e2f1b..6b627a4 100644 --- a/org/madore/damlengine/Context.java +++ b/org/madore/damlengine/Context.java @@ -22,6 +22,7 @@ public class Context implements Cloneable { public String subtitleStr; public String subtitleLang; public ArrayList<String> translations; + public StringBuffer commentsJSParam; } public GeneralContext gc; diff --git a/org/madore/damlengine/TodoComments.java b/org/madore/damlengine/TodoComments.java index 85ce7d3..e5cb04e 100644 --- a/org/madore/damlengine/TodoComments.java +++ b/org/madore/damlengine/TodoComments.java @@ -53,5 +53,12 @@ public final class TodoComments extends TodoElement { + ctx.ent.number + ".numcomments"); p.appendChild(span); span.appendChild(ctx.doc.createComment(" EMPTY ")); + if ( ctx.gc.commentsJSParam == null ) { + ctx.gc.commentsJSParam = new StringBuffer("x=" + ctx.ent.date + "." + + ctx.ent.number); + } else { + ctx.gc.commentsJSParam.append("&x=" + ctx.ent.date + "." + + ctx.ent.number); + } } } diff --git a/org/madore/damlengine/TodoCommentsScript.java b/org/madore/damlengine/TodoCommentsScript.java new file mode 100644 index 0000000..224d547 --- /dev/null +++ b/org/madore/damlengine/TodoCommentsScript.java @@ -0,0 +1,26 @@ +package org.madore.damlengine; + +import org.w3c.dom.*; + +public final class TodoCommentsScript extends TodoElement { + + public TodoCommentsScript(Element node, + Context ctx, + TodoItem caller) { + super(node, ctx, caller); + } + + @Override + public void handle() { + if ( ctx.gc.commentsJSParam == null ) { + node.getParentNode().removeChild(node); + return; + } + Element script = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "script"); + script.setAttributeNS(null, "type", "text/javascript"); + script.setAttributeNS(null, "src", "/cgi-bin/numcomments.pl/x.js?"+ctx.gc.commentsJSParam); + script.setAttributeNS(null, "defer", "defer"); + node.appendChild(ctx.doc.createComment(" EMPTY ")); + node.getParentNode().replaceChild(script, node); + } +} diff --git a/org/madore/damlengine/TodoWeblogElement.java b/org/madore/damlengine/TodoWeblogElement.java index fa537a8..3d457a8 100644 --- a/org/madore/damlengine/TodoWeblogElement.java +++ b/org/madore/damlengine/TodoWeblogElement.java @@ -23,6 +23,7 @@ public final class TodoWeblogElement extends TodoDefaultElement { @Override public void handleNodeOnly() { + System.err.println("warning: weblog element should not be processed this way!"); Node parent = node.getParentNode(); String lang = LangHelper.getLangNorec(node); ArrayList<Node> childList = getChildList(this.node); @@ -42,8 +43,13 @@ public final class TodoWeblogElement extends TodoDefaultElement { toProcess.add(it); } } - this.ownerDeque.registerAtStart(toProcess); + Element token = ctx.doc.createElementNS(DamlEngine.DAML_NS, + "d:implicit-do-comments-script"); + node.getParentNode().insertBefore(token, node); + node.getParentNode().insertBefore(ctx.doc.createTextNode("\n"), node); + toProcess.add(new TodoCommentsScript(token, ctx, this)); parent.removeChild(node); + this.ownerDeque.registerAtStart(toProcess); } } diff --git a/org/madore/damlengine/TodoWeblogSelectElement.java b/org/madore/damlengine/TodoWeblogSelectElement.java index 145b938..33c9731 100644 --- a/org/madore/damlengine/TodoWeblogSelectElement.java +++ b/org/madore/damlengine/TodoWeblogSelectElement.java @@ -42,11 +42,17 @@ public final class TodoWeblogSelectElement extends TodoDefaultElement { Document temp = par.parse(input); Node newNode = ctx.doc.adoptNode(temp.getDocumentElement()); node.getParentNode().insertBefore(newNode, node); + node.getParentNode().insertBefore(ctx.doc.createTextNode("\n"), node); TodoElement it = TodoElement.getTodoElement((Element)newNode, this.ctx, this); toProcess.add(it); } + Element token = ctx.doc.createElementNS(DamlEngine.DAML_NS, + "d:implicit-do-comments-script"); + node.getParentNode().insertBefore(token, node); + node.getParentNode().insertBefore(ctx.doc.createTextNode("\n"), node); + toProcess.add(new TodoCommentsScript(token, ctx, this)); node.getParentNode().removeChild(node); this.ownerDeque.registerAtStart(toProcess); } |