diff options
author | David A. Madore <david+git@madore.org> | 2010-10-09 22:06:05 +0200 |
---|---|---|
committer | David A. Madore <david+git@madore.org> | 2010-10-09 22:06:05 +0200 |
commit | f58d15f93fe1f9dda09d7b564a49d9fd4c53a08d (patch) | |
tree | f1985a816352c7fdbc8947e4e6c0e95896dded13 /org/madore | |
parent | b39ca81f1300ad9e59839a9a52e9a6081dd4a517 (diff) | |
download | damlengine-f58d15f93fe1f9dda09d7b564a49d9fd4c53a08d.tar.gz damlengine-f58d15f93fe1f9dda09d7b564a49d9fd4c53a08d.tar.bz2 damlengine-f58d15f93fe1f9dda09d7b564a49d9fd4c53a08d.zip |
Footer handler.
Diffstat (limited to 'org/madore')
-rw-r--r-- | org/madore/damlengine/TodoBodyElement.java | 2 | ||||
-rw-r--r-- | org/madore/damlengine/TodoFooter.java | 51 |
2 files changed, 52 insertions, 1 deletions
diff --git a/org/madore/damlengine/TodoBodyElement.java b/org/madore/damlengine/TodoBodyElement.java index ce1f064..e70bd3b 100644 --- a/org/madore/damlengine/TodoBodyElement.java +++ b/org/madore/damlengine/TodoBodyElement.java @@ -68,7 +68,7 @@ public final class TodoBodyElement extends TodoDefaultElement { "d:implicit-do-footer"); bodyNode.appendChild(token); bodyNode.appendChild(ctx.doc.createTextNode("\n")); - // toProcess.add(new TodoFooter(token, this.ctx, this)); + toProcess.add(new TodoFooter(token, this.ctx, this)); } this.ownerDeque.registerAtStart(toProcess); } diff --git a/org/madore/damlengine/TodoFooter.java b/org/madore/damlengine/TodoFooter.java new file mode 100644 index 0000000..8c45eeb --- /dev/null +++ b/org/madore/damlengine/TodoFooter.java @@ -0,0 +1,51 @@ +package org.madore.damlengine; + +import java.util.ArrayList; +import java.util.regex.Pattern; +import org.w3c.dom.*; + +public final class TodoFooter extends TodoElement { + + public TodoFooter(Element node, + Context ctx, + TodoItem caller) { + super(node, ctx, caller); + } + + @Override + public void handle() { + ArrayList<TodoElement> toProcess = new ArrayList<TodoElement>(2); + Element hr = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "hr"); + hr.setAttributeNS(null, "class", "cleared"); + node.getParentNode().insertBefore(hr, node); + node.getParentNode().insertBefore(ctx.doc.createTextNode("\n"), node); + toProcess.add(TodoElement.getTodoElement(hr, this.ctx, this)); + Element addr = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "address"); + node.getParentNode().insertBefore(addr, node); + node.getParentNode().insertBefore(ctx.doc.createTextNode("\n"), node); + toProcess.add(TodoElement.getTodoElement(addr, this.ctx, this)); + Element a = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "a"); + a.setAttributeNS(null, "href", + (ctx.uriToTop==null)?"http://www.madore.org/~david/" + :ctx.uriToTop); + addr.appendChild(a); + a.appendChild(ctx.doc.createTextNode("David Madore")); + addr.appendChild(ctx.doc.createTextNode(" (")); + Element email = ctx.doc.createElementNS(DamlEngine.DAML_NS, "d:email-despammed"); + addr.appendChild(email); + addr.appendChild(ctx.doc.createTextNode(")")); + email.appendChild(ctx.doc.createTextNode("david+www")); + email.appendChild(ctx.doc.createElementNS(DamlEngine.DAML_NS, "d:email-at")); + email.appendChild(ctx.doc.createTextNode("madore")); + email.appendChild(ctx.doc.createElementNS(DamlEngine.DAML_NS, "d:email-dot")); + email.appendChild(ctx.doc.createTextNode("org")); + Node ws = node.getNextSibling(); + if ( ( ws.getNodeType() == Node.TEXT_NODE + || ws.getNodeType() == Node.CDATA_SECTION_NODE ) + && Pattern.matches("^\\s*$",((CharacterData)ws).getData()) ) + node.getParentNode().removeChild(ws); + node.getParentNode().removeChild(node); + this.ownerDeque.registerAtStart(toProcess); + } + +} |