diff options
author | David A. Madore <david+git@madore.org> | 2018-09-11 00:46:17 +0200 |
---|---|---|
committer | David A. Madore <david+git@madore.org> | 2018-09-11 00:46:17 +0200 |
commit | 40af35162bc33e6cac3651ec0e8447db10619637 (patch) | |
tree | 7be136fe0680e08c7817d4232ed3a0ac1b7bb53e /org/madore | |
parent | b127db40f8fe70dabd1fa3830fb98e63763d6775 (diff) | |
download | damlengine-40af35162bc33e6cac3651ec0e8447db10619637.tar.gz damlengine-40af35162bc33e6cac3651ec0e8447db10619637.tar.bz2 damlengine-40af35162bc33e6cac3651ec0e8447db10619637.zip |
Generate Twitter card on blog entry pages.
Diffstat (limited to 'org/madore')
-rw-r--r-- | org/madore/damlengine/TodoDamlElement.java | 26 |
1 files changed, 26 insertions, 0 deletions
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<Node> childList = getChildList(this.node); ArrayList<TodoElement> toProcessFirst = new ArrayList<TodoElement>(); ArrayList<TodoElement> toProcess = new ArrayList<TodoElement>(childList.size()+8); |