From 7d13f49dabd75be14676e27ec43ab8b297d738e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Fri, 8 Aug 2014 17:09:23 +0100 Subject: [PATCH] Add tweet embedding plugin --- js/plugins.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/js/plugins.js b/js/plugins.js index 4febfc3..0f356ce 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -351,8 +351,36 @@ plugins.factory('userPlugins', function() { ); gistPlugin.name = 'Gist'; + var tweetPlugin = new Plugin( + urlPlugin(function(url) { + var regexp = /^https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(?:es)?\/(\d+)/i; + var match = url.match(regexp); + if (match) { + url = 'https://api.twitter.com/1/statuses/oembed.json?id=' + match[2]; + return function() { + var element = document.querySelector('.embed_' + this.$$hashKey); + jsonp(url, function(data) { + // sepearate the HTML into content and script tag + var scriptIndex = data.html.indexOf("