Add shortcode for tweets
authordigitalcraftsman <digitalcraftsman@users.noreply.github.com>
Fri, 20 Nov 2015 18:44:05 +0000 (19:44 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 24 Nov 2015 07:59:32 +0000 (08:59 +0100)
tpl/template_embedded.go

index 5ae37a34005e733aedf03f696ad9fa1201a317f4..673907d00761c1b2a656661e74cbbd1d33f7aafe 100644 (file)
@@ -47,6 +47,9 @@ func (t *GoHTMLTemplate) EmbedShortcodes() {
   <iframe src="//player.vimeo.com/video/{{ index .Params 0 }}" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
 </div>`)
        t.AddInternalShortcode("gist.html", `<script src="https://gist.github.com/{{ index .Params 0 }}/{{ index .Params 1 }}.js"></script>`)
+       t.AddInternalShortcode("tweet.html", `{{ $user  := index .Params 0 }}
+{{ $tweet := index .Params 1 }}
+{{ (getJSON "https://api.twitter.com/1/statuses/oembed.json?url=https://twitter.com/" $user "/status/" $tweet).html | safeHTML }}`)
 }
 
 func (t *GoHTMLTemplate) EmbedTemplates() {