From 40af35162bc33e6cac3651ec0e8447db10619637 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Tue, 11 Sep 2018 00:46:17 +0200 Subject: Generate Twitter card on blog entry pages. --- org/madore/damlengine/TodoDamlElement.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/org/madore/damlengine/TodoDamlElement.java b/org/madore/damlengine/TodoDamlElement.java index dff27ee..50c39bb 100644 --- a/org/madore/damlengine/TodoDamlElement.java +++ b/org/madore/damlengine/TodoDamlElement.java @@ -98,6 +98,32 @@ public final class TodoDamlElement extends TodoDefaultElement { headNode.appendChild(meta); headNode.appendChild(ctx.doc.createTextNode("\n")); + // Twitter summary card + if ( ctx.wsc != null && ctx.wsc instanceof Context.WeblogSingleSelectionContext ) { + meta = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "meta"); + meta.setAttributeNS(null, "name", "twitter:card"); + meta.setAttributeNS(null, "content", "summary"); + headNode.appendChild(meta); + headNode.appendChild(ctx.doc.createTextNode("\n")); + meta = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "meta"); + meta.setAttributeNS(null, "name", "twitter:site"); + meta.setAttributeNS(null, "content", "@gro_tsen"); + headNode.appendChild(meta); + headNode.appendChild(ctx.doc.createTextNode("\n")); + final WeblogSummary wsum = WeblogSummary.getSummary(ctx.dc); + if ( wsum != null ) { + final WeblogSummary.EntrySummary esum + = wsum.entries.get(new Integer(((Context.WeblogSingleSelectionContext)(ctx.wsc)).number)); + if ( esum != null && esum.title != null ) { + meta = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "meta"); + meta.setAttributeNS(null, "name", "twitter:title"); + meta.setAttributeNS(null, "content", esum.title); + headNode.appendChild(meta); + headNode.appendChild(ctx.doc.createTextNode("\n")); + } + } + } + ArrayList childList = getChildList(this.node); ArrayList toProcessFirst = new ArrayList(); ArrayList toProcess = new ArrayList(childList.size()+8); -- cgit v1.2.3