From 62fda0a120fe4d068f1380924b5493adb70064ea Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Wed, 26 Jan 2011 16:20:12 +0100 Subject: [PATCH] oembed consumer plugin --- addon/oembed/oembed.js | 51 ++++++++++++++++++++++++++++++++++++ addon/oembed/oembed.php | 56 ++++++++++++++++++++++++++++++++++++++++ addon/oembed/oembed.png | Bin 0 -> 417 bytes 3 files changed, 107 insertions(+) create mode 100644 addon/oembed/oembed.js create mode 100644 addon/oembed/oembed.php create mode 100644 addon/oembed/oembed.png diff --git a/addon/oembed/oembed.js b/addon/oembed/oembed.js new file mode 100644 index 0000000000..26541490b1 --- /dev/null +++ b/addon/oembed/oembed.js @@ -0,0 +1,51 @@ +function oembed(){ + $("#oembed").toggleClass('hide'); +} + +function oembed_do(){ + embedurl = $('#oembed_url').attr('value'); + var url = 'http://oohembed.com/oohembed/?url='+escape( embedurl )+"&callback=?"; + + $.getJSON(url, function(data) { + var ret=""; + switch(data.type){ + case "video": { + if (data.thumbnail_url){ + tw = 200; if (data.thumbnail_width) tw=data.thumbnail_width; + th = 180; if (data.thumbnail_height) tw=data.thumbnail_height; + ret = ""; + // tiny mce bbcode plugin not support image size...... + ret += ""; + } else { + ret = data.html; + } + }; break; + case "photo": { + // tiny mce bbcode plugin not support image size...... + ret = ""; + }; break; + case "link": { + ret = ""+data.title+""; + }; break; + case "rich": { + ret = data.html; // not so safe... http://www.oembed.com/ : "Consumers may wish to load the HTML in an off-domain iframe to avoid XSS" + }; break; + default: { + alert("Error retriving data!"); + return; + } + } + var embedlink = embedurl; + if (data.title) embedlink = data.title + ret+="
"+embedlink+""; + if (data.author_name) { + ret+=" by "+data.author_name; + } + if (data.provider_name) { + ret+=" on "+data.provider_name; + } + tinyMCE.execCommand('mceInsertRawHTML',false,ret); + oembed(); + }); + +} diff --git a/addon/oembed/oembed.php b/addon/oembed/oembed.php new file mode 100644 index 0000000000..55654a5432 --- /dev/null +++ b/addon/oembed/oembed.php @@ -0,0 +1,56 @@ + + '; + + $b .= ' +
  + + +

Paste a link from 5min.com, Amazon Product Image, blip.tv, Clikthrough, CollegeHumor Video, + Daily Show with Jon Stewart, Dailymotion, dotSUB.com, Flickr Photos, Funny or Die Video, + Google Video, Hulu, Kinomap, LiveJournal UserPic, Metacafe, National Film Board of Canada, + Phodroid Photos, Photobucket, Qik Video, Revision3, Scribd, SlideShare, TwitPic, Twitter Status, + Viddler Video, Vimeo, Wikipedia, Wordpress.com, XKCD Comic, YFrog, YouTube

+
+ '; +} + + +function oembed_hook_jot_tool($a, &$b) { + $b .= ' +
+ Embed +
+ '; +} + + + +?> \ No newline at end of file diff --git a/addon/oembed/oembed.png b/addon/oembed/oembed.png new file mode 100644 index 0000000000000000000000000000000000000000..6fc3794bba5b1aa57c04469e384c301108d23892 GIT binary patch literal 417 zcmV;S0bc%zP)Yq{$FzW&zl)UA8YJ0`33Mi-f)=wY3w9|D?DQ2TLLU2VjuM>wuH5`Z^H>*F;_-_ z)db!`T}HZ&#msNU5#F)z`GRW+yn*UMOS_mZ#2RprFe_Cl=^2A)Eoj`CM9i%oO-ZZE zPu6kVqlDfRtHBFuv+CWrz!Rp5BKG4Nw-`bf&a?9Y+~5vlKRsgy&eClrv6qSWkP7tW zn6jT3V?4t!X3?JY|A