summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2018-09-10 22:46:17 (GMT)
committerDavid A. Madore <david+git@madore.org>2018-09-10 22:46:17 (GMT)
commit40af35162bc33e6cac3651ec0e8447db10619637 (patch)
tree7be136fe0680e08c7817d4232ed3a0ac1b7bb53e
parentb127db40f8fe70dabd1fa3830fb98e63763d6775 (diff)
downloaddamlengine-40af35162bc33e6cac3651ec0e8447db10619637.zip
damlengine-40af35162bc33e6cac3651ec0e8447db10619637.tar.gz
damlengine-40af35162bc33e6cac3651ec0e8447db10619637.tar.bz2
Generate Twitter card on blog entry pages.
-rw-r--r--org/madore/damlengine/TodoDamlElement.java26
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);