From 457ce3fb7d0bd2198d1397912093cc1f99befe26 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Wed, 7 Sep 2011 18:01:38 +0200 Subject: Use HTML5 elements for header, hgroup, nav(bar), footer. --- org/madore/damlengine/TodoCommentsScript.java | 2 +- org/madore/damlengine/TodoDamlElement.java | 22 ++++++++++++++-------- .../damlengine/TodoExtraStyleOrScriptElement.java | 2 +- org/madore/damlengine/TodoFooter.java | 16 +++++++++------- org/madore/damlengine/TodoNavbar.java | 2 +- org/madore/damlengine/TodoSubtitleElement.java | 2 +- org/madore/damlengine/TodoTitleOrSubtitle.java | 2 +- org/madore/damlengine/TodoTranslationElement.java | 2 +- org/madore/damlengine/TodoTranslations.java | 4 ++-- org/madore/damlengine/included.css | 4 ++++ 10 files changed, 35 insertions(+), 23 deletions(-) diff --git a/org/madore/damlengine/TodoCommentsScript.java b/org/madore/damlengine/TodoCommentsScript.java index eb250e8..fbe0bbe 100644 --- a/org/madore/damlengine/TodoCommentsScript.java +++ b/org/madore/damlengine/TodoCommentsScript.java @@ -15,7 +15,7 @@ public final class TodoCommentsScript extends TodoElement { public void handle() { if ( ctx.gc.commentsJSParam == null ) { Node ws = node.getNextSibling(); - if ( ( ws.getNodeType() == Node.TEXT_NODE + if ( ws != null && ( ws.getNodeType() == Node.TEXT_NODE || ws.getNodeType() == Node.CDATA_SECTION_NODE ) && Pattern.matches("^\\s*$",((CharacterData)ws).getData()) ) node.getParentNode().removeChild(ws); diff --git a/org/madore/damlengine/TodoDamlElement.java b/org/madore/damlengine/TodoDamlElement.java index 5237d91..93275d9 100644 --- a/org/madore/damlengine/TodoDamlElement.java +++ b/org/madore/damlengine/TodoDamlElement.java @@ -95,34 +95,40 @@ public final class TodoDamlElement extends TodoDefaultElement { ArrayList childList = getChildList(this.node); ArrayList toProcessFirst = new ArrayList(); ArrayList toProcess = new ArrayList(childList.size()+8); + Element header = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "header"); + bodyNode.appendChild(ctx.doc.createTextNode("\n")); + bodyNode.appendChild(header); + Element hgroup = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "hgroup"); + header.appendChild(ctx.doc.createTextNode("\n")); + header.appendChild(hgroup); if ( node.getAttributeNS(null, "notitle").equals("") ) { Element token = ctx.doc.createElementNS(DamlEngine.DAML_NS, "d:implicit-do-title"); - bodyNode.appendChild(ctx.doc.createTextNode("\n")); - bodyNode.appendChild(token); + hgroup.appendChild(ctx.doc.createTextNode("\n")); + hgroup.appendChild(token); toProcess.add(new TodoTitleOrSubtitle(TodoTitleOrSubtitle.Type.TITLE, token, this.ctx, this)); } if ( node.getAttributeNS(null, "nosubtitle").equals("") ) { Element token = ctx.doc.createElementNS(DamlEngine.DAML_NS, "d:implicit-do-subtitle"); - bodyNode.appendChild(ctx.doc.createTextNode("\n")); - bodyNode.appendChild(token); + hgroup.appendChild(ctx.doc.createTextNode("\n")); + hgroup.appendChild(token); toProcess.add(new TodoTitleOrSubtitle(TodoTitleOrSubtitle.Type.SUBTITLE, token, this.ctx, this)); } if ( node.getAttributeNS(null, "nonavbar").equals("") ) { Element token = ctx.doc.createElementNS(DamlEngine.DAML_NS, "d:implicit-do-navbar"); - bodyNode.appendChild(ctx.doc.createTextNode("\n")); - bodyNode.appendChild(token); + header.appendChild(ctx.doc.createTextNode("\n")); + header.appendChild(token); toProcess.add(new TodoNavbar(token, this.ctx, this)); } if ( node.getAttributeNS(null, "notranslations").equals("") ) { Element token = ctx.doc.createElementNS(DamlEngine.DAML_NS, "d:implicit-do-translations"); - bodyNode.appendChild(ctx.doc.createTextNode("\n")); - bodyNode.appendChild(token); + header.appendChild(ctx.doc.createTextNode("\n")); + header.appendChild(token); toProcess.add(new TodoTranslations(token, this.ctx, this)); } for ( Node child : childList ) { diff --git a/org/madore/damlengine/TodoExtraStyleOrScriptElement.java b/org/madore/damlengine/TodoExtraStyleOrScriptElement.java index 9b4a6c6..d285d8f 100644 --- a/org/madore/damlengine/TodoExtraStyleOrScriptElement.java +++ b/org/madore/damlengine/TodoExtraStyleOrScriptElement.java @@ -37,7 +37,7 @@ public final class TodoExtraStyleOrScriptElement extends TodoDefaultElement { else ctx.gc.styleContent.append(content); Node ws = node.getNextSibling(); - if ( ( ws.getNodeType() == Node.TEXT_NODE + if ( ws != null && ( ws.getNodeType() == Node.TEXT_NODE || ws.getNodeType() == Node.CDATA_SECTION_NODE ) && Pattern.matches("^\\s*$",((CharacterData)ws).getData()) ) node.getParentNode().removeChild(ws); diff --git a/org/madore/damlengine/TodoFooter.java b/org/madore/damlengine/TodoFooter.java index c47c951..ece31d4 100644 --- a/org/madore/damlengine/TodoFooter.java +++ b/org/madore/damlengine/TodoFooter.java @@ -14,15 +14,17 @@ public final class TodoFooter extends TodoElement { @Override public void handle() { + Element footer = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "footer"); + node.getParentNode().insertBefore(footer, node); + node.getParentNode().insertBefore(ctx.doc.createTextNode("\n"), node); + footer.setAttributeNS(null, "class", "cleared"); ArrayList toProcess = new ArrayList(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)); + footer.appendChild(hr); + footer.appendChild(ctx.doc.createTextNode("\n")); Element addr = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "address"); - node.getParentNode().insertBefore(addr, node); - node.getParentNode().insertBefore(ctx.doc.createTextNode("\n"), node); + footer.appendChild(addr); + footer.appendChild(ctx.doc.createTextNode("\n")); toProcess.add(TodoElement.getTodoElement(addr, this.ctx, this)); Element a = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "a"); a.setAttributeNS(null, "href", @@ -40,7 +42,7 @@ public final class TodoFooter extends TodoElement { 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 + if ( ws != null && ( ws.getNodeType() == Node.TEXT_NODE || ws.getNodeType() == Node.CDATA_SECTION_NODE ) && Pattern.matches("^\\s*$",((CharacterData)ws).getData()) ) node.getParentNode().removeChild(ws); diff --git a/org/madore/damlengine/TodoNavbar.java b/org/madore/damlengine/TodoNavbar.java index 4b05180..145ac77 100644 --- a/org/madore/damlengine/TodoNavbar.java +++ b/org/madore/damlengine/TodoNavbar.java @@ -12,7 +12,7 @@ public final class TodoNavbar extends TodoElement { @Override public void handle() { - Element p = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "p"); + Element p = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "nav"); String lang = LangHelper.getLangRec(node); String explicitLang = LangHelper.getLangNorec(node); if ( lang == null || ! ( lang.equals("en") || lang.equals("fr") ) ) { diff --git a/org/madore/damlengine/TodoSubtitleElement.java b/org/madore/damlengine/TodoSubtitleElement.java index 361bcfc..f40ed96 100644 --- a/org/madore/damlengine/TodoSubtitleElement.java +++ b/org/madore/damlengine/TodoSubtitleElement.java @@ -33,7 +33,7 @@ public final class TodoSubtitleElement extends TodoDefaultElement { ctx.gc.subtitle.appendChild(child); } Node ws = node.getNextSibling(); - if ( ( ws.getNodeType() == Node.TEXT_NODE + if ( ws != null && ( ws.getNodeType() == Node.TEXT_NODE || ws.getNodeType() == Node.CDATA_SECTION_NODE ) && Pattern.matches("^\\s*$",((CharacterData)ws).getData()) ) node.getParentNode().removeChild(ws); diff --git a/org/madore/damlengine/TodoTitleOrSubtitle.java b/org/madore/damlengine/TodoTitleOrSubtitle.java index 01c4973..3000c61 100644 --- a/org/madore/damlengine/TodoTitleOrSubtitle.java +++ b/org/madore/damlengine/TodoTitleOrSubtitle.java @@ -31,7 +31,7 @@ public final class TodoTitleOrSubtitle extends TodoElement { public void handle() { if ( ((t==Type.TITLE)?ctx.gc.title:ctx.gc.subtitle) == null ) { Node ws = node.getNextSibling(); - if ( ( ws.getNodeType() == Node.TEXT_NODE + if ( ws != null && ( ws.getNodeType() == Node.TEXT_NODE || ws.getNodeType() == Node.CDATA_SECTION_NODE ) && Pattern.matches("^\\s*$",((CharacterData)ws).getData()) ) node.getParentNode().removeChild(ws); diff --git a/org/madore/damlengine/TodoTranslationElement.java b/org/madore/damlengine/TodoTranslationElement.java index 90a44a7..b66fb93 100644 --- a/org/madore/damlengine/TodoTranslationElement.java +++ b/org/madore/damlengine/TodoTranslationElement.java @@ -30,7 +30,7 @@ public final class TodoTranslationElement extends TodoDefaultElement { throw new IllegalArgumentException("translation element must have an xml:lang attribute"); ctx.gc.translations.add(lang); Node ws = node.getNextSibling(); - if ( ( ws.getNodeType() == Node.TEXT_NODE + if ( ws != null && ( ws.getNodeType() == Node.TEXT_NODE || ws.getNodeType() == Node.CDATA_SECTION_NODE ) && Pattern.matches("^\\s*$",((CharacterData)ws).getData()) ) node.getParentNode().removeChild(ws); diff --git a/org/madore/damlengine/TodoTranslations.java b/org/madore/damlengine/TodoTranslations.java index dc67c30..cfd08af 100644 --- a/org/madore/damlengine/TodoTranslations.java +++ b/org/madore/damlengine/TodoTranslations.java @@ -16,7 +16,7 @@ public final class TodoTranslations extends TodoElement { public void handle() { if ( ctx.gc.translations == null ) { Node ws = node.getNextSibling(); - if ( ( ws.getNodeType() == Node.TEXT_NODE + if ( ws != null && ( ws.getNodeType() == Node.TEXT_NODE || ws.getNodeType() == Node.CDATA_SECTION_NODE ) && Pattern.matches("^\\s*$",((CharacterData)ws).getData()) ) node.getParentNode().removeChild(ws); @@ -55,7 +55,7 @@ public final class TodoTranslations extends TodoElement { toProcess.add(TodoElement.getTodoElement(p, this.ctx, this)); } Node ws = node.getNextSibling(); - if ( ( ws.getNodeType() == Node.TEXT_NODE + if ( ws != null && ( ws.getNodeType() == Node.TEXT_NODE || ws.getNodeType() == Node.CDATA_SECTION_NODE ) && Pattern.matches("^\\s*$",((CharacterData)ws).getData()) ) node.getParentNode().removeChild(ws); diff --git a/org/madore/damlengine/included.css b/org/madore/damlengine/included.css index ff9d538..a7cdce3 100644 --- a/org/madore/damlengine/included.css +++ b/org/madore/damlengine/included.css @@ -15,6 +15,7 @@ h3 { color: rgb(96,64,0); } color: rgb(24,96,0); } .navbar { + display: block; font-size: .83em; font-family: "Times Roman", Times, "Times New Roman", serif; } @@ -97,3 +98,6 @@ li { -moz-float-edge: content-box; } /* Undo Mozilla buggy bugware! */ .weblog-internal-link:link,.weblog-internal-link:visited { color: rgb(0,64,192); } :link:hover,:visited:hover { text-decoration: underline; } } +@media print { + .navbar { display: none; } +} -- cgit v1.2.3