summaryrefslogtreecommitdiffstats
path: root/org/madore
diff options
context:
space:
mode:
Diffstat (limited to 'org/madore')
-rw-r--r--org/madore/damlengine/TodoElement.java2
-rw-r--r--org/madore/damlengine/TodoMetaElement.java53
2 files changed, 55 insertions, 0 deletions
diff --git a/org/madore/damlengine/TodoElement.java b/org/madore/damlengine/TodoElement.java
index c8b2d11..01e5863 100644
--- a/org/madore/damlengine/TodoElement.java
+++ b/org/madore/damlengine/TodoElement.java
@@ -23,6 +23,8 @@ public abstract class TodoElement extends TodoItem {
damlFactories.put("title", new TodoTitleElement.Factory());
damlFactories.put("subtitle", new TodoSubtitleElement.Factory());
damlFactories.put("translation", new TodoTranslationElement.Factory());
+ damlFactories.put("meta-description", new TodoMetaElement.Factory(TodoMetaElement.Type.DESCRIPTION));
+ damlFactories.put("meta-keywords", new TodoMetaElement.Factory(TodoMetaElement.Type.KEYWORDS));
}
protected final Element node;
diff --git a/org/madore/damlengine/TodoMetaElement.java b/org/madore/damlengine/TodoMetaElement.java
new file mode 100644
index 0000000..1089bf9
--- /dev/null
+++ b/org/madore/damlengine/TodoMetaElement.java
@@ -0,0 +1,53 @@
+package org.madore.damlengine;
+
+import java.util.ArrayList;
+import java.util.regex.Pattern;
+import org.w3c.dom.*;
+
+public final class TodoMetaElement extends TodoDefaultElement {
+
+ public enum Type {
+ DESCRIPTION("Description"),
+ KEYWORDS("Keywords");
+ final String metaName;
+ Type(String metaName) {
+ this.metaName = metaName;
+ }
+ }
+
+ public static class Factory extends TodoElement.Factory {
+ final Type t;
+ public Factory(Type t) {
+ super();
+ this.t = t;
+ }
+ @Override
+ public TodoMetaElement newItem(Element node,
+ Context ctx,
+ TodoItem caller) {
+ return new TodoMetaElement(t, node, ctx, caller);
+ }
+ }
+
+ final Type t;
+
+ public TodoMetaElement(Type t,
+ Element node,
+ Context ctx,
+ TodoItem caller) {
+ super(node, ctx, caller);
+ this.t = t;
+ }
+
+ @Override
+ public void handleNodeOnly() {
+ Element meta = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "meta");
+ String lang = LangHelper.getLangNorec(node);
+ if ( lang != null )
+ LangHelper.setLangNorec(meta, lang);
+ meta.setAttributeNS(null, "name", t.metaName);
+ meta.setAttributeNS(null, "content", node.getTextContent());
+ node.getParentNode().replaceChild(meta, node);
+ }
+
+}