diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000..719153d4b
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,9 @@
+root = true
+
+[*]
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = false
+insert_final_newline = true
+indent_style = tab
+indent_size = 4
diff --git a/.travis.yml b/.travis.yml
index 23ccb125a..eb62f813c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,5 @@
language: php
php:
-- 5.3
- 5.4
- 5.5
- 5.6
@@ -11,14 +10,14 @@ before_script:
- npm install grunt grunt-cli grunt-contrib-jshint grunt-contrib-csslint grunt-phplint --save-dev
- mysql -u root -e "CREATE DATABASE rhymix"
- mysql -u root -e "SET PASSWORD FOR 'travis'@'localhost' = PASSWORD('travis')"
-- if [[ $TRAVIS_PHP_VERSION != "hhvm" ]]; then php -S localhost:8000 & fi
-- if [[ $TRAVIS_PHP_VERSION == "5.3" ]]; then touch codecept.phar; fi
+- if [[ $TRAVIS_PHP_VERSION != "5.4" && $TRAVIS_PHP_VERSION != "hhvm" ]]; then php -S localhost:8000 & fi
- if [[ $TRAVIS_PHP_VERSION == "5.4" ]]; then wget http://codeception.com/releases/2.0.16/codecept.phar; fi
-- if [[ ! -f codecept.phar ]]; then wget http://codeception.com/codecept.phar; fi
+- if [[ ! -f codecept.phar ]]; then wget http://codeception.com/releases/2.1.6/codecept.phar; fi
script:
-- if [[ -f codecept.phar ]]; then php codecept.phar build; fi
-- if [[ $TRAVIS_PHP_VERSION == "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis --skip install; fi
-- if [[ $TRAVIS_PHP_VERSION != "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis; fi
+- if [[ -s codecept.phar ]]; then php codecept.phar build; fi
+- if [[ -s codecept.phar && $TRAVIS_PHP_VERSION == "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis --skip install; fi
+- if [[ -s codecept.phar && $TRAVIS_PHP_VERSION == "5.4" ]]; then php codecept.phar run -d --fail-fast --env travis --skip install; fi
+- if [[ -s codecept.phar && $TRAVIS_PHP_VERSION != "5.4" && $TRAVIS_PHP_VERSION != "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis; fi
- grunt lint
notifications:
email: false
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 7e482d998..fd98ea028 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -58,6 +58,8 @@ PHP, HTML, XML, CSS, JS 등 모든 텍스트 파일의 문자셋은 BOM이 없
들여쓰기는 1개의 탭으로 합니다.
단, 탭 대신 공백을 사용하는 파일에서는 일관성 유지를 위해 4칸의 공백을 사용할 수 있습니다.
+들여쓴 줄들 사이의 빈 줄도 들여씁니다. (에디터에서 후행 공백을 제거하지 않도록 설정하십시오.)
+
PHP 코드만으로 이루어진 파일은 맨 끝에 `?>` 태그를 사용하지 않습니다.
### 공백 및 줄바꿈 규칙
@@ -155,5 +157,8 @@ Rhymix에서 정한 `error_reporting` 설정 하에서 어떤 에러도 발생
문자열과 문자열, 정수와 정수를 비교할 때는 가능하면 `==` 대신 `===`을 사용합니다.
실제 자료형이 다를 가능성이 있는 경우 `intval()`, `strval()` 등의 함수와 함께 사용합니다.
+PHP 5.4 이상에서 지원하는 간단한 배열 문법(`[1, 2, 3]`)을 사용할 수 있으나,
+복잡한 구조의 배열을 선언할 때는 이 문법이 오히려 가독성을 해칠 수 있으니 주의하시기 바랍니다.
+
여기에서 규정하지 않은 내용은 [PSR-1](http://www.php-fig.org/psr/psr-1/)과
[PSR-2](http://www.php-fig.org/psr/psr-2/)를 따릅니다.
diff --git a/README.md b/README.md
index 7c3975e43..83fc1d487 100644
--- a/README.md
+++ b/README.md
@@ -32,18 +32,23 @@ Rhymix는 개발자와 사용자가 서로의 권리와 책임을 존중하는
### 설치 환경
-- PHP 5.3.3 이상 (PHP 5.5.9 이상 권장, PHP 7 지원)
-- MySQL 4.1.13 이상 (MySQL 5.0.7 이상 또는 MariaDB 권장)
-- CUBRID 또는 MS SQL을 DB로 사용할 수도 있으나, 권장하지는 않습니다.
+Rhymix를 사용하려면 아래의 조건을 충족하는 웹호스팅이나 서버를 마련하셔야 합니다.
+
+
+- PHP 5.5.9 이상 (PHP 7 권장)
+- MySQL 5.0.7 이상 (MariaDB 권장)
- 필수 PHP 모듈
- curl
- gd
- iconv 또는 mbstring
- json
- mcrypt 또는 openssl
- - xml 및 simplexml
+ - simplexml
- php.ini에서 session.auto_start = Off로 설정되어 있어야 합니다.
- 설치 폴더 또는 files 폴더에 쓰기 권한이 주어져야 합니다.
+- MySQL/MariaDB 외에도 아래의 DB를 사용할 수 있습니다.
+ - CUBRID 9.0 이상
+ - Microsoft SQL Server 2008 이상
### 개발 참여
diff --git a/addons/oembed/jquery.oembed.js b/addons/oembed/jquery.oembed.js
index dd17f4841..1bafb620e 100755
--- a/addons/oembed/jquery.oembed.js
+++ b/addons/oembed/jquery.oembed.js
@@ -5,1054 +5,952 @@
* Licensed under the MIT license
*
* Orignal Author: Richard Chamorro
- * Forked by Andrew Mee to Provide a slightly diffent kind of embedding
- * experience
- *
- * Modified : NAVER Corp.
+ * Forked by Andrew Mee to Provide a slightly diffent kind of embedding experience
*/
(function ($) {
- $.fn.oembed = function (url, options, embedAction) {
- settings = $.extend(true, $.fn.oembed.defaults, options);
- var shortURLList = ["0rz.tw", "1link.in", "1url.com", "2.gp", "2big.at", "2tu.us", "3.ly", "307.to", "4ms.me", "4sq.com", "4url.cc", "6url.com", "7.ly", "a.gg", "a.nf", "aa.cx", "abcurl.net",
- "ad.vu", "adf.ly", "adjix.com", "afx.cc", "all.fuseurl.com", "alturl.com", "amzn.to", "ar.gy", "arst.ch", "atu.ca", "azc.cc", "b23.ru", "b2l.me", "bacn.me", "bcool.bz", "binged.it",
- "bit.ly", "bizj.us", "bloat.me", "bravo.ly", "bsa.ly", "budurl.com", "canurl.com", "chilp.it", "chzb.gr", "cl.lk", "cl.ly", "clck.ru", "cli.gs", "cliccami.info",
- "clickthru.ca", "clop.in", "conta.cc", "cort.as", "cot.ag", "crks.me", "ctvr.us", "cutt.us", "dai.ly", "decenturl.com", "dfl8.me", "digbig.com",
- "http:\/\/digg\.com\/[^\/]+$", "disq.us", "dld.bz", "dlvr.it", "do.my", "doiop.com", "dopen.us", "easyuri.com", "easyurl.net", "eepurl.com", "eweri.com",
- "fa.by", "fav.me", "fb.me", "fbshare.me", "ff.im", "fff.to", "fire.to", "firsturl.de", "firsturl.net", "flic.kr", "flq.us", "fly2.ws", "fon.gs", "freak.to",
- "fuseurl.com", "fuzzy.to", "fwd4.me", "fwib.net", "g.ro.lt", "gizmo.do", "gl.am", "go.9nl.com", "go.ign.com", "go.usa.gov", "goo.gl", "goshrink.com", "gurl.es",
- "hex.io", "hiderefer.com", "hmm.ph", "href.in", "hsblinks.com", "htxt.it", "huff.to", "hulu.com", "hurl.me", "hurl.ws", "icanhaz.com", "idek.net", "ilix.in", "is.gd",
- "its.my", "ix.lt", "j.mp", "jijr.com", "kl.am", "klck.me", "korta.nu", "krunchd.com", "l9k.net", "lat.ms", "liip.to", "liltext.com", "linkbee.com", "linkbun.ch",
- "liurl.cn", "ln-s.net", "ln-s.ru", "lnk.gd", "lnk.ms", "lnkd.in", "lnkurl.com", "lru.jp", "lt.tl", "lurl.no", "macte.ch", "mash.to", "merky.de", "migre.me", "miniurl.com",
- "minurl.fr", "mke.me", "moby.to", "moourl.com", "mrte.ch", "myloc.me", "myurl.in", "n.pr", "nbc.co", "nblo.gs", "nn.nf", "not.my", "notlong.com", "nsfw.in",
- "nutshellurl.com", "nxy.in", "nyti.ms", "o-x.fr", "oc1.us", "om.ly", "omf.gd", "omoikane.net", "on.cnn.com", "on.mktw.net", "onforb.es", "orz.se", "ow.ly", "ping.fm",
- "pli.gs", "pnt.me", "politi.co", "post.ly", "pp.gg", "profile.to", "ptiturl.com", "pub.vitrue.com", "qlnk.net", "qte.me", "qu.tc", "qy.fi", "r.ebay.com", "r.im", "rb6.me", "read.bi",
- "readthis.ca", "reallytinyurl.com", "redir.ec", "redirects.ca", "redirx.com", "retwt.me", "ri.ms", "rickroll.it", "riz.gd", "rt.nu", "ru.ly", "rubyurl.com", "rurl.org",
- "rww.tw", "s4c.in", "s7y.us", "safe.mn", "sameurl.com", "sdut.us", "shar.es", "shink.de", "shorl.com", "short.ie", "short.to", "shortlinks.co.uk", "shorturl.com",
- "shout.to", "show.my", "shrinkify.com", "shrinkr.com", "shrt.fr", "shrt.st", "shrten.com", "shrunkin.com", "simurl.com", "slate.me", "smallr.com", "smsh.me", "smurl.name",
- "sn.im", "snipr.com", "snipurl.com", "snurl.com", "sp2.ro", "spedr.com", "srnk.net", "srs.li", "starturl.com", "stks.co", "su.pr", "surl.co.uk", "surl.hu", "t.cn", "t.co", "t.lh.com",
- "ta.gd", "tbd.ly", "tcrn.ch", "tgr.me", "tgr.ph", "tighturl.com", "tiniuri.com", "tiny.cc", "tiny.ly", "tiny.pl", "tinylink.in", "tinyuri.ca", "tinyurl.com", "tk.", "tl.gd",
- "tmi.me", "tnij.org", "tnw.to", "tny.com", "to.ly", "togoto.us", "totc.us", "toysr.us", "tpm.ly", "tr.im", "tra.kz", "trunc.it", "twhub.com", "twirl.at",
- "twitclicks.com", "twitterurl.net", "twitterurl.org", "twiturl.de", "twurl.cc", "twurl.nl", "u.mavrev.com", "u.nu", "u76.org", "ub0.cc", "ulu.lu", "updating.me", "ur1.ca",
- "url.az", "url.co.uk", "url.ie", "url360.me", "url4.eu", "urlborg.com", "urlbrief.com", "urlcover.com", "urlcut.com", "urlenco.de", "urli.nl", "urls.im",
- "urlshorteningservicefortwitter.com", "urlx.ie", "urlzen.com", "usat.ly", "use.my", "vb.ly", "vevo.ly", "vgn.am", "vl.am", "vm.lc", "w55.de", "wapo.st", "wapurl.co.uk", "wipi.es",
- "wp.me", "x.vu", "xr.com", "xrl.in", "xrl.us", "xurl.es", "xurl.jp", "y.ahoo.it", "yatuc.com", "ye.pe", "yep.it", "yfrog.com", "yhoo.it", "yiyd.com", "youtu.be", "yuarel.com",
- "z0p.de", "zi.ma", "zi.mu", "zipmyurl.com", "zud.me", "zurl.ws", "zz.gd", "zzang.kr", "›.ws", "✩.ws", "✿.ws", "❥.ws", "➔.ws", "➞.ws", "➡.ws", "➨.ws", "➯.ws", "➹.ws", "➽.ws"
- ];
+ $.fn.oembed = function (url, options, embedAction) {
- if($('#jqoembeddata').length === 0) $('').appendTo('body');
+ settings = $.extend(true, $.fn.oembed.defaults, options);
+ var shortURLList = ["0rz.tw", "1link.in", "1url.com", "2.gp", "2big.at", "2tu.us", "3.ly", "307.to", "4ms.me", "4sq.com", "4url.cc", "6url.com", "7.ly", "a.gg", "a.nf", "aa.cx", "abcurl.net",
+ "ad.vu", "adf.ly", "adjix.com", "afx.cc", "all.fuseurl.com", "alturl.com", "amzn.to", "ar.gy", "arst.ch", "atu.ca", "azc.cc", "b23.ru", "b2l.me", "bacn.me", "bcool.bz", "binged.it",
+ "bit.ly", "bizj.us", "bloat.me", "bravo.ly", "bsa.ly", "budurl.com", "canurl.com", "chilp.it", "chzb.gr", "cl.lk", "cl.ly", "clck.ru", "cli.gs", "cliccami.info",
+ "clickthru.ca", "clop.in", "conta.cc", "cort.as", "cot.ag", "crks.me", "ctvr.us", "cutt.us", "dai.ly", "decenturl.com", "dfl8.me", "digbig.com",
+ "http:\/\/digg\.com\/[^\/]+$", "disq.us", "dld.bz", "dlvr.it", "do.my", "doiop.com", "dopen.us", "easyuri.com", "easyurl.net", "eepurl.com", "eweri.com",
+ "fa.by", "fav.me", "fb.me", "fbshare.me", "ff.im", "fff.to", "fire.to", "firsturl.de", "firsturl.net", "flic.kr", "flq.us", "fly2.ws", "fon.gs", "freak.to",
+ "fuseurl.com", "fuzzy.to", "fwd4.me", "fwib.net", "g.ro.lt", "gizmo.do", "gl.am", "go.9nl.com", "go.ign.com", "go.usa.gov", "goo.gl", "goshrink.com", "gurl.es",
+ "hex.io", "hiderefer.com", "hmm.ph", "href.in", "hsblinks.com", "htxt.it", "huff.to", "hulu.com", "hurl.me", "hurl.ws", "icanhaz.com", "idek.net", "ilix.in", "is.gd",
+ "its.my", "ix.lt", "j.mp", "jijr.com", "kl.am", "klck.me", "korta.nu", "krunchd.com", "l9k.net", "lat.ms", "liip.to", "liltext.com", "linkbee.com", "linkbun.ch",
+ "liurl.cn", "ln-s.net", "ln-s.ru", "lnk.gd", "lnk.ms", "lnkd.in", "lnkurl.com", "lru.jp", "lt.tl", "lurl.no", "macte.ch", "mash.to", "merky.de", "migre.me", "miniurl.com",
+ "minurl.fr", "mke.me", "moby.to", "moourl.com", "mrte.ch", "myloc.me", "myurl.in", "n.pr", "nbc.co", "nblo.gs", "nn.nf", "not.my", "notlong.com", "nsfw.in",
+ "nutshellurl.com", "nxy.in", "nyti.ms", "o-x.fr", "oc1.us", "om.ly", "omf.gd", "omoikane.net", "on.cnn.com", "on.mktw.net", "onforb.es", "orz.se", "ow.ly", "ping.fm",
+ "pli.gs", "pnt.me", "politi.co", "post.ly", "pp.gg", "profile.to", "ptiturl.com", "pub.vitrue.com", "qlnk.net", "qte.me", "qu.tc", "qy.fi", "r.ebay.com", "r.im", "rb6.me", "read.bi",
+ "readthis.ca", "reallytinyurl.com", "redir.ec", "redirects.ca", "redirx.com", "retwt.me", "ri.ms", "rickroll.it", "riz.gd", "rt.nu", "ru.ly", "rubyurl.com", "rurl.org",
+ "rww.tw", "s4c.in", "s7y.us", "safe.mn", "sameurl.com", "sdut.us", "shar.es", "shink.de", "shorl.com", "short.ie", "short.to", "shortlinks.co.uk", "shorturl.com",
+ "shout.to", "show.my", "shrinkify.com", "shrinkr.com", "shrt.fr", "shrt.st", "shrten.com", "shrunkin.com", "simurl.com", "slate.me", "smallr.com", "smsh.me", "smurl.name",
+ "sn.im", "snipr.com", "snipurl.com", "snurl.com", "sp2.ro", "spedr.com", "srnk.net", "srs.li", "starturl.com", "stks.co", "su.pr", "surl.co.uk", "surl.hu", "t.cn", "t.co", "t.lh.com",
+ "ta.gd", "tbd.ly", "tcrn.ch", "tgr.me", "tgr.ph", "tighturl.com", "tiniuri.com", "tiny.cc", "tiny.ly", "tiny.pl", "tinylink.in", "tinyuri.ca", "tinyurl.com", "tk.", "tl.gd",
+ "tmi.me", "tnij.org", "tnw.to", "tny.com", "to.ly", "togoto.us", "totc.us", "toysr.us", "tpm.ly", "tr.im", "tra.kz", "trunc.it", "twhub.com", "twirl.at",
+ "twitclicks.com", "twitterurl.net", "twitterurl.org", "twiturl.de", "twurl.cc", "twurl.nl", "u.mavrev.com", "u.nu", "u76.org", "ub0.cc", "ulu.lu", "updating.me", "ur1.ca",
+ "url.az", "url.co.uk", "url.ie", "url360.me", "url4.eu", "urlborg.com", "urlbrief.com", "urlcover.com", "urlcut.com", "urlenco.de", "urli.nl", "urls.im",
+ "urlshorteningservicefortwitter.com", "urlx.ie", "urlzen.com", "usat.ly", "use.my", "vb.ly", "vevo.ly", "vgn.am", "vl.am", "vm.lc", "w55.de", "wapo.st", "wapurl.co.uk", "wipi.es",
+ "wp.me", "x.vu", "xr.com", "xrl.in", "xrl.us", "xurl.es", "xurl.jp", "y.ahoo.it", "yatuc.com", "ye.pe", "yep.it", "yfrog.com", "yhoo.it", "yiyd.com", "youtu.be", "yuarel.com",
+ "z0p.de", "zi.ma", "zi.mu", "zipmyurl.com", "zud.me", "zurl.ws", "zz.gd", "zzang.kr", "›.ws", "✩.ws", "✿.ws", "❥.ws", "➔.ws", "➞.ws", "➡.ws", "➨.ws", "➯.ws", "➹.ws", "➽.ws"];
- return this.each(function () {
- var container = $(this),
- resourceURL = (url && (!url.indexOf('http://') || !url.indexOf('https://'))) ? url : container.attr("href"),
- provider;
+ if ($('#jqoembeddata').length === 0) $('').appendTo('body');
- if(embedAction) {
- settings.onEmbed = embedAction;
- } else if(!settings.onEmbed) {
- settings.onEmbed = function (oembedData) {
- $.fn.oembed.insertCode(this, settings.embedMethod, oembedData);
- };
- }
+ return this.each(function () {
+ var container = $(this),
+ resourceURL = (url && (!url.indexOf('http://') || !url.indexOf('https://'))) ? url : container.attr("href"),
+ provider;
- if(resourceURL !== null && resourceURL !== undefined) {
- //Check if shorten URL
- for(var j = 0, l = shortURLList.length; j < l; j++) {
- var regExp = new RegExp('://' + shortURLList[j] + '/', "i");
- if(resourceURL.match(regExp) !== null) {
- //AJAX to http://api.longurl.org/v2/expand?url=http://bit.ly/JATvIs&format=json&callback=hhh
- var ajaxopts = $.extend({
- url: "http://api.longurl.org/v2/expand",
- dataType: 'jsonp',
- data: {
- url: resourceURL,
- format: "json"
- //callback: "?"
- },
- success: function (data) {
- //this = $.fn.oembed;
- resourceURL = data['long-url'];
- provider = $.fn.oembed.getOEmbedProvider(data['long-url']);
+ if (embedAction) {
+ settings.onEmbed = embedAction;
+ }
+ else if (!settings.onEmbed) {
+ settings.onEmbed = function (oembedData) {
+ $.fn.oembed.insertCode(this, settings.embedMethod, oembedData);
+ };
+ }
- if(provider !== null) {
- provider.params = getNormalizedParams(settings[provider.name]) || {};
- provider.maxWidth = settings.maxWidth;
- provider.maxHeight = settings.maxHeight;
- embedCode(container, resourceURL, provider);
- } else {
- settings.onProviderNotFound.call(container, resourceURL);
- }
- }
- }, settings.ajaxOptions || {});
+ if (resourceURL !== null && resourceURL !== undefined) {
+ //Check if shorten URL
+ for (var j = 0, l = shortURLList.length; j < l; j++) {
+ var regExp = new RegExp('://' + shortURLList[j] + '/', "i");
+
+ provider = $.fn.oembed.getOEmbedProvider(resourceURL);
- $.ajax(ajaxopts);
+ if (!provider && window.location.protocol !== "https:" && resourceURL.match(regExp) !== null) {
+ //AJAX to http://api.longurl.org/v2/expand?url=http://bit.ly/JATvIs&format=json&callback=hhh
+ var ajaxopts = $.extend({
+ url: "http://api.longurl.org/v2/expand",
+ dataType: 'jsonp',
+ data: {
+ url: resourceURL,
+ format: "json"
+ //callback: "?"
+ },
+ success: function (data) {
+ //this = $.fn.oembed;
+ resourceURL = data['long-url'];
+ provider = $.fn.oembed.getOEmbedProvider(data['long-url']);
- return container;
- }
- }
- provider = $.fn.oembed.getOEmbedProvider(resourceURL);
+ //remove fallback
+ if (!!settings.fallback === false) {
+ provider = provider.name.toLowerCase() === 'opengraph' ? null : provider;
+ }
- if(provider !== null) {
- provider.params = getNormalizedParams(settings[provider.name]) || {};
- provider.maxWidth = settings.maxWidth;
- provider.maxHeight = settings.maxHeight;
- embedCode(container, resourceURL, provider);
- } else {
- settings.onProviderNotFound.call(container, resourceURL);
- }
- }
+ if (provider !== null) {
+ provider.params = getNormalizedParams(settings[provider.name]) || {};
+ provider.maxWidth = settings.maxWidth;
+ provider.maxHeight = settings.maxHeight;
+ embedCode(container, resourceURL, provider);
+ } else {
+ settings.onProviderNotFound.call(container, resourceURL);
+ }
+ },
+ error: function () {
+ settings.onError.call(container, resourceURL)
+ }
+ }, settings.longUrlAjaxOptions || settings.ajaxOptions || {});
- return container;
- });
+ $.ajax(ajaxopts);
+
+ return container;
+ }
+ }
+
+ //remove fallback
+ if (!!settings.fallback === false) {
+ provider = provider.name.toLowerCase() === 'opengraph' ? null : provider;
+ }
+ if (provider !== null) {
+ provider.params = getNormalizedParams(settings[provider.name]) || {};
+ provider.maxWidth = settings.maxWidth;
+ provider.maxHeight = settings.maxHeight;
+ embedCode(container, resourceURL, provider);
+ } else {
+ settings.onProviderNotFound.call(container, resourceURL);
+ }
+ }
+ return container;
+ });
+ };
+
+ var settings;
+
+ // Plugin defaults
+ $.fn.oembed.defaults = {
+ fallback: true,
+ maxWidth: null,
+ maxHeight: null,
+ includeHandle: true,
+ embedMethod: 'auto',
+ // "auto", "append", "fill"
+ onProviderNotFound: function () {
+ },
+ beforeEmbed: function () {
+ },
+ afterEmbed: function () {
+ },
+ onEmbed: false,
+ onError: function (a, b, c, d) {
+ console.log('err:', a, b, c, d)
+ },
+ ajaxOptions: {},
+ longUrlAjaxOptions: {}
+ };
+
+ /* Private functions */
+ function rand(length, current) { //Found on http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript
+ current = current ? current : '';
+ return length ? rand(--length, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz".charAt(Math.floor(Math.random() * 60)) + current) : current;
+ }
+
+ function getRequestUrl(provider, externalUrl) {
+ var url = provider.apiendpoint,
+ qs = "",
+ i;
+ url += (url.indexOf("?") <= 0) ? "?" : "&";
+ url = url.replace('#', '%23');
+
+ if (provider.maxWidth !== null && (typeof provider.params.maxwidth === 'undefined' || provider.params.maxwidth === null)) {
+ provider.params.maxwidth = provider.maxWidth;
+ }
+
+ if (provider.maxHeight !== null && (typeof provider.params.maxheight === 'undefined' || provider.params.maxheight === null)) {
+ provider.params.maxheight = provider.maxHeight;
+ }
+
+ for (i in provider.params) {
+ // We don't want them to jack everything up by changing the callback parameter
+ if (i == provider.callbackparameter)
+ continue;
+
+ // allows the options to be set to null, don't send null values to the server as parameters
+ if (provider.params[i] !== null)
+ qs += "&" + escape(i) + "=" + provider.params[i];
+ }
+
+ url += "format=" + provider.format + "&url=" + escape(externalUrl) + qs;
+ if (provider.dataType != 'json')
+ url += "&" + provider.callbackparameter + "=?";
+
+ return url;
+ }
+
+ function success(oembedData, externalUrl, container) {
+ $('#jqoembeddata').data(externalUrl, oembedData.code);
+ settings.beforeEmbed.call(container, oembedData);
+ settings.onEmbed.call(container, oembedData);
+ settings.afterEmbed.call(container, oembedData);
+ }
+
+ function embedCode(container, externalUrl, embedProvider) {
+ if ($('#jqoembeddata').data(externalUrl) != undefined && embedProvider.embedtag.tag != 'iframe') {
+ var oembedData = {code: $('#jqoembeddata').data(externalUrl)};
+ success(oembedData, externalUrl, container);
+ } else if (embedProvider.yql) {
+ var from = embedProvider.yql.from || 'htmlstring';
+ var url = embedProvider.yql.url ? embedProvider.yql.url(externalUrl) : externalUrl;
+ var query = 'SELECT * FROM ' + from
+ + ' WHERE url="' + (url) + '"'
+ + " and " + (/html/.test(from) ? 'xpath' : 'itemPath') + "='" + (embedProvider.yql.xpath || '/') + "'";
+ if (from == 'html')
+ query += " and compat='html5'";
+ var ajaxopts = $.extend({
+ url: "//query.yahooapis.com/v1/public/yql",
+ dataType: 'jsonp',
+ data: {
+ q: query,
+ format: "json",
+ env: 'store://datatables.org/alltableswithkeys',
+ callback: "?"
+ },
+ success: function (data) {
+ var result;
+
+ if (embedProvider.yql.xpath && embedProvider.yql.xpath == '//meta|//title|//link') {
+ var meta = {};
+
+ if (data.query == null) {
+ data.query = {};
+ }
+ if (data.query.results == null) {
+ data.query.results = {"meta": []};
+ }
+ for (var i = 0, l = data.query.results.meta.length; i < l; i++) {
+ var name = data.query.results.meta[i].name || data.query.results.meta[i].property || null;
+ if (name == null)continue;
+ meta[name.toLowerCase()] = data.query.results.meta[i].content;
+ }
+ if (!meta.hasOwnProperty("title") || !meta.hasOwnProperty("og:title")) {
+ if (data.query.results.title != null) {
+ meta.title = data.query.results.title;
+ }
+ }
+ if (!meta.hasOwnProperty("og:image") && data.query.results.hasOwnProperty("link")) {
+ for (var i = 0, l = data.query.results.link.length; i < l; i++) {
+ if (data.query.results.link[i].hasOwnProperty("rel")) {
+ if (data.query.results.link[i].rel == "apple-touch-icon") {
+ if (data.query.results.link[i].href.charAt(0) == "/") {
+ meta["og:image"] = url.match(/^(([a-z]+:)?(\/\/)?[^\/]+\/).*$/)[1] + data.query.results.link[i].href;
+ } else {
+ meta["og:image"] = data.query.results.link[i].href;
+ }
+ }
+ }
+ }
+ }
+ result = embedProvider.yql.datareturn(meta);
+ } else {
+ result = embedProvider.yql.datareturn ? embedProvider.yql.datareturn(data.query.results) : data.query.results.result;
+ }
+ if (result === false)return;
+ var oembedData = $.extend({}, result);
+ oembedData.code = result;
+ success(oembedData, externalUrl, container);
+ },
+ error: settings.onError.call(container, externalUrl, embedProvider)
+ }, settings.ajaxOptions || {});
+ $.ajax(ajaxopts);
+ } else if (embedProvider.templateRegex) {
+ if (embedProvider.embedtag.tag !== '') {
+ var flashvars = embedProvider.embedtag.flashvars || '';
+ var tag = embedProvider.embedtag.tag || 'embed';
+ var width = embedProvider.embedtag.width || 'auto';
+ var height = embedProvider.embedtag.height || 'auto';
+ var src = externalUrl.replace(embedProvider.templateRegex, embedProvider.apiendpoint);
+
+ if (!embedProvider.nocache) {
+ src += '&jqoemcache=' + rand(5);
+ }
+
+ if (embedProvider.apikey) {
+ src = src.replace('_APIKEY_', settings.apikeys[embedProvider.name]);
+ }
+
+ var code = $('<' + tag + '/>').attr('src', src).attr('width', width)
+ .attr('height', height)
+ .attr('allowfullscreen', embedProvider.embedtag.allowfullscreen || 'true')
+ .attr('allowscriptaccess', embedProvider.embedtag.allowfullscreen || 'always')
+ .css('max-height', settings.maxHeight || 'auto')
+ .css('max-width', settings.maxWidth || 'auto');
+
+ if (tag == 'embed') {
+ code.attr('type', embedProvider.embedtag.type || "application/x-shockwave-flash")
+ .attr('flashvars', externalUrl.replace(embedProvider.templateRegex, flashvars));
+ }
+
+ if (tag == 'iframe') {
+ code.attr('scrolling', embedProvider.embedtag.scrolling || "no")
+ .attr('frameborder', embedProvider.embedtag.frameborder || "0");
+
+ }
+
+ success({code: code}, externalUrl, container);
+ } else if (embedProvider.apiendpoint) {
+ //Add APIkey if true
+ if (embedProvider.apikey)
+ embedProvider.apiendpoint = embedProvider.apiendpoint.replace('_APIKEY_', settings.apikeys[embedProvider.name]);
+
+ ajaxopts = $.extend({
+ url: externalUrl.replace(embedProvider.templateRegex, embedProvider.apiendpoint),
+ dataType: 'jsonp',
+ success: function (data) {
+ var oembedData = $.extend({}, data);
+ oembedData.code = embedProvider.templateData(data);
+ success(oembedData, externalUrl, container);
+ },
+ error: settings.onError.call(container, externalUrl, embedProvider)
+ }, settings.ajaxOptions || {});
+ $.ajax(ajaxopts);
+ } else {
+ success({code: externalUrl.replace(embedProvider.templateRegex, embedProvider.template)}, externalUrl, container);
+ }
+ } else {
+
+ var requestUrl = getRequestUrl(embedProvider, externalUrl);
+ ajaxopts = $.extend({
+ url: requestUrl,
+ dataType: embedProvider.dataType || 'jsonp',
+ success: function (data) {
+ var oembedData = $.extend({}, data);
+ switch (oembedData.type) {
+ case "file": //Deviant Art has this
+ case "photo":
+ oembedData.code = $.fn.oembed.getPhotoCode(externalUrl, oembedData);
+ break;
+ case "video":
+ case "rich":
+ oembedData.code = $.fn.oembed.getRichCode(externalUrl, oembedData);
+ break;
+ default:
+ oembedData.code = $.fn.oembed.getGenericCode(externalUrl, oembedData);
+ break;
+ }
+ success(oembedData, externalUrl, container);
+ },
+ error: settings.onError.call(container, externalUrl, embedProvider)
+ }, settings.ajaxOptions || {});
+ $.ajax(ajaxopts);
+ }
+ }
+
+ function getNormalizedParams(params) {
+ if (params === null) return null;
+ var key, normalizedParams = {};
+ for (key in params) {
+ if (key !== null) normalizedParams[key.toLowerCase()] = params[key];
+ }
+ return normalizedParams;
+ }
+
+ /* Public functions */
+ $.fn.oembed.insertCode = function (container, embedMethod, oembedData) {
+ if (oembedData === null)
+ return;
+
+ if (embedMethod === 'auto' && container.attr('href') !== null) {
+ embedMethod = 'append';
+ } else if (embedMethod == 'auto') {
+ embedMethod = 'replace';
+ }
+
+ switch (embedMethod) {
+ case "replace":
+ container.replaceWith(oembedData.code);
+ break;
+ case "fill":
+ container.html(oembedData.code);
+ break;
+ case "append":
+ container.wrap('
');
+ var oembedContainer = container.parent();
+ if (settings.includeHandle) {
+ $('↓').insertBefore(container).click(function () {
+ var encodedString = encodeURIComponent($(this).text());
+ $(this).html((encodedString == '%E2%86%91') ? '↓' : '↑');
+ $(this).parent().children().last().toggle();
+ });
+ }
+ oembedContainer.append('
');
+ try {
+ oembedData.code.clone().appendTo(oembedContainer);
+ } catch (e) {
+ oembedContainer.append(oembedData.code);
+ }
+ /* Make videos semi-responsive
+ * If parent div width less than embeded iframe video then iframe gets shrunk to fit smaller width
+ * If parent div width greater thans embed iframe use the max widht
+ * - works on youtubes and vimeo
+ */
+ if (settings.maxWidth) {
+ var post_width = oembedContainer.parent().width();
+ if (post_width < settings.maxWidth) {
+ var iframe_width_orig = $('iframe', oembedContainer).width();
+ var iframe_height_orig = $('iframe', oembedContainer).height();
+ var ratio = iframe_width_orig / post_width;
+ $('iframe', oembedContainer).width(iframe_width_orig / ratio);
+ $('iframe', oembedContainer).height(iframe_height_orig / ratio);
+ } else {
+ if (settings.maxWidth) {
+ $('iframe', oembedContainer).width(settings.maxWidth);
+ }
+ if (settings.maxHeight) {
+ $('iframe', oembedContainer).height(settings.maxHeight);
+ }
+ }
+ }
+ break;
+ }
+ };
+
+ $.fn.oembed.getPhotoCode = function (url, oembedData) {
+ var code;
+ var alt = oembedData.title ? oembedData.title : '';
+ alt += oembedData.author_name ? ' - ' + oembedData.author_name : '';
+ alt += oembedData.provider_name ? ' - ' + oembedData.provider_name : '';
+
+ if (oembedData.url) {
+ code = '';
+ } else if (oembedData.thumbnail_url) {
+ var newURL = oembedData.thumbnail_url.replace('_s', '_b');
+ code = '';
+ } else {
+ code = 'Error loading this picture
';
+ }
+
+ if (oembedData.html) {
+ code += "" + oembedData.html + "
";
+ }
+
+ return code;
+ };
+
+ $.fn.oembed.getRichCode = function (url, oembedData) {
+ return oembedData.html;
+ };
+
+ $.fn.oembed.getGenericCode = function (url, oembedData) {
+ var title = ((oembedData.title) && (oembedData.title !== null)) ? oembedData.title : url;
+ var code = '' + title + '';
+
+ if (oembedData.html) {
+ code += "" + oembedData.html + "
";
+ }
+
+ return code;
+ };
+
+ $.fn.oembed.getOEmbedProvider = function (url) {
+ for (var i = 0; i < $.fn.oembed.providers.length; i++) {
+ for (var j = 0, l = $.fn.oembed.providers[i].urlschemes.length; j < l; j++) {
+ var regExp = new RegExp($.fn.oembed.providers[i].urlschemes[j], "i");
+
+ if (url.match(regExp) !== null)
+ return $.fn.oembed.providers[i];
+ }
+ }
+ return null;
+ };
+
+ // Constructor Function for OEmbedProvider Class.
+ $.fn.oembed.OEmbedProvider = function (name, type, urlschemesarray, apiendpoint, extraSettings) {
+ this.name = name;
+ this.type = type; // "photo", "video", "link", "rich", null
+ this.urlschemes = urlschemesarray;
+ this.apiendpoint = apiendpoint;
+ this.maxWidth = 500;
+ this.maxHeight = 400;
+ extraSettings = extraSettings || {};
+
+ if (extraSettings.useYQL) {
+
+ if (extraSettings.useYQL == 'xml') {
+ extraSettings.yql = {
+ xpath: "//oembed/html",
+ from: 'xml',
+ apiendpoint: this.apiendpoint,
+ url: function (externalurl) {
+ return this.apiendpoint + '?format=xml&url=' + externalurl
+ },
+ datareturn: function (results) {
+ return results.html.replace(/.*\[CDATA\[(.*)\]\]>$/, '$1') || ''
+ }
+ };
+ } else {
+ extraSettings.yql = {
+ from: 'json',
+ apiendpoint: this.apiendpoint,
+ url: function (externalurl) {
+ return this.apiendpoint + '?format=json&url=' + externalurl
+ },
+ datareturn: function (results) {
+ if (results.json.type != 'video' && (results.json.url || results.json.thumbnail_url)) {
+ return '
';
+ }
+ return results.json.html || ''
+ }
+ };
+ }
+ this.apiendpoint = null;
+ }
- };
+ for (var property in extraSettings) {
+ this[property] = extraSettings[property];
+ }
- var settings;
+ this.format = this.format || 'json';
+ this.callbackparameter = this.callbackparameter || "callback";
+ this.embedtag = this.embedtag || {tag: ""};
- // Plugin defaults
- $.fn.oembed.defaults = {
- maxWidth: null,
- maxHeight: null,
- includeHandle: true,
- embedMethod: 'auto',
- // "auto", "append", "fill"
- onProviderNotFound: function () {},
- beforeEmbed: function () {},
- afterEmbed: function () {},
- onEmbed: false,
- onError: function () {},
- ajaxOptions: {}
- };
- /* Private functions */
- function rand(length, current) { //Found on http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript
- current = current ? current : '';
- return length ? rand(--length, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz".charAt(Math.floor(Math.random() * 60)) + current) : current;
- }
+ };
- function getRequestUrl(provider, externalUrl) {
- var url = provider.apiendpoint,
- qs = "",
- i;
- url += (url.indexOf("?") <= 0) ? "?" : "&";
- url = url.replace('#', '%23');
+ /*
+ * Function to update existing providers
+ *
+ * @param {String} name The name of the provider
+ * @param {String} type The type of the provider can be "file", "photo", "video", "rich"
+ * @param {String} urlshemesarray Array of url of the provider
+ * @param {String} apiendpoint The endpoint of the provider
+ * @param {String} extraSettings Extra settings of the provider
+ */
+ $.fn.updateOEmbedProvider = function (name, type, urlschemesarray, apiendpoint, extraSettings) {
+ for (var i = 0; i < $.fn.oembed.providers.length; i++) {
+ if ($.fn.oembed.providers[i].name === name) {
+ if (type !== null) {
+ $.fn.oembed.providers[i].type = type;
+ }
+ if (urlschemesarray !== null) {
+ $.fn.oembed.providers[i].urlschemes = urlschemesarray;
+ }
+ if (apiendpoint !== null) {
+ $.fn.oembed.providers[i].apiendpoint = apiendpoint;
+ }
+ if (extraSettings !== null) {
+ $.fn.oembed.providers[i].extraSettings = extraSettings;
+ for (var property in extraSettings) {
+ if (property !== null && extraSettings[property] !== null) {
+ $.fn.oembed.providers[i][property] = extraSettings[property];
+ }
+ }
+ }
+ }
+ }
+ };
- if(provider.maxWidth !== null && (typeof provider.params.maxwidth === 'undefined' || provider.params.maxwidth === null)) {
- provider.params.maxwidth = provider.maxWidth;
- }
+ /* Native & common providers */
+ $.fn.oembed.providers = [
- if(provider.maxHeight !== null && (typeof provider.params.maxheight === 'undefined' || provider.params.maxheight === null)) {
- provider.params.maxheight = provider.maxHeight;
- }
+ //Video
+ new $.fn.oembed.OEmbedProvider("youtube", "video", ["youtube\\.com/watch.+v=[\\w-]+&?", "youtu\\.be/[\\w-]+", "youtube.com/embed"], '//www.youtube.com/embed/$1?wmode=transparent', {
+ templateRegex: /.*(?:v\=|be\/|embed\/)([\w\-]+)&?.*/, embedtag: {tag: 'iframe', width: '425', height: '349'}
+ }),
- for(i in provider.params) {
- // We don't want them to jack everything up by changing the callback parameter
- if(i == provider.callbackparameter) continue;
+ //new $.fn.oembed.OEmbedProvider("youtube", "video", ["youtube\\.com/watch.+v=[\\w-]+&?", "youtu\\.be/[\\w-]+"], 'http://www.youtube.com/oembed', {useYQL:'json'}),
+ //new $.fn.oembed.OEmbedProvider("youtubeiframe", "video", ["youtube.com/embed"], "$1?wmode=transparent",
+ // {templateRegex:/(.*)/,embedtag : {tag: 'iframe', width:'425',height: '349'}}),
+ new $.fn.oembed.OEmbedProvider("wistia", "video", ["wistia.com/medias/.+", "wistia.com/m/.+", "wistia.com/embed/.+", "wi.st/m/.+", "wi.st/embed/.+"], 'http://fast.wistia.com/oembed', {useYQL: 'json'}),
+ new $.fn.oembed.OEmbedProvider("xtranormal", "video", ["xtranormal\\.com/watch/.+"], "http://www.xtranormal.com/xtraplayr/$1/$2", {
+ templateRegex: /.*com\/watch\/([\w\-]+)\/([\w\-]+).*/, embedtag: {tag: 'iframe', width: '320', height: '269'}}),
+ new $.fn.oembed.OEmbedProvider("scivee", "video", ["scivee.tv/node/.+"], "http://www.scivee.tv/flash/embedCast.swf?", {
+ templateRegex: /.*tv\/node\/(.+)/, embedtag: {width: '480', height: '400', flashvars: "id=$1&type=3"}}),
+ new $.fn.oembed.OEmbedProvider("veoh", "video", ["veoh.com/watch/.+"], "http://www.veoh.com/swf/webplayer/WebPlayer.swf?version=AFrontend.5.7.0.1337&permalinkId=$1&player=videodetailsembedded&videoAutoPlay=0&id=anonymous", {
+ templateRegex: /.*watch\/([^\?]+).*/, embedtag: {width: '410', height: '341'}}),
+ new $.fn.oembed.OEmbedProvider("gametrailers", "video", ["gametrailers\\.com/video/.+"], "http://media.mtvnservices.com/mgid:moses:video:gametrailers.com:$2", {
+ templateRegex: /.*com\/video\/([\w\-]+)\/([\w\-]+).*/, embedtag: {width: '512', height: '288' }}),
+ new $.fn.oembed.OEmbedProvider("funnyordie", "video", ["funnyordie\\.com/videos/.+"], "http://player.ordienetworks.com/flash/fodplayer.swf?", {
+ templateRegex: /.*videos\/([^\/]+)\/([^\/]+)?/, embedtag: {width: 512, height: 328, flashvars: "key=$1"}}),
+ new $.fn.oembed.OEmbedProvider("colledgehumour", "video", ["collegehumor\\.com/video/.+"], "http://www.collegehumor.com/moogaloop/moogaloop.swf?clip_id=$1&use_node_id=true&fullscreen=1",
+ {templateRegex: /.*video\/([^\/]+).*/, embedtag: {width: 600, height: 338}}),
+ new $.fn.oembed.OEmbedProvider("metacafe", "video", ["metacafe\\.com/watch/.+"], "http://www.metacafe.com/fplayer/$1/$2.swf",
+ {templateRegex: /.*watch\/(\d+)\/(\w+)\/.*/, embedtag: {width: 400, height: 345}}),
+ new $.fn.oembed.OEmbedProvider("bambuser", "video", ["bambuser\\.com\/channel\/.*\/broadcast\/.*"], "http://static.bambuser.com/r/player.swf?vid=$1",
+ {templateRegex: /.*bambuser\.com\/channel\/.*\/broadcast\/(\w+).*/, embedtag: {width: 512, height: 339 }}),
+ new $.fn.oembed.OEmbedProvider("twitvid", "video", ["twitvid\\.com/.+"], "http://www.twitvid.com/embed.php?guid=$1&autoplay=0",
+ {templateRegex: /.*twitvid\.com\/(\w+).*/, embedtag: {tag: 'iframe', width: 480, height: 360 }}),
+ new $.fn.oembed.OEmbedProvider("aniboom", "video", ["aniboom\\.com/animation-video/.+"], "http://api.aniboom.com/e/$1",
+ {templateRegex: /.*animation-video\/(\d+).*/, embedtag: {width: 594, height: 334}}),
+ new $.fn.oembed.OEmbedProvider("vzaar", "video", ["vzaar\\.com/videos/.+", "vzaar.tv/.+"], "http://view.vzaar.com/$1/player?",
+ {templateRegex: /.*\/(\d+).*/, embedtag: {tag: 'iframe', width: 576, height: 324 }}),
+ new $.fn.oembed.OEmbedProvider("snotr", "video", ["snotr\\.com/video/.+"], "http://www.snotr.com/embed/$1",
+ {templateRegex: /.*\/(\d+).*/, embedtag: {tag: 'iframe', width: 400, height: 330}, nocache: 1 }),
+ new $.fn.oembed.OEmbedProvider("youku", "video", ["v.youku.com/v_show/id_.+"], "http://player.youku.com/player.php/sid/$1/v.swf",
+ {templateRegex: /.*id_(.+)\.html.*/, embedtag: {width: 480, height: 400}, nocache: 1 }),
+ new $.fn.oembed.OEmbedProvider("tudou", "video", ["tudou.com/programs/view/.+\/"], "http://www.tudou.com/v/$1/v.swf",
+ {templateRegex: /.*view\/(.+)\//, embedtag: {width: 480, height: 400}, nocache: 1 }),
+ new $.fn.oembed.OEmbedProvider("embedr", "video", ["embedr\\.com/playlist/.+"], "http://embedr.com/swf/slider/$1/425/520/default/false/std?",
+ {templateRegex: /.*playlist\/([^\/]+).*/, embedtag: {width: 425, height: 520}}),
+ new $.fn.oembed.OEmbedProvider("blip", "video", ["blip\\.tv/.+"], "//blip.tv/oembed/"),
+ new $.fn.oembed.OEmbedProvider("minoto-video", "video", ["http://api.minoto-video.com/publishers/.+/videos/.+", "http://dashboard.minoto-video.com/main/video/details/.+", "http://embed.minoto-video.com/.+"], "http://api.minoto-video.com/services/oembed.json", {useYQL: 'json'}),
+ new $.fn.oembed.OEmbedProvider("animoto", "video", ["animoto.com/play/.+"], "http://animoto.com/services/oembed"),
+ new $.fn.oembed.OEmbedProvider("hulu", "video", ["hulu\\.com/watch/.*"], "//www.hulu.com/api/oembed.json"),
+ new $.fn.oembed.OEmbedProvider("ustream", "video", ["ustream\\.tv/recorded/.*"], "http://www.ustream.tv/oembed", {useYQL: 'json'}),
+ new $.fn.oembed.OEmbedProvider("videojug", "video", ["videojug\\.com/(film|payer|interview).*"], "http://www.videojug.com/oembed.json", {useYQL: 'json'}),
+ new $.fn.oembed.OEmbedProvider("sapo", "video", ["videos\\.sapo\\.pt/.*"], "http://videos.sapo.pt/oembed", {useYQL: 'json'}),
+ new $.fn.oembed.OEmbedProvider("vodpod", "video", ["vodpod.com/watch/.*"], "http://vodpod.com/oembed.js", {useYQL: 'json'}),
+ new $.fn.oembed.OEmbedProvider("vimeo", "video", ["www\.vimeo\.com\/groups\/.*\/videos\/.*", "www\.vimeo\.com\/.*", "vimeo\.com\/groups\/.*\/videos\/.*", "vimeo\.com\/.*"], "//vimeo.com/api/oembed.json"),
+ new $.fn.oembed.OEmbedProvider("dailymotion", "video", ["dailymotion\\.com/.+"], '//www.dailymotion.com/services/oembed'),
+ new $.fn.oembed.OEmbedProvider("5min", "video", ["www\\.5min\\.com/.+"], 'http://api.5min.com/oembed.xml', {useYQL: 'xml'}),
+ new $.fn.oembed.OEmbedProvider("National Film Board of Canada", "video", ["nfb\\.ca/film/.+"], 'http://www.nfb.ca/remote/services/oembed/', {useYQL: 'json'}),
+ new $.fn.oembed.OEmbedProvider("qik", "video", ["qik\\.com/\\w+"], 'http://qik.com/api/oembed.json', {useYQL: 'json'}),
+ new $.fn.oembed.OEmbedProvider("revision3", "video", ["revision3\\.com"], "http://revision3.com/api/oembed/"),
+ new $.fn.oembed.OEmbedProvider("dotsub", "video", ["dotsub\\.com/view/.+"], "http://dotsub.com/services/oembed", {useYQL: 'json'}),
+ new $.fn.oembed.OEmbedProvider("clikthrough", "video", ["clikthrough\\.com/theater/video/\\d+"], "http://clikthrough.com/services/oembed"),
+ new $.fn.oembed.OEmbedProvider("Kinomap", "video", ["kinomap\\.com/.+"], "http://www.kinomap.com/oembed"),
+ new $.fn.oembed.OEmbedProvider("VHX", "video", ["vhx.tv/.+"], "http://vhx.tv/services/oembed.json"),
+ new $.fn.oembed.OEmbedProvider("bambuser", "video", ["bambuser.com/.+"], "http://api.bambuser.com/oembed/iframe.json"),
+ new $.fn.oembed.OEmbedProvider("justin.tv", "video", ["justin.tv/.+"], 'http://api.justin.tv/api/embed/from_url.json', {useYQL: 'json'}),
+ new $.fn.oembed.OEmbedProvider("vine", "video", ["vine.co/v/.*"], null,
+ {
+ templateRegex: /https?:\/\/w?w?w?.?vine\.co\/v\/([a-zA-Z0-9]*).*/,
+ template: '' +
+ '',
+ nocache: 1
+ }),
+ new $.fn.oembed.OEmbedProvider("boxofficebuz", "video", ["boxofficebuz\\.com\\/embed/.+"], "http://boxofficebuz.com/embed/$1/$2", {templateRegex: [/.*boxofficebuz\.com\/embed\/(\w+)\/([\w*\-*]+)/], embedtag: {tag: 'iframe', width: 480, height: 360 }}),
+ new $.fn.oembed.OEmbedProvider("clipsyndicate", "video", ["clipsyndicate\\.com/video/play/.+", "clipsyndicate\\.com/embed/iframe\?.+"], "http://eplayer.clipsyndicate.com/embed/iframe?pf_id=1&show_title=0&va_id=$1&windows=1", {templateRegex: [/.*www\.clipsyndicate\.com\/video\/play\/(\w+)\/.*/, /.*eplayer\.clipsyndicate\.com\/embed\/iframe\?.*va_id=(\w+).*.*/], embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
+ new $.fn.oembed.OEmbedProvider("coub", "video", ["coub\\.com/.+"], "http://www.coub.com/embed/$1?muted=false&autostart=false&originalSize=false&hideTopBar=false&noSiteButtons=false&startWithHD=false", {templateRegex: [/.*coub\.com\/embed\/(\w+)\?*.*/, /.*coub\.com\/view\/(\w+).*/], embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
+ new $.fn.oembed.OEmbedProvider("discoverychannel", "video", ["snagplayer\\.video\\.dp\\.discovery\\.com/.+"], "http://snagplayer.video.dp.discovery.com/$1/snag-it-player.htm?auto=no", {templateRegex: [/.*snagplayer\.video\.dp\.discovery\/(\w+).*/], embedtag: {tag: 'iframe', width: 480, height: 360 }}),
+ new $.fn.oembed.OEmbedProvider("telly", "video", ["telly\\.com/.+"], "http://www.telly.com/embed.php?guid=$1&autoplay=0", {templateRegex: [/.*telly\.com\/embed\.php\?guid=(\w+).*/, /.*telly\.com\/(\w+).*/], embedtag: {tag: 'iframe', width: 480, height: 360 }}),
+ new $.fn.oembed.OEmbedProvider("minilogs", "video", ["minilogs\\.com/.+"], "http://www.minilogs.com/e/$1", {templateRegex: [/.*minilogs\.com\/e\/(\w+).*/, /.*minilogs\.com\/(\w+).*/], embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
+ new $.fn.oembed.OEmbedProvider("viddy", "video", ["viddy\\.com/.+"], "http://www.viddy.com/embed/video/$1", {templateRegex: [/.*viddy\.com\/embed\/video\/(\.*)/, /.*viddy\.com\/video\/(\.*)/], embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
+ new $.fn.oembed.OEmbedProvider("worldstarhiphop", "video", ["worldstarhiphop\\.com\/embed/.+"], "http://www.worldstarhiphop.com/embed/$1", {templateRegex: /.*worldstarhiphop\.com\/embed\/(\w+).*/, embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
+ new $.fn.oembed.OEmbedProvider("zapiks", "video", ["zapiks\\.fr\/.+"], "http://www.zapiks.fr/index.php?action=playerIframe&media_id=$1&autoStart=fals", {templateRegex: /.*zapiks\.fr\/index.php\?[\w\=\&]*media_id=(\w+).*/, embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
- // allows the options to be set to null, don't send null values to the server as parameters
- if(provider.params[i] !== null) qs += "&" + escape(i) + "=" + provider.params[i];
- }
+ //Audio
+ new $.fn.oembed.OEmbedProvider("official.fm", "rich", ["official.fm/.+"], 'http://official.fm/services/oembed', {useYQL: 'json'}),
+ new $.fn.oembed.OEmbedProvider("chirbit", "rich", ["chirb.it/.+"], 'http://chirb.it/oembed.json', {useYQL: 'json'}),
+ new $.fn.oembed.OEmbedProvider("chirbit", "audio", ["chirb\\.it/.+"], "http://chirb.it/wp/$1", {templateRegex: [/.*chirb\.it\/wp\/(\w+).*/, /.*chirb\.it\/(\w+).*/], embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
+ new $.fn.oembed.OEmbedProvider("Huffduffer", "rich", ["huffduffer.com/[-.\\w@]+/\\d+"], "http://huffduffer.com/oembed"),
+ new $.fn.oembed.OEmbedProvider("Spotify", "rich", ["open.spotify.com/(track|album|user)/"], "https://embed.spotify.com/oembed/"),
+ new $.fn.oembed.OEmbedProvider("shoudio", "rich", ["shoudio.com/.+", "shoud.io/.+"], "http://shoudio.com/api/oembed"),
+ new $.fn.oembed.OEmbedProvider("mixcloud", "rich", ["mixcloud.com/.+"], 'http://www.mixcloud.com/oembed/', {useYQL: 'json'}),
+ new $.fn.oembed.OEmbedProvider("rdio.com", "rich", ["rd.io/.+", "rdio.com"], "http://www.rdio.com/api/oembed/"),
+ new $.fn.oembed.OEmbedProvider("Soundcloud", "rich", ["soundcloud.com/.+", "snd.sc/.+"], "//soundcloud.com/oembed", {format: 'js'}),
+ new $.fn.oembed.OEmbedProvider("bandcamp", "rich", ["bandcamp\\.com/album/.+"], null,
+ {
+ yql: {
+ xpath: "//meta[contains(@content, \\'EmbeddedPlayer\\')]",
+ from: 'html',
+ datareturn: function (results) {
+ return results.meta ? '' : false;
+ }
+ }
+ }),
- url += "format=" + provider.format + "&url=" + escape(externalUrl) + qs;
- if(provider.dataType != 'json') url += "&" + provider.callbackparameter + "=?";
+ //Photo
+ new $.fn.oembed.OEmbedProvider("deviantart", "photo", ["deviantart.com/.+", "fav.me/.+", "deviantart.com/.+"], "//backend.deviantart.com/oembed", {format: 'jsonp'}),
+ new $.fn.oembed.OEmbedProvider("skitch", "photo", ["skitch.com/.+"], null,
+ {
+ yql: {
+ xpath: "json",
+ from: 'json',
+ url: function (externalurl) {
+ return 'http://skitch.com/oembed/?format=json&url=' + externalurl
+ },
+ datareturn: function (data) {
+ return $.fn.oembed.getPhotoCode(data.json.url, data.json);
+ }
+ }
+ }),
+ new $.fn.oembed.OEmbedProvider("mobypicture", "photo", ["mobypicture.com/user/.+/view/.+", "moby.to/.+"], "http://api.mobypicture.com/oEmbed"),
+ new $.fn.oembed.OEmbedProvider("flickr", "photo", ["flickr\\.com/photos/.+"], "//flickr.com/services/oembed", {callbackparameter: 'jsoncallback'}),
+ new $.fn.oembed.OEmbedProvider("photobucket", "photo", ["photobucket\\.com/(albums|groups)/.+"], "http://photobucket.com/oembed/"),
+ new $.fn.oembed.OEmbedProvider("instagram", "photo", ["instagr\\.?am(\\.com)?/.+"], "//api.instagram.com/oembed"),
+ //new $.fn.oembed.OEmbedProvider("yfrog", "photo", ["yfrog\\.(com|ru|com\\.tr|it|fr|co\\.il|co\\.uk|com\\.pl|pl|eu|us)/.+"], "http://www.yfrog.com/api/oembed",{useYQL:"json"}),
+ new $.fn.oembed.OEmbedProvider("SmugMug", "photo", ["smugmug.com/[-.\\w@]+/.+"], "http://api.smugmug.com/services/oembed/"),
+ new $.fn.oembed.OEmbedProvider("dribbble", "photo", ["dribbble.com/shots/.+"], "http://api.dribbble.com/shots/$1?callback=?",
+ {
+ templateRegex: /.*shots\/([\d]+).*/,
+ templateData: function (data) {
+ if (!data.image_teaser_url) {
+ return false;
+ }
+ return '
';
+ }
+ }),
+ new $.fn.oembed.OEmbedProvider("chart.ly", "photo", ["chart\\.ly/[a-z0-9]{6,8}"], "http://chart.ly/uploads/large_$1.png",
+ {templateRegex: /.*ly\/([^\/]+).*/, embedtag: {tag: 'img'}, nocache: 1}),
+ //new $.fn.oembed.OEmbedProvider("stocktwits.com", "photo", ["stocktwits\\.com/message/.+"], "http://charts.stocktwits.com/production/original_$1.png?",
+ // { templateRegex: /.*message\/([^\/]+).*/, embedtag: { tag: 'img'},nocache:1 }),
+ new $.fn.oembed.OEmbedProvider("circuitlab", "photo", ["circuitlab.com/circuit/.+"], "https://www.circuitlab.com/circuit/$1/screenshot/540x405/",
+ {templateRegex: /.*circuit\/([^\/]+).*/, embedtag: {tag: 'img'}, nocache: 1}),
+ new $.fn.oembed.OEmbedProvider("23hq", "photo", ["23hq.com/[-.\\w@]+/photo/.+"], "http://www.23hq.com/23/oembed", {useYQL: "json"}),
+ new $.fn.oembed.OEmbedProvider("img.ly", "photo", ["img\\.ly/.+"], "//img.ly/show/thumb/$1",
+ {templateRegex: /.*ly\/([^\/]+).*/, embedtag: {tag: 'img'}, nocache: 1}),
+ new $.fn.oembed.OEmbedProvider("twitgoo.com", "photo", ["twitgoo\\.com/.+"], "http://twitgoo.com/show/thumb/$1",
+ {templateRegex: /.*com\/([^\/]+).*/, embedtag: {tag: 'img'}, nocache: 1}),
+ new $.fn.oembed.OEmbedProvider("imgur.com", "photo", ["imgur\\.com/gallery/.+"], "http://imgur.com/$1l.jpg",
+ {templateRegex: /.*gallery\/([^\/]+).*/, embedtag: {tag: 'img'}, nocache: 1}),
+ new $.fn.oembed.OEmbedProvider("visual.ly", "rich", ["visual\\.ly/.+"], null,
+ {
+ yql: {
+ xpath: "//a[@id=\\'gc_article_graphic_image\\']/img",
+ from: 'htmlstring'
+ }
+ }),
+ new $.fn.oembed.OEmbedProvider("achewood", "photo", ["achewood\\.com\\/index.php\\?date=.+"], "http://www.achewood.com/comic.php?date=$1", {templateRegex: /.*achewood\.com\/index.php\?date=(\w+).*/, embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
+ new $.fn.oembed.OEmbedProvider("fotokritik", "photo", ["fotokritik\\.com/.+"], "http://www.fotokritik.com/embed/$1", {templateRegex: [/.*fotokritik\.com\/embed\/(\w+).*/, /.*fotokritik\.com\/(\w+).*/], embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
+ new $.fn.oembed.OEmbedProvider("giflike", "photo", ["giflike\\.com/.+"], "http://www.giflike.com/embed/$1", {templateRegex: [/.*giflike\.com\/embed\/(\w+).*/, /.*giflike\.com\/a\/(\w+).*/], embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
- return url;
- }
+ //Rich
+ new $.fn.oembed.OEmbedProvider("twitter", "rich", ["twitter.com/.+"], "https://api.twitter.com/1/statuses/oembed.json"),
+ new $.fn.oembed.OEmbedProvider("gmep", "rich", ["gmep.imeducate.com/.*", "gmep.org/.*"], "http://gmep.org/oembed.json"),
+ new $.fn.oembed.OEmbedProvider("urtak", "rich", ["urtak.com/(u|clr)/.+"], "http://oembed.urtak.com/1/oembed"),
+ new $.fn.oembed.OEmbedProvider("cacoo", "rich", ["cacoo.com/.+"], "http://cacoo.com/oembed.json"),
+ new $.fn.oembed.OEmbedProvider("dailymile", "rich", ["dailymile.com/people/.*/entries/.*"], "http://api.dailymile.com/oembed"),
+ new $.fn.oembed.OEmbedProvider("documentcloud", "rich", ["documentcloud.org/documents/.+"], "https://www.documentcloud.org/api/oembed.json"),
+ new $.fn.oembed.OEmbedProvider("dipity", "rich", ["dipity.com/timeline/.+"], 'http://www.dipity.com/oembed/timeline/', {useYQL: 'json'}),
+ new $.fn.oembed.OEmbedProvider("sketchfab", "rich", ["sketchfab.com/show/.+"], 'http://sketchfab.com/oembed', {useYQL: 'json'}),
+ new $.fn.oembed.OEmbedProvider("speakerdeck", "rich", ["speakerdeck.com/.+"], 'http://speakerdeck.com/oembed.json', {useYQL: 'json'}),
+ new $.fn.oembed.OEmbedProvider("popplet", "rich", ["popplet.com/app/.*"], "http://popplet.com/app/Popplet_Alpha.swf?page_id=$1&em=1",
+ {
+ templateRegex: /.*#\/([^\/]+).*/,
+ embedtag: {
+ width: 460,
+ height: 460
+ }
+ }),
- function success(oembedData, externalUrl, container) {
- $('#jqoembeddata').data(externalUrl, oembedData.code);
- settings.beforeEmbed.call(container, oembedData);
- settings.onEmbed.call(container, oembedData);
- settings.afterEmbed.call(container, oembedData);
- }
+ new $.fn.oembed.OEmbedProvider("pearltrees", "rich", ["pearltrees.com/.*"], "http://cdn.pearltrees.com/s/embed/getApp?",
+ {
+ templateRegex: /.*N-f=1_(\d+).*N-p=(\d+).*/,
+ embedtag: {
+ width: 460,
+ height: 460,
+ flashvars: "lang=en_US&embedId=pt-embed-$1-693&treeId=$1&pearlId=$2&treeTitle=Diagrams%2FVisualization&site=www.pearltrees.com%2FF"
+ }
+ }),
- function embedCode(container, externalUrl, embedProvider) {
- if($('#jqoembeddata').data(externalUrl) != undefined && embedProvider.embedtag.tag != 'iframe') {
- var oembedData = {
- code: $('#jqoembeddata').data(externalUrl)
- };
- success(oembedData, externalUrl, container);
- } else if(embedProvider.yql) {
- var from = embedProvider.yql.from || 'htmlstring';
- var url = embedProvider.yql.url ? embedProvider.yql.url(externalUrl) : externalUrl;
- var query = 'SELECT * FROM ' + from + ' WHERE url="' + (url) + '"' + " and " + (/html/.test(from) ? 'xpath' : 'itemPath') + "='" + (embedProvider.yql.xpath || '/') + "'";
- if(from == 'html') query += " and compat='html5'";
- var ajaxopts = $.extend({
- url: "http://query.yahooapis.com/v1/public/yql",
- dataType: 'jsonp',
- data: {
- q: query,
- format: "json",
- env: 'store://datatables.org/alltableswithkeys',
- callback: "?"
- },
- success: function (data) {
- var result;
- if(embedProvider.yql.xpath && embedProvider.yql.xpath == '//meta|//title|//link') {
- var meta = {};
- if(data.query.results == null) {
- data.query.results = {
- "meta": []
- };
- }
- for(var i = 0, l = data.query.results.meta.length; i < l; i++) {
- var name = data.query.results.meta[i].name || data.query.results.meta[i].property || null;
- if(name == null) continue;
- meta[name.toLowerCase()] = data.query.results.meta[i].content;
- }
- if(!meta.hasOwnProperty("title") || !meta.hasOwnProperty("og:title")) {
- if(data.query.results.title != null) {
- meta.title = data.query.results.title;
- }
- }
- result = embedProvider.yql.datareturn(meta);
- } else {
- result = embedProvider.yql.datareturn ? embedProvider.yql.datareturn(data.query.results) : data.query.results.result;
- }
- if(result === false) return;
- var oembedData = $.extend({}, result);
- oembedData.code = result;
- success(oembedData, externalUrl, container);
- },
- error: settings.onError.call(container, externalUrl, embedProvider)
- }, settings.ajaxOptions || {});
+ new $.fn.oembed.OEmbedProvider("prezi", "rich", ["prezi.com/.*"], "//prezi.com/bin/preziloader.swf?",
+ {
+ templateRegex: /.*com\/([^\/]+)\/.*/,
+ embedtag: {
+ width: 550,
+ height: 400,
+ flashvars: "prezi_id=$1&lock_to_path=0&color=ffffff&autoplay=no&autohide_ctrls=0"
+ }
+ }),
- $.ajax(ajaxopts);
- } else if(embedProvider.templateRegex) {
- if(embedProvider.embedtag.tag !== '') {
- var flashvars = embedProvider.embedtag.flashvars || '';
- var tag = embedProvider.embedtag.tag || 'embed';
- var width = embedProvider.embedtag.width || 'auto';
- var nocache = embedProvider.embedtag.nocache || 0;
- var height = embedProvider.embedtag.height || 'auto';
- var src = externalUrl.replace(embedProvider.templateRegex, embedProvider.apiendpoint);
- if(!embedProvider.nocache) src += '&jqoemcache=' + rand(5);
- if(embedProvider.apikey) src = src.replace('_APIKEY_', settings.apikeys[embedProvider.name]);
+ new $.fn.oembed.OEmbedProvider("tourwrist", "rich", ["tourwrist.com/tours/.+"], null,
+ {
+ templateRegex: /.*tours.([\d]+).*/,
+ template: function (wm, tourid) {
+ setTimeout(function () {
+ if (loadEmbeds)loadEmbeds();
+ }, 2000);
+ return " ";
+ }
+ }),
- var code = $('<' + tag + '/>')
- .attr('src', src)
- .attr('width', width)
- .attr('height', height)
- .attr('allowfullscreen', embedProvider.embedtag.allowfullscreen || 'true')
- .attr('allowscriptaccess', embedProvider.embedtag.allowfullscreen || 'always')
- .css('max-height', settings.maxHeight || 'auto')
- .css('max-width', settings.maxWidth || 'auto');
- if(tag == 'embed') {
- code
- .attr('type', embedProvider.embedtag.type || "application/x-shockwave-flash")
- .attr('flashvars', externalUrl.replace(embedProvider.templateRegex, flashvars));
- }
- if(tag == 'iframe'){
- code
- .attr('scrolling', embedProvider.embedtag.scrolling || "no")
- .attr('frameborder', embedProvider.embedtag.frameborder || "0");
- }
+ new $.fn.oembed.OEmbedProvider("meetup", "rich", ["meetup\\.(com|ps)/.+"], "http://api.meetup.com/oembed"),
+ new $.fn.oembed.OEmbedProvider("ebay", "rich", ["ebay\\.*"], "http://togo.ebay.com/togo/togo.swf?2008013100",
+ {
+ templateRegex: /.*\/([^\/]+)\/(\d{10,13}).*/,
+ embedtag: {
+ width: 355,
+ height: 300,
+ flashvars: "base=http://togo.ebay.com/togo/&lang=en-us&mode=normal&itemid=$2&query=$1"
+ }
+ }),
+ new $.fn.oembed.OEmbedProvider("wikipedia", "rich", ["wikipedia.org/wiki/.+"], "http://$1.wikipedia.org/w/api.php?action=parse&page=$2&format=json§ion=0&callback=?", {
+ templateRegex: /.*\/\/([\w]+).*\/wiki\/([^\/]+).*/,
+ templateData: function (data) {
+ if (!data.parse)
+ return false;
+ var text = data.parse['text']['*'].replace(/href="\/wiki/g, 'href="http://en.wikipedia.org/wiki');
+ return '';
+ }
+ }),
+ new $.fn.oembed.OEmbedProvider("imdb", "rich", ["imdb.com/title/.+"], "http://www.imdbapi.com/?i=$1&callback=?",
+ {
+ templateRegex: /.*\/title\/([^\/]+).*/,
+ templateData: function (data) {
+ if (!data.Title)
+ return false;
+ return 'Rating: ' + data.imdbRating + '
Genre: ' + data.Genre + '
Starring: ' + data.Actors + '
' + data.Plot + '
';
+ }
+ }),
+ new $.fn.oembed.OEmbedProvider("livejournal", "rich", ["livejournal.com/"], "http://ljpic.seacrow.com/json/$2$4?jsonp=?"
+ , {
+ templateRegex: /(http:\/\/(((?!users).)+)\.livejournal\.com|.*users\.livejournal\.com\/([^\/]+)).*/,
+ templateData: function (data) {
+ if (!data.username)
+ return false;
+ return '';
+ }
+ }),
+ new $.fn.oembed.OEmbedProvider("circuitbee", "rich", ["circuitbee\\.com/circuit/view/.+"], "http://c.circuitbee.com/build/r/schematic-embed.html?id=$1",
+ {
+ templateRegex: /.*circuit\/view\/(\d+).*/,
+ embedtag: {
+ tag: 'iframe',
+ width: '500',
+ height: '350'
+ }
+ }),
- var oembedData = {
- code: code
- };
- success(oembedData, externalUrl, container);
- } else if(embedProvider.apiendpoint) {
- //Add APIkey if true
- if(embedProvider.apikey) embedProvider.apiendpoint = embedProvider.apiendpoint.replace('_APIKEY_', settings.apikeys[embedProvider.name]);
- ajaxopts = $.extend({
- url: externalUrl.replace(embedProvider.templateRegex, embedProvider.apiendpoint),
- dataType: 'jsonp',
- success: function (data) {
- var oembedData = $.extend({}, data);
- oembedData.code = embedProvider.templateData(data);
- if(oembedData.code) success(oembedData, externalUrl, container);
- },
- error: settings.onError.call(container, externalUrl, embedProvider)
- }, settings.ajaxOptions || {});
+ new $.fn.oembed.OEmbedProvider("googlecalendar", "rich", ["www.google.com/calendar/embed?.+"], "$1",
+ {templateRegex: /(.*)/, embedtag: {tag: 'iframe', width: '800', height: '600' }}),
+ new $.fn.oembed.OEmbedProvider("jsfiddle", "rich", ["jsfiddle.net/[^/]+/?"], "http://jsfiddle.net/$1/embedded/result,js,resources,html,css/?",
+ {templateRegex: /.*net\/([^\/]+).*/, embedtag: {tag: 'iframe', width: '100%', height: '300' }}),
+ new $.fn.oembed.OEmbedProvider("jsbin", "rich", ["jsbin.com/.+"], "http://jsbin.com/$1/?",
+ {templateRegex: /.*com\/([^\/]+).*/, embedtag: {tag: 'iframe', width: '100%', height: '300' }}),
+ new $.fn.oembed.OEmbedProvider("jotform", "rich", ["form.jotform.co/form/.+"], "$1?",
+ {templateRegex: /(.*)/, embedtag: {tag: 'iframe', width: '100%', height: '507' }}),
+ new $.fn.oembed.OEmbedProvider("reelapp", "rich", ["reelapp\\.com/.+"], "http://www.reelapp.com/$1/embed",
+ {templateRegex: /.*com\/(\S{6}).*/, embedtag: {tag: 'iframe', width: '400', height: '338'}}),
+ new $.fn.oembed.OEmbedProvider("linkedin", "rich", ["linkedin.com/pub/.+"], "https://www.linkedin.com/cws/member/public_profile?public_profile_url=$1&format=inline&isFramed=true",
+ {templateRegex: /(.*)/, embedtag: {tag: 'iframe', width: '368px', height: 'auto'}}),
+ new $.fn.oembed.OEmbedProvider("timetoast", "rich", ["timetoast.com/timelines/[0-9]+"], "http://www.timetoast.com/flash/TimelineViewer.swf?passedTimelines=$1",
+ {templateRegex: /.*timelines\/([0-9]*)/, embedtag: { width: 550, height: 400}, nocache: 1}),
+ new $.fn.oembed.OEmbedProvider("pastebin", "rich", ["pastebin\\.com/[\\S]{8}"], "http://pastebin.com/embed_iframe.php?i=$1",
+ {templateRegex: /.*\/(\S{8}).*/, embedtag: {tag: 'iframe', width: '100%', height: 'auto'}}),
+ new $.fn.oembed.OEmbedProvider("mixlr", "rich", ["mixlr.com/.+"], "http://mixlr.com/embed/$1?autoplay=ae",
+ {templateRegex: /.*com\/([^\/]+).*/, embedtag: {tag: 'iframe', width: '100%', height: 'auto' }}),
+ new $.fn.oembed.OEmbedProvider("pastie", "rich", ["pastie\\.org/pastes/.+"], null, {yql: {xpath: '//pre[@class="textmate-source"]'}}),
+ new $.fn.oembed.OEmbedProvider("github", "rich", ["gist.github.com/.+"], "https://github.com/api/oembed"),
+ new $.fn.oembed.OEmbedProvider("github", "rich", ["github.com/[-.\\w@]+/[-.\\w@]+"], "https://api.github.com/repos/$1/$2?callback=?"
+ , {templateRegex: /.*\/([^\/]+)\/([^\/]+).*/,
+ templateData: function (data) {
+ if (!data.data.html_url)return false;
+ return '' + data.data.description + '
'
+ + '
Last updated: ' + data.data.pushed_at + '
';
+ }
+ }),
+ new $.fn.oembed.OEmbedProvider("facebook", "rich", ["facebook.com"], null
+ , {templateRegex: /.*\/([^\/]+)\/([^\/]+).*/,
+ template: function (url) {
+ // adding script directly to DOM to make sure that it is loaded correctly.
+ if (!$.fn.oembed.facebokScriptHasBeenAdded) {
+ $('').appendTo('body');
+ var script = document.createElement('script');
+ script.type = 'text/javascript';
+ script.text = '(function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) return;js = d.createElement(s); js.id = id;js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0";fjs.parentNode.insertBefore(js, fjs);}(document, "script", "facebook-jssdk"));';
+ document.body.appendChild(script);
+ $.fn.oembed.facebokScriptHasBeenAdded = true;
+ }
- $.ajax(ajaxopts);
- } else {
- var oembedData = {
- code: externalUrl.replace(embedProvider.templateRegex, embedProvider.template)
- };
- success(oembedData, externalUrl, container);
- }
- } else {
+ // returning template with url of facebook post.
+ return '';
- var requestUrl = getRequestUrl(embedProvider, externalUrl),
- ajaxopts = $.extend({
- url: requestUrl,
- dataType: embedProvider.dataType || 'jsonp',
- success: function (data) {
- var oembedData = $.extend({}, data);
- switch(oembedData.type) {
- case "file": //Deviant Art has this
- case "photo":
- oembedData.code = $.fn.oembed.getPhotoCode(externalUrl, oembedData);
- break;
- case "video":
- case "rich":
- oembedData.code = $.fn.oembed.getRichCode(externalUrl, oembedData);
- break;
- default:
- oembedData.code = $.fn.oembed.getGenericCode(externalUrl, oembedData);
- break;
- }
- success(oembedData, externalUrl, container);
- },
- error: settings.onError.call(container, externalUrl, embedProvider)
- }, settings.ajaxOptions || {});
+ }
+ }),
+ /*
+ // Saving old implementation of Facebook in case we will need it as example in the future.
+ new $.fn.oembed.OEmbedProvider("facebook", "rich", ["facebook.com/(people/[^\\/]+/\\d+|[^\\/]+$)"], "https://graph.facebook.com/$2$3/?callback=?"
+ ,{templateRegex:/.*facebook.com\/(people\/[^\/]+\/(\d+).*|([^\/]+$))/,
+ templateData : function(data){ if(!data.id)return false;
+ var out = '';
+ if(data.picture) out += '

';
+ else out += '

';
+ if(data.from) out += '
'+data.name+'';
+ if(data.founded) out += 'Founded:
'+data.founded+'';
+ if(data.category) out += 'Category:
'+data.category+'';
+ if(data.website) out += 'Website:
'+data.website+'';
+ if(data.gender) out += 'Gender:
'+data.gender+'';
+ if(data.description) out += data.description + '
';
+ out += '
';
+ return out;
+ }
+ }),
+ */
+ new $.fn.oembed.OEmbedProvider("stackoverflow", "rich", ["stackoverflow.com/questions/[\\d]+"], "http://api.stackoverflow.com/1.1/questions/$1?body=true&jsonp=?"
+ , {templateRegex: /.*questions\/([\d]+).*/,
+ templateData: function (data) {
+ if (!data.questions)
+ return false;
+ var q = data.questions[0];
+ var body = $(q.body).text();
+ var out = '
'
+ + '
' + (q.up_vote_count - q.down_vote_count) + 'vote(s)
'
+ + '
' + q.answer_count + 'answer
' + q.view_count + ' view(s)
'
+ + '
'
+ + '
' + body.substring(0, 100) + '...
';
+ return out;
+ }
+ }),
+ new $.fn.oembed.OEmbedProvider("wordpress", "rich", ["wordpress\\.com/.+", "blogs\\.cnn\\.com/.+", "techcrunch\\.com/.+", "wp\\.me/.+"], "http://public-api.wordpress.com/oembed/1.0/?for=jquery-oembed-all"),
+ new $.fn.oembed.OEmbedProvider("screenr", "rich", ["screenr\.com"], "http://www.screenr.com/embed/$1",
+ {templateRegex: /.*\/([^\/]+).*/, embedtag: {tag: 'iframe', width: '650', height: 396}}) ,
+ new $.fn.oembed.OEmbedProvider("gigpans", "rich", ["gigapan\\.org/[-.\\w@]+/\\d+"], "http://gigapan.org/gigapans/$1/options/nosnapshots/iframe/flash.html",
+ {templateRegex: /.*\/(\d+)\/?.*/, embedtag: {tag: 'iframe', width: '100%', height: 400 }}),
+ new $.fn.oembed.OEmbedProvider("scribd", "rich", ["scribd\\.com/.+"], "http://www.scribd.com/embeds/$1/content?start_page=1&view_mode=list",
+ {templateRegex: /.*doc\/([^\/]+).*/, embedtag: {tag: 'iframe', width: '100%', height: 600}}),
+ new $.fn.oembed.OEmbedProvider("kickstarter", "rich", ["kickstarter\\.com/projects/.+"], "$1/widget/card.html",
+ {templateRegex: /([^\?]+).*/, embedtag: {tag: 'iframe', width: '220', height: 380}}),
+ new $.fn.oembed.OEmbedProvider("amazon", "rich", ["amzn.com/B+", "amazon.com.*/(B\\S+)($|\\/.*)"], "http://rcm.amazon.com/e/cm?t=_APIKEY_&o=1&p=8&l=as1&asins=$1&ref=qf_br_asin_til&fc1=000000&IS2=1<1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr",
+ {
+ apikey: true,
+ templateRegex: /.*\/(B[0-9A-Z]+)($|\/.*)/,
+ embedtag: {
+ tag: 'iframe',
+ width: '120px',
+ height: '240px'}
+ }),
+ new $.fn.oembed.OEmbedProvider("slideshare", "rich", ["slideshare\.net"], "//www.slideshare.net/api/oembed/2", {format: 'jsonp'}),
+ new $.fn.oembed.OEmbedProvider("roomsharejp", "rich", ["roomshare\\.jp/(en/)?post/.*"], "http://roomshare.jp/oembed.json"),
+ new $.fn.oembed.OEmbedProvider("lanyard", "rich", ["lanyrd.com/\\d+/.+"], null,
+ {
+ yql: {
+ xpath: '(//div[@class="primary"])[1]',
+ from: 'htmlstring',
+ datareturn: function (results) {
+ if (!results.result)
+ return false;
+ return '
' + results.result + '
';
+ }
+ }
+ }),
+ new $.fn.oembed.OEmbedProvider("asciiartfarts", "rich", ["asciiartfarts.com/\\d+.html"], null,
+ {
+ yql: {
+ xpath: '//pre/font',
+ from: 'htmlstring',
+ datareturn: function (results) {
+ if (!results.result)
+ return false;
+ return '
' + results.result + '
';
+ }
+ }
+ }),
+ new $.fn.oembed.OEmbedProvider("coveritlive", "rich", ["coveritlive.com/"], null, {
+ templateRegex: /(.*)/,
+ template: ''}),
+ new $.fn.oembed.OEmbedProvider("polldaddy", "rich", ["polldaddy.com/"], null, {
+ templateRegex: /(?:https?:\/\/w?w?w?.?polldaddy.com\/poll\/)([0-9]*)\//,
+ template: '',
+ nocache: 1
+ }),
+ new $.fn.oembed.OEmbedProvider("360io", "rich", ["360\\.io/.+"], "http://360.io/$1", {templateRegex: /.*360\.io\/(\w+).*/, embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
+ new $.fn.oembed.OEmbedProvider("bubbli", "rich", ["on\\.bubb\\.li/.+"], "http://on.bubb.li/$1", {templateRegex: /.*on\.bubb\.li\/(\w+).*/, embedtag: {tag: 'iframe', width: 480, height: 360}, nocache: 1 }),
+ new $.fn.oembed.OEmbedProvider("cloudup", "rich", ["cloudup\\.com/.+"], "http://cloudup.com/$1?chromeless", {templateRegex: [/.*cloudup\.com\/(\w+).*/], embedtag: {tag: 'iframe', width: 480, height: 360 }}),
+ new $.fn.oembed.OEmbedProvider("codepen", "rich", ["codepen.io/.+"], "http://codepen.io/$1/embed/$2", {templateRegex: [/.*io\/(\w+)\/pen\/(\w+).*/, /.*io\/(\w+)\/full\/(\w+).*/], embedtag: {tag: 'iframe', width: '100%', height: '300'}, nocache: 1 }),
+ new $.fn.oembed.OEmbedProvider("googleviews", "rich", ["(.*maps\\.google\\.com\\/maps\\?).+(output=svembed).+(cbp=(.*)).*"], "https://maps.google.com/maps?layer=c&panoid=$3&ie=UTF8&source=embed&output=svembed&cbp=$5", {templateRegex: /(.*maps\.google\.com\/maps\?).+(panoid=(\w+)&).*(cbp=(.*)).*/, embedtag: {tag: 'iframe', width: 480, height: 360}, nocache: 1 }),
+ new $.fn.oembed.OEmbedProvider("googlemaps", "rich", ["google\\.com\/maps\/place/.+"], "http://maps.google.com/maps?t=m&q=$1&output=embed", {templateRegex: /.*google\.com\/maps\/place\/([\w\+]*)\/.*/, embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
+ new $.fn.oembed.OEmbedProvider("imajize", "rich", ["embed\\.imajize\\.com/.+"], "http://embed.imajize.com/$1", {templateRegex: /.*embed\.imajize\.com\/(.*)/, embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
+ new $.fn.oembed.OEmbedProvider("mapjam", "rich", ["mapjam\\.com/.+"], "http://www.mapjam.com/$1", {templateRegex: /.*mapjam\.com\/(.*)/, embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
+ new $.fn.oembed.OEmbedProvider("polar", "rich", ["polarb\\.com/.+"], "http://assets-polarb-com.a.ssl.fastly.net/api/v4/publishers/unknown/embedded_polls/iframe?poll_id=$1", {templateRegex: /.*polarb\.com\/polls\/(\w+).*/, embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
+ new $.fn.oembed.OEmbedProvider("ponga", "rich", ["ponga\\.com/.+"], "https://www.ponga.com/embedded?id=$1", {templateRegex: [/.*ponga\.com\/embedded\?id=(\w+).*/, /.*ponga\.com\/(\w+).*/], embedtag: {tag: 'iframe', width: 480, height: 360 }, nocache: 1}),
- function getNormalizedParams(params) {
- if(params === null) return null;
- var key, normalizedParams = {};
- for(key in params) {
- if(key !== null) normalizedParams[key.toLowerCase()] = params[key];
- }
- return normalizedParams;
- }
-
- /* Public functions */
- $.fn.oembed.insertCode = function (container, embedMethod, oembedData) {
- if(oembedData === null) return;
- if(embedMethod == 'auto' && container.attr("href") !== null) embedMethod = 'append';
- else if(embedMethod == 'auto') embedMethod = 'replace';
- switch(embedMethod) {
- case "replace":
- container.replaceWith(oembedData.code);
- break;
- case "fill":
- container.html(oembedData.code);
- break;
- case "append":
- container.wrap('');
- var oembedContainer = container.parent();
- if(settings.includeHandle) {
- $('↓').insertBefore(container).click(function () {
- var encodedString = encodeURIComponent($(this).text());
- $(this).html((encodedString == '%E2%86%91') ? '↓' : '↑');
- $(this).parent().children().last().toggle();
- });
- }
- oembedContainer.append('
');
- try {
- oembedData.code.clone().appendTo(oembedContainer);
- } catch(e) {
- oembedContainer.append(oembedData.code);
- }
- /* Make videos semi-responsive
- * If parent div width less than embeded iframe video then iframe gets shrunk to fit smaller width
- * If parent div width greater thans embed iframe use the max widht
- * - works on youtubes and vimeo
- */
- if(settings.maxWidth) {
- var post_width = oembedContainer.parent().width();
- if(post_width < settings.maxWidth) {
- var iframe_width_orig = $('iframe', oembedContainer).width();
- var iframe_height_orig = $('iframe', oembedContainer).height();
- var ratio = iframe_width_orig / post_width;
- $('iframe', oembedContainer).width(iframe_width_orig / ratio);
- $('iframe', oembedContainer).height(iframe_height_orig / ratio);
- } else {
- if(settings.maxWidth) {
- $('iframe', oembedContainer).width(settings.maxWidth);
- }
- if(settings.maxHeight) {
- $('iframe', oembedContainer).height(settings.maxHeight);
- }
- }
- }
- break;
- }
- };
-
- $.fn.oembed.getPhotoCode = function (url, oembedData) {
- var code, alt = oembedData.title ? oembedData.title : '';
- alt += oembedData.author_name ? ' - ' + oembedData.author_name : '';
- alt += oembedData.provider_name ? ' - ' + oembedData.provider_name : '';
- if(oembedData.url) {
- code = '';
- } else if(oembedData.thumbnail_url) {
- var newURL = oembedData.thumbnail_url.replace('_s', '_b');
- code = '';
- } else {
- code = 'Error loading this picture
';
- }
- if(oembedData.html) code += "" + oembedData.html + "
";
- return code;
- };
-
- $.fn.oembed.getRichCode = function (url, oembedData) {
- var code = oembedData.html;
- return code;
- };
-
- $.fn.oembed.getGenericCode = function (url, oembedData) {
- var title = (oembedData.title !== null) ? oembedData.title : url,
- code = '';
- if(oembedData.html) code += '' + title + '
' + jQuery(oembedData.html).text().substring(0,200) + '... more
';
- return code;
- };
-
- $.fn.oembed.getOEmbedProvider = function (url) {
- for(var i = 0; i < $.fn.oembed.providers.length; i++) {
- for(var j = 0, l = $.fn.oembed.providers[i].urlschemes.length; j < l; j++) {
- var regExp = new RegExp($.fn.oembed.providers[i].urlschemes[j], "i");
- if(url.match(regExp) !== null) return $.fn.oembed.providers[i];
- }
- }
- return null;
- };
-
- $.fn.oembed.OEmbedProvider = function (name, type, urlschemesarray, apiendpoint, extraSettings) {
- this.name = name;
- this.type = type; // "photo", "video", "link", "rich", null
- this.urlschemes = urlschemesarray;
- this.apiendpoint = apiendpoint;
- this.maxWidth = 500;
- this.maxHeight = 400;
- extraSettings = extraSettings || {};
-
- if(extraSettings.useYQL) {
- if(extraSettings.useYQL == 'xml') {
- extraSettings.yql = {
- xpath: "//oembed/html",
- from: 'xml',
- apiendpoint: this.apiendpoint,
- url: function (externalurl) {
- return this.apiendpoint + '?format=xml&url=' + externalurl
- },
- datareturn: function (results) {
- return results.html.replace(/.*\[CDATA\[(.*)\]\]>$/, '$1') || ''
- }
- };
- } else {
- extraSettings.yql = {
- from: 'json',
- apiendpoint: this.apiendpoint,
- url: function (externalurl) {
- return this.apiendpoint + '?format=json&url=' + externalurl
- },
- datareturn: function (results) {
- if(results.json.type != 'video' && (results.json.url || results.json.thumbnail_url)) {
- return '
';
- }
- return results.json.html || ''
- }
- };
- }
- this.apiendpoint = null;
- }
-
- for(var property in extraSettings) {
- this[property] = extraSettings[property];
- }
-
- this.format = this.format || 'json';
- this.callbackparameter = this.callbackparameter || "callback";
- this.embedtag = this.embedtag || {
- tag: ""
- };
- };
-
- /*
- * Function to update existing providers
- *
- * @param {String} name The name of the provider
- * @param {String} type The type of the provider can be "file", "photo", "video", "rich"
- * @param {String} urlshemesarray Array of url of the provider
- * @param {String} apiendpoint The endpoint of the provider
- * @param {String} extraSettings Extra settings of the provider
- */
- $.fn.updateOEmbedProvider = function (name, type, urlschemesarray, apiendpoint, extraSettings) {
- for(var i = 0; i < $.fn.oembed.providers.length; i++) {
- if($.fn.oembed.providers[i].name === name) {
- if(type !== null) {
- $.fn.oembed.providers[i].type = type;
- }
- if(urlschemesarray !== null) {
- $.fn.oembed.providers[i].urlschemes = urlschemesarray;
- }
- if(apiendpoint !== null) {
- $.fn.oembed.providers[i].apiendpoint = apiendpoint;
- }
- if(extraSettings !== null) {
- $.fn.oembed.providers[i].extraSettings = extraSettings;
- for(var property in extraSettings) {
- if(property !== null && extraSettings[property] !== null) {
- $.fn.oembed.providers[i][property] = extraSettings[property];
- }
- }
- }
- }
- }
- };
-
- /* Native & common providers */
- $.fn.oembed.providers = [
- //Video
- new $.fn.oembed.OEmbedProvider("youtube", "video", ["youtube\\.com/watch.+v=[\\w-]+&?", "youtu\\.be/[\\w-]+", "youtube.com/embed"], 'http://www.youtube.com/embed/$1?wmode=transparent', {
- templateRegex: /.*(?:v\=|be\/|embed\/)([\w\-]+)&?.*/,
- embedtag: {
- tag: 'iframe',
- width: '425',
- height: '349'
- }
- }),
-
- // new $.fn.oembed.OEmbedProvider("youtube", "video", ["youtube\\.com/watch.+v=[\\w-]+&?", "youtu\\.be/[\\w-]+"], 'http://www.youtube.com/oembed', {
- // useYQL: 'json'
- // }),
- // new $.fn.oembed.OEmbedProvider("youtubeiframe", "video", ["youtube.com/embed"], "$1?wmode=transparent", {
- // templateRegex: /(.*)/,
- // embedtag: {
- // tag: 'iframe',
- // width: '425',
- // height: '349'
- // }
- // }),
- new $.fn.oembed.OEmbedProvider("wistia", "video", ["wistia.com/m/.+", "wistia.com/embed/.+", "wi.st/m/.+", "wi.st/embed/.+"], 'http://fast.wistia.com/oembed', {
- useYQL: 'json'
- }),
- new $.fn.oembed.OEmbedProvider("xtranormal", "video", ["xtranormal\\.com/watch/.+"], "http://www.xtranormal.com/xtraplayr/$1/$2", {
- templateRegex: /.*com\/watch\/([\w\-]+)\/([\w\-]+).*/,
- embedtag: {
- tag: 'iframe',
- width: '320',
- height: '269'
- }
- }),
- new $.fn.oembed.OEmbedProvider("scivee", "video", ["scivee.tv/node/.+"], "http://www.scivee.tv/flash/embedCast.swf?", {
- templateRegex: /.*tv\/node\/(.+)/,
- embedtag: {
- width: '480',
- height: '400',
- flashvars: "id=$1&type=3"
- }
- }),
- new $.fn.oembed.OEmbedProvider("veoh", "video", ["veoh.com/watch/.+"], "http://www.veoh.com/swf/webplayer/WebPlayer.swf?version=AFrontend.5.7.0.1337&permalinkId=$1&player=videodetailsembedded&videoAutoPlay=0&id=anonymous", {
- templateRegex: /.*watch\/([^\?]+).*/,
- embedtag: {
- width: '410',
- height: '341'
- }
- }),
- new $.fn.oembed.OEmbedProvider("gametrailers", "video", ["gametrailers\\.com/video/.+"], "http://media.mtvnservices.com/mgid:moses:video:gametrailers.com:$2", {
- templateRegex: /.*com\/video\/([\w\-]+)\/([\w\-]+).*/,
- embedtag: {
- width: '512',
- height: '288'
- }
- }),
- new $.fn.oembed.OEmbedProvider("funnyordie", "video", ["funnyordie\\.com/videos/.+"], "http://player.ordienetworks.com/flash/fodplayer.swf?", {
- templateRegex: /.*videos\/([^\/]+)\/([^\/]+)?/,
- embedtag: {
- width: 512,
- height: 328,
- flashvars: "key=$1"
- }
- }),
- new $.fn.oembed.OEmbedProvider("colledgehumour", "video", ["collegehumor\\.com/video/.+"], "http://www.collegehumor.com/moogaloop/moogaloop.swf?clip_id=$1&use_node_id=true&fullscreen=1", {
- templateRegex: /.*video\/([^\/]+).*/,
- embedtag: {
- width: 600,
- height: 338
- }
- }),
- new $.fn.oembed.OEmbedProvider("metacafe", "video", ["metacafe\\.com/watch/.+"], "http://www.metacafe.com/fplayer/$1/$2.swf", {
- templateRegex: /.*watch\/(\d+)\/(\w+)\/.*/,
- embedtag: {
- width: 400,
- height: 345
- }
- }),
- new $.fn.oembed.OEmbedProvider("bambuser", "video", ["bambuser\\.com\/channel\/.*\/broadcast\/.*"], "http://static.bambuser.com/r/player.swf?vid=$1", {
- templateRegex: /.*bambuser\.com\/channel\/.*\/broadcast\/(\w+).*/,
- embedtag: {
- width: 512,
- height: 339
- }
- }),
- new $.fn.oembed.OEmbedProvider("twitvid", "video", ["twitvid\\.com/.+"], "http://www.twitvid.com/embed.php?guid=$1&autoplay=0", {
- templateRegex: /.*twitvid\.com\/(\w+).*/,
- embedtag: {
- tag: 'iframe',
- width: 480,
- height: 360
- }
- }),
- new $.fn.oembed.OEmbedProvider("aniboom", "video", ["aniboom\\.com/animation-video/.+"], "http://api.aniboom.com/e/$1", {
- templateRegex: /.*animation-video\/(\d+).*/,
- embedtag: {
- width: 594,
- height: 334
- }
- }),
- new $.fn.oembed.OEmbedProvider("vzaar", "video", ["vzaar\\.com/videos/.+", "vzaar.tv/.+"], "http://view.vzaar.com/$1/player?", {
- templateRegex: /.*\/(\d+).*/,
- embedtag: {
- tag: 'iframe',
- width: 576,
- height: 324
- }
- }),
- new $.fn.oembed.OEmbedProvider("snotr", "video", ["snotr\\.com/video/.+"], "http://www.snotr.com/embed/$1", {
- templateRegex: /.*\/(\d+).*/,
- embedtag: {
- tag: 'iframe',
- width: 400,
- height: 330,
- nocache: 1
- }
- }),
- new $.fn.oembed.OEmbedProvider("youku", "video", ["v.youku.com/v_show/id_.+"], "http://player.youku.com/player.php/sid/$1/v.swf", {
- templateRegex: /.*id_(.+)\.html.*/,
- embedtag: {
- width: 480,
- height: 400,
- nocache: 1
- }
- }),
- new $.fn.oembed.OEmbedProvider("tudou", "video", ["tudou.com/programs/view/.+\/"], "http://www.tudou.com/v/$1/v.swf", {
- templateRegex: /.*view\/(.+)\//,
- embedtag: {
- width: 480,
- height: 400,
- nocache: 1
- }
- }),
- new $.fn.oembed.OEmbedProvider("embedr", "video", ["embedr\\.com/playlist/.+"], "http://embedr.com/swf/slider/$1/425/520/default/false/std?", {
- templateRegex: /.*playlist\/([^\/]+).*/,
- embedtag: {
- width: 425,
- height: 520
- }
- }),
- new $.fn.oembed.OEmbedProvider("blip", "video", ["blip\\.tv/.+"], "http://blip.tv/oembed/"),
- new $.fn.oembed.OEmbedProvider("minoto-video", "video", ["http://api.minoto-video.com/publishers/.+/videos/.+", "http://dashboard.minoto-video.com/main/video/details/.+", "http://embed.minoto-video.com/.+"], "http://api.minoto-video.com/services/oembed.json", {
- useYQL: 'json'
- }),
- new $.fn.oembed.OEmbedProvider("animoto", "video", ["animoto.com/play/.+"], "http://animoto.com/services/oembed"),
- new $.fn.oembed.OEmbedProvider("hulu", "video", ["hulu\\.com/watch/.*"], "http://www.hulu.com/api/oembed.json"),
- new $.fn.oembed.OEmbedProvider("ustream", "video", ["ustream\\.tv/recorded/.*"], "http://www.ustream.tv/oembed", {
- useYQL: 'json'
- }),
- new $.fn.oembed.OEmbedProvider("videojug", "video", ["videojug\\.com/(film|payer|interview).*"], "http://www.videojug.com/oembed.json", {
- useYQL: 'json'
- }),
- new $.fn.oembed.OEmbedProvider("sapo", "video", ["videos\\.sapo\\.pt/.*"], "http://videos.sapo.pt/oembed", {
- useYQL: 'json'
- }),
- new $.fn.oembed.OEmbedProvider("vodpod", "video", ["vodpod.com/watch/.*"], "http://vodpod.com/oembed.js", {
- useYQL: 'json'
- }),
- new $.fn.oembed.OEmbedProvider("vimeo", "video", ["www\.vimeo\.com\/groups\/.*\/videos\/.*", "www\.vimeo\.com\/.*", "vimeo\.com\/groups\/.*\/videos\/.*", "vimeo\.com\/.*"], "//vimeo.com/api/oembed.json"),
- new $.fn.oembed.OEmbedProvider("dailymotion", "video", ["dailymotion\\.com/.+"], 'http://www.dailymotion.com/services/oembed'),
- new $.fn.oembed.OEmbedProvider("5min", "video", ["www\\.5min\\.com/.+"], 'http://api.5min.com/oembed.xml', {
- useYQL: 'xml'
- }),
- new $.fn.oembed.OEmbedProvider("National Film Board of Canada", "video", ["nfb\\.ca/film/.+"], 'http://www.nfb.ca/remote/services/oembed/', {
- useYQL: 'json'
- }),
- new $.fn.oembed.OEmbedProvider("qik", "video", ["qik\\.com/\\w+"], 'http://qik.com/api/oembed.json', {
- useYQL: 'json'
- }),
- new $.fn.oembed.OEmbedProvider("revision3", "video", ["revision3\\.com"], "http://revision3.com/api/oembed/"),
- new $.fn.oembed.OEmbedProvider("dotsub", "video", ["dotsub\\.com/view/.+"], "http://dotsub.com/services/oembed", {
- useYQL: 'json'
- }),
- new $.fn.oembed.OEmbedProvider("clikthrough", "video", ["clikthrough\\.com/theater/video/\\d+"], "http://clikthrough.com/services/oembed"),
- new $.fn.oembed.OEmbedProvider("Kinomap", "video", ["kinomap\\.com/.+"], "http://www.kinomap.com/oembed"),
- new $.fn.oembed.OEmbedProvider("VHX", "video", ["vhx.tv/.+"], "http://vhx.tv/services/oembed.json"),
- new $.fn.oembed.OEmbedProvider("bambuser", "video", ["bambuser.com/.+"], "http://api.bambuser.com/oembed/iframe.json"),
- new $.fn.oembed.OEmbedProvider("justin.tv", "video", ["justin.tv/.+"], 'http://api.justin.tv/api/embed/from_url.json', {
- useYQL: 'json'
- }),
-
- //Audio
- new $.fn.oembed.OEmbedProvider("official.fm", "rich", ["official.fm/.+"], 'http://official.fm/services/oembed', {
- useYQL: 'json'
- }),
- new $.fn.oembed.OEmbedProvider("chirbit", "rich", ["chirb.it/.+"], 'http://chirb.it/oembed.json', {
- useYQL: 'json'
- }),
- new $.fn.oembed.OEmbedProvider("Huffduffer", "rich", ["huffduffer.com/[-.\\w@]+/\\d+"], "http://huffduffer.com/oembed"),
- new $.fn.oembed.OEmbedProvider("Spotify", "rich", ["open.spotify.com/(track|album|user)/"], "https://embed.spotify.com/oembed/"),
- new $.fn.oembed.OEmbedProvider("shoudio", "rich", ["shoudio.com/.+", "shoud.io/.+"], "http://shoudio.com/api/oembed"),
- new $.fn.oembed.OEmbedProvider("mixcloud", "rich", ["mixcloud.com/.+"], 'http://www.mixcloud.com/oembed/', {
- useYQL: 'json'
- }),
- new $.fn.oembed.OEmbedProvider("rdio.com", "rich", ["rd.io/.+", "rdio.com"], "http://www.rdio.com/api/oembed/"),
- new $.fn.oembed.OEmbedProvider("Soundcloud", "rich", ["soundcloud.com/.+", "snd.sc/.+"], "http://soundcloud.com/oembed", {
- format: 'js'
- }),
- new $.fn.oembed.OEmbedProvider("bandcamp", "rich", ["bandcamp\\.com/album/.+"], null, {
- yql: {
- xpath: "//meta[contains(@content, \\'EmbeddedPlayer\\')]",
- from: 'html',
- datareturn: function (results) {
- return results.meta ? '' : false;
- }
- }
- }),
-
- //Photo
- new $.fn.oembed.OEmbedProvider("deviantart", "photo", ["deviantart.com/.+", "fav.me/.+", "deviantart.com/.+"], "http://backend.deviantart.com/oembed", {
- format: 'jsonp'
- }),
- new $.fn.oembed.OEmbedProvider("skitch", "photo", ["skitch.com/.+"], null, {
- yql: {
- xpath: "json",
- from: 'json',
- url: function (externalurl) {
- return 'http://skitch.com/oembed/?format=json&url=' + externalurl
- },
- datareturn: function (data) {
- return $.fn.oembed.getPhotoCode(data.json.url, data.json);
- }
- }
- }),
- new $.fn.oembed.OEmbedProvider("mobypicture", "photo", ["mobypicture.com/user/.+/view/.+", "moby.to/.+"], "http://api.mobypicture.com/oEmbed"),
- new $.fn.oembed.OEmbedProvider("flickr", "photo", ["flickr\\.com/photos/.+"], "http://flickr.com/services/oembed", {
- callbackparameter: 'jsoncallback'
- }),
- new $.fn.oembed.OEmbedProvider("photobucket", "photo", ["photobucket\\.com/(albums|groups)/.+"], "http://photobucket.com/oembed/"),
- new $.fn.oembed.OEmbedProvider("instagram", "photo", ["instagr\\.?am(\\.com)?/.+"], "http://api.instagram.com/oembed"),
- // new $.fn.oembed.OEmbedProvider("yfrog", "photo", ["yfrog\\.(com|ru|com\\.tr|it|fr|co\\.il|co\\.uk|com\\.pl|pl|eu|us)/.+"], "http://www.yfrog.com/api/oembed", {
- // useYQL: "json"
- // }),
- new $.fn.oembed.OEmbedProvider("SmugMug", "photo", ["smugmug.com/[-.\\w@]+/.+"], "http://api.smugmug.com/services/oembed/"),
-
- new $.fn.oembed.OEmbedProvider("dribbble", "photo", ["dribbble.com/shots/.+"], "http://api.dribbble.com/shots/$1?callback=?", {
- templateRegex: /.*shots\/([\d]+).*/,
- templateData: function (data) {
- if(!data.image_teaser_url) return false;
- return '
';
- }
- }),
- new $.fn.oembed.OEmbedProvider("chart.ly", "photo", ["chart\\.ly/[a-z0-9]{6,8}"], "http://chart.ly/uploads/large_$1.png", {
- templateRegex: /.*ly\/([^\/]+).*/,
- embedtag: {
- tag: 'img'
- },
- nocache: 1
- }),
- // new $.fn.oembed.OEmbedProvider("stocktwits.com", "photo", ["stocktwits\\.com/message/.+"], "http://charts.stocktwits.com/production/original_$1.png?", {
- // templateRegex: /.*message\/([^\/]+).*/,
- // embedtag: {
- // tag: 'img'
- // },
- // nocache: 1
- // }),
- new $.fn.oembed.OEmbedProvider("circuitlab", "photo", ["circuitlab.com/circuit/.+"], "https://www.circuitlab.com/circuit/$1/screenshot/540x405/", {
- templateRegex: /.*circuit\/([^\/]+).*/,
- embedtag: {
- tag: 'img'
- },
- nocache: 1
- }),
- new $.fn.oembed.OEmbedProvider("23hq", "photo", ["23hq.com/[-.\\w@]+/photo/.+"], "http://www.23hq.com/23/oembed", {
- useYQL: "json"
- }),
- new $.fn.oembed.OEmbedProvider("img.ly", "photo", ["img\\.ly/.+"], "http://img.ly/show/thumb/$1", {
- templateRegex: /.*ly\/([^\/]+).*/,
- embedtag: {
- tag: 'img'
- },
- nocache: 1
- }),
- new $.fn.oembed.OEmbedProvider("twitgoo.com", "photo", ["twitgoo\\.com/.+"], "http://twitgoo.com/show/thumb/$1", {
- templateRegex: /.*com\/([^\/]+).*/,
- embedtag: {
- tag: 'img'
- },
- nocache: 1
- }),
- new $.fn.oembed.OEmbedProvider("imgur.com", "photo", ["imgur\\.com/gallery/.+"], "http://imgur.com/$1l.jpg", {
- templateRegex: /.*gallery\/([^\/]+).*/,
- embedtag: {
- tag: 'img'
- },
- nocache: 1
- }),
- new $.fn.oembed.OEmbedProvider("visual.ly", "rich", ["visual\\.ly/.+"], null, {
- yql: {
- xpath: "//a[@id=\\'gc_article_graphic_image\\']/img",
- from: 'htmlstring'
- }
- }),
-
- //Rich
- new $.fn.oembed.OEmbedProvider("twitter", "rich", ["twitter.com/.+"], "https://api.twitter.com/1/statuses/oembed.json"),
- new $.fn.oembed.OEmbedProvider("gmep", "rich", ["gmep.imeducate.com/.*", "gmep.org/.*"], "http://gmep.org/oembed.json"),
- new $.fn.oembed.OEmbedProvider("urtak", "rich", ["urtak.com/(u|clr)/.+"], "http://oembed.urtak.com/1/oembed"),
- new $.fn.oembed.OEmbedProvider("cacoo", "rich", ["cacoo.com/.+"], "http://cacoo.com/oembed.json"),
- new $.fn.oembed.OEmbedProvider("dailymile", "rich", ["dailymile.com/people/.*/entries/.*"], "http://api.dailymile.com/oembed"),
- new $.fn.oembed.OEmbedProvider("dipity", "rich", ["dipity.com/timeline/.+"], 'http://www.dipity.com/oembed/timeline/', {
- useYQL: 'json'
- }),
- new $.fn.oembed.OEmbedProvider("sketchfab", "rich", ["sketchfab.com/show/.+"], 'http://sketchfab.com/oembed', {
- useYQL: 'json'
- }),
- new $.fn.oembed.OEmbedProvider("speakerdeck", "rich", ["speakerdeck.com/.+"], 'http://speakerdeck.com/oembed.json', {
- useYQL: 'json'
- }),
- new $.fn.oembed.OEmbedProvider("popplet", "rich", ["popplet.com/app/.*"], "http://popplet.com/app/Popplet_Alpha.swf?page_id=$1&em=1", {
- templateRegex: /.*#\/([^\/]+).*/,
- embedtag: {
- width: 460,
- height: 460
- }
- }),
- new $.fn.oembed.OEmbedProvider("pearltrees", "rich", ["pearltrees.com/.*"], "http://cdn.pearltrees.com/s/embed/getApp?", {
- templateRegex: /.*N-f=1_(\d+).*N-p=(\d+).*/,
- embedtag: {
- width: 460,
- height: 460,
- flashvars: "lang=en_US&embedId=pt-embed-$1-693&treeId=$1&pearlId=$2&treeTitle=Diagrams%2FVisualization&site=www.pearltrees.com%2FF"
- }
- }),
- new $.fn.oembed.OEmbedProvider("prezi", "rich", ["prezi.com/.*"], "http://prezi.com/bin/preziloader.swf?", {
- templateRegex: /.*com\/([^\/]+)\/.*/,
- embedtag: {
- width: 550,
- height: 400,
- flashvars: "prezi_id=$1&lock_to_path=0&color=ffffff&autoplay=no&autohide_ctrls=0"
- }
- }),
- new $.fn.oembed.OEmbedProvider("tourwrist", "rich", ["tourwrist.com/tours/.+"], null, {
- templateRegex: /.*tours.([\d]+).*/,
- template: function (wm, tourid) {
- setTimeout(function () {
- if(loadEmbeds) loadEmbeds();
- }, 2000);
- return " ";
- }
- }),
- new $.fn.oembed.OEmbedProvider("meetup", "rich", ["meetup\\.(com|ps)/.+"], "http://api.meetup.com/oembed"),
- new $.fn.oembed.OEmbedProvider("ebay", "rich", ["ebay\\.*"], "http://togo.ebay.com/togo/togo.swf?2008013100", {
- templateRegex: /.*\/([^\/]+)\/(\d{10,13}).*/,
- embedtag: {
- width: 355,
- height: 300,
- flashvars: "base=http://togo.ebay.com/togo/&lang=en-us&mode=normal&itemid=$2&query=$1"
- }
- }),
- new $.fn.oembed.OEmbedProvider("wikipedia", "rich", ["wikipedia.org/wiki/.+"], "http://$1.wikipedia.org/w/api.php?action=parse&page=$2&format=json§ion=0&callback=?", {
- templateRegex: /.*\/\/([\w]+).*\/wiki\/([^\/]+).*/,
- templateData: function (data) {
- if(!data.parse) return false;
- var text = data.parse['text']['*'].replace(/href="\/wiki/g, 'href="http://en.wikipedia.org/wiki');
- return '' + data.parse['displaytitle'] + '
' +jQuery(text).text().substring(0,200) + '...
';
- }
- }),
- new $.fn.oembed.OEmbedProvider("imdb", "rich", ["imdb.com/title/.+"], "http://www.imdbapi.com/?i=$1&callback=?", {
- templateRegex: /.*\/title\/([^\/]+).*/,
- templateData: function (data) {
- if(!data.Title) return false;
- return 'Rating: ' + data.imdbRating + '
Genre: ' + data.Genre + '
Starring: ' + data.Actors + '
' + data.Plot + '
';
- }
- }),
- new $.fn.oembed.OEmbedProvider("livejournal", "rich", ["livejournal.com/"], "http://ljpic.seacrow.com/json/$2$4?jsonp=?", {
- templateRegex: /(http:\/\/(((?!users).)+)\.livejournal\.com|.*users\.livejournal\.com\/([^\/]+)).*/,
- templateData: function (data) {
- if(!data.username) return false;
- return '';
- }
- }),
- new $.fn.oembed.OEmbedProvider("circuitbee", "rich", ["circuitbee\\.com/circuit/view/.+"], "http://c.circuitbee.com/build/r/schematic-embed.html?id=$1", {
- templateRegex: /.*circuit\/view\/(\d+).*/,
- embedtag: {
- tag: 'iframe',
- width: '500',
- height: '350'
- }
- }),
- new $.fn.oembed.OEmbedProvider("googlecalendar", "rich", ["www.google.com/calendar/embed?.+"], "$1", {
- templateRegex: /(.*)/,
- embedtag: {
- tag: 'iframe',
- width: '800',
- height: '600'
- }
- }),
- new $.fn.oembed.OEmbedProvider("jsfiddle", "rich", ["jsfiddle.net/[^/]+/?"], "http://jsfiddle.net/$1/embedded/result,js,resources,html,css/?", {
- templateRegex: /.*net\/([^\/]+).*/,
- embedtag: {
- tag: 'iframe',
- width: '100%',
- height: '300'
- }
- }),
- new $.fn.oembed.OEmbedProvider("jsbin", "rich", ["jsbin.com/.+"], "http://jsbin.com/$1/?", {
- templateRegex: /.*com\/([^\/]+).*/,
- embedtag: {
- tag: 'iframe',
- width: '100%',
- height: '300'
- }
- }),
- new $.fn.oembed.OEmbedProvider("jotform", "rich", ["form.jotform.co/form/.+"], "$1?", {
- templateRegex: /(.*)/,
- embedtag: {
- tag: 'iframe',
- width: '100%',
- height: '507'
- }
- }),
- new $.fn.oembed.OEmbedProvider("reelapp", "rich", ["reelapp\\.com/.+"], "http://www.reelapp.com/$1/embed", {
- templateRegex: /.*com\/(\S{6}).*/,
- embedtag: {
- tag: 'iframe',
- width: '400',
- height: '338'
- }
- }),
- new $.fn.oembed.OEmbedProvider("linkedin", "rich", ["linkedin.com/pub/.+"], "https://www.linkedin.com/cws/member/public_profile?public_profile_url=$1&format=inline&isFramed=true", {
- templateRegex: /(.*)/,
- embedtag: {
- tag: 'iframe',
- width: '368px',
- height: 'auto'
- }
- }),
- new $.fn.oembed.OEmbedProvider("timetoast", "rich", ["timetoast.com/timelines/[0-9]+"], "http://www.timetoast.com/flash/TimelineViewer.swf?passedTimelines=$1", {
- templateRegex: /.*timelines\/([0-9]*)/,
- embedtag: {
- width: 550,
- height: 400,
- nocache: 1
- }
- }),
- new $.fn.oembed.OEmbedProvider("pastebin", "rich", ["pastebin\\.com/[\\S]{8}"], "http://pastebin.com/embed_iframe.php?i=$1", {
- templateRegex: /.*\/(\S{8}).*/,
- embedtag: {
- tag: 'iframe',
- width: '100%',
- height: 'auto'
- }
- }),
- new $.fn.oembed.OEmbedProvider("mixlr", "rich", ["mixlr.com/.+"], "http://mixlr.com/embed/$1?autoplay=ae", {
- templateRegex: /.*com\/([^\/]+).*/,
- embedtag: {
- tag: 'iframe',
- width: '100%',
- height: 'auto'
- }
- }),
- new $.fn.oembed.OEmbedProvider("pastie", "rich", ["pastie\\.org/pastes/.+"], null, {
- yql: {
- xpath: '//pre[@class="textmate-source"]'
- }
- }),
- new $.fn.oembed.OEmbedProvider("github", "rich", ["gist.github.com/.+"], "https://github.com/api/oembed"),
- new $.fn.oembed.OEmbedProvider("github", "rich", ["github.com/[-.\\w@]+/[-.\\w@]+"], "https://api.github.com/repos/$1/$2?callback=?", {
- templateRegex: /.*\/([^\/]+)\/([^\/]+).*/,
- templateData: function (data) {
- if(!data.data.html_url) return false;
- return '' + data.data.description + '
' + '
Last updated: ' + data.data.pushed_at + '
';
- }
- }),
- new $.fn.oembed.OEmbedProvider("facebook", "rich", ["facebook.com/(people/[^\\/]+/\\d+|[^\\/]+$)"], "https://graph.facebook.com/$2$3/?callback=?", {
- templateRegex: /.*facebook.com\/(people\/[^\/]+\/(\d+).*|([^\/]+$))/,
- templateData: function (data) {
- if(!data.id) return false;
- var out = '';
- if(data.picture) out += '

';
- else out += '

';
- if(data.from) out += '
' + data.name + '';
- if(data.founded) out += 'Founded:
' + data.founded + ''
- if(data.category) out += 'Category:
' + data.category + '';
- if(data.website) out += 'Website:
' + data.website + '';
- if(data.gender) out += 'Gender:
' + data.gender + '';
- if(data.description) out += data.description + '
';
- out += '
';
- return out;
- }
- }),
- new $.fn.oembed.OEmbedProvider("stackoverflow", "rich", ["stackoverflow.com/questions/[\\d]+"], "http://api.stackoverflow.com/1.1/questions/$1?body=true&jsonp=?", {
- templateRegex: /.*questions\/([\d]+).*/,
- templateData: function (data) {
- if(!data.questions) return false;
- var q = data.questions[0];
- var body = $(q.body).text();
- var out = '
' + '
' + (q.up_vote_count - q.down_vote_count) + 'vote(s)
' + '
' + q.answer_count + 'answer
' + q.view_count + ' view(s)
' + '
' + '
' + body.substring(0, 100) + '...
';
- return out;
- }
- }),
- new $.fn.oembed.OEmbedProvider("wordpress", "rich", ["wordpress\\.com/.+", "blogs\\.cnn\\.com/.+", "techcrunch\\.com/.+", "wp\\.me/.+"], "http://public-api.wordpress.com/oembed/1.0/?for=jquery-oembed-all"),
- new $.fn.oembed.OEmbedProvider("screenr", "rich", ["screenr\.com"], "http://www.screenr.com/embed/$1", {
- templateRegex: /.*\/([^\/]+).*/,
- embedtag: {
- tag: 'iframe',
- width: '650',
- height: 396
- }
- }),
- new $.fn.oembed.OEmbedProvider("gigpans", "rich", ["gigapan\\.org/[-.\\w@]+/\\d+"], "http://gigapan.org/gigapans/$1/options/nosnapshots/iframe/flash.html", {
- templateRegex: /.*\/(\d+)\/?.*/,
- embedtag: {
- tag: 'iframe',
- width: '100%',
- height: 400
- }
- }),
- new $.fn.oembed.OEmbedProvider("scribd", "rich", ["scribd\\.com/.+"], "http://www.scribd.com/embeds/$1/content?start_page=1&view_mode=list", {
- templateRegex: /.*doc\/([^\/]+).*/,
- embedtag: {
- tag: 'iframe',
- width: '100%',
- height: 600
- }
- }),
- new $.fn.oembed.OEmbedProvider("kickstarter", "rich", ["kickstarter\\.com/projects/.+"], "$1/widget/card.html", {
- templateRegex: /([^\?]+).*/,
- embedtag: {
- tag: 'iframe',
- width: '220',
- height: 380
- }
- }),
- new $.fn.oembed.OEmbedProvider("amazon", "rich", ["amzn.com/B+", "amazon.com.*/(B\\S+)($|\\/.*)"], "http://rcm.amazon.com/e/cm?t=_APIKEY_&o=1&p=8&l=as1&asins=$1&ref=qf_br_asin_til&fc1=000000&IS2=1<1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr", {
- apikey: true,
- templateRegex: /.*\/(B[0-9A-Z]+)($|\/.*)/,
- embedtag: {
- tag: 'iframe',
- width: '120px',
- height: '240px'
- }
- }),
- new $.fn.oembed.OEmbedProvider("slideshare", "rich", ["slideshare\.net"], "http://www.slideshare.net/api/oembed/2", {
- format: 'jsonp'
- }),
- new $.fn.oembed.OEmbedProvider("roomsharejp", "rich", ["roomshare\\.jp/(en/)?post/.*"], "http://roomshare.jp/oembed.json"),
- new $.fn.oembed.OEmbedProvider("lanyard", "rich", ["lanyrd.com/\\d+/.+"], null, {
- yql: {
- xpath: '(//div[@class="primary"])[1]',
- from: 'htmlstring',
- datareturn: function (results) {
- if(!results.result) return false;
- return '
' + results.result + '
';
- }
- }
- }),
- new $.fn.oembed.OEmbedProvider("asciiartfarts", "rich", ["asciiartfarts.com/\\d+.html"], null, {
- yql: {
- xpath: '//pre/font',
- from: 'htmlstring',
- datareturn: function (results) {
- if(!results.result) return false;
- return '
' + results.result + '
';
- }
- }
- })
- ];
+ ];
})(jQuery);
+//This is needed for gravatar :(
+String.prototype.md5=function(){var a=function(a,b){var c=(a&65535)+(b&65535);var d=(a>>16)+(b>>16)+(c>>16);return d<<16|c&65535};var b=function(a,b){return a<>>32-b};var c=function(c,d,e,f,g,h){return a(b(a(a(d,c),a(f,h)),g),e)};var d=function(a,b,d,e,f,g,h){return c(b&d|~b&e,a,b,f,g,h)};var e=function(a,b,d,e,f,g,h){return c(b&e|d&~e,a,b,f,g,h)};var f=function(a,b,d,e,f,g,h){return c(b^d^e,a,b,f,g,h)};var g=function(a,b,d,e,f,g,h){return c(d^(b|~e),a,b,f,g,h)};var h=function(b){var c,h,i,j,k,l=b.length;var m=1732584193;var n=-271733879;var o=-1732584194;var p=271733878;for(k=0;k>2]>>d%4*8+4&15)+b.charAt(a[d>>2]>>d%4*8&15)}return c};var j=function(a){var b=(a.length+8>>6)+1;var c=[],d,e=b*16,f,g=a.length;for(d=0;d>2]|=(a.charCodeAt(f)&255)<>2]|=128<sitelock_title = $config['lock']['title'];
$db_info->sitelock_message = $config['lock']['message'];
$db_info->sitelock_whitelist = count($config['lock']['allow']) ? $config['lock']['allow'] : array('127.0.0.1');
- $db_info->embed_white_iframe = $config['embedfilter']['iframe'];
- $db_info->embed_white_object = $config['embedfilter']['object'];
+ $db_info->embed_white_iframe = $config['mediafilter']['iframe'] ?: $config['embedfilter']['iframe'];
+ $db_info->embed_white_object = $config['mediafilter']['object'] ?: $config['embedfilter']['object'];
$db_info->use_mobile_view = $config['use_mobile_view'] ? 'Y' : 'N';
$db_info->use_prepared_statements = $config['use_prepared_statements'] ? 'Y' : 'N';
$db_info->use_rewrite = $config['use_rewrite'] ? 'Y' : 'N';
@@ -686,7 +691,7 @@ class Context
public function checkSSO()
{
// pass if it's not GET request or XE is not yet installed
- if(!config('use_sso') || isCrawler())
+ if(!config('use_sso') || Rhymix\Framework\UA::isRobot())
{
return TRUE;
}
@@ -712,61 +717,66 @@ class Context
$current_site = self::getRequestUri();
// Step 1: if the current site is not the default site, send SSO validation request to the default site
- if($default_url !== $current_site && !self::get('SSOID') && $_COOKIE['sso'] !== md5($current_site))
+ if($default_url !== $current_site && !self::get('sso_response') && $_COOKIE['sso'] !== md5($current_site))
{
// Set sso cookie to prevent multiple simultaneous SSO validation requests
setcookie('sso', md5($current_site), 0, '/');
// Redirect to the default site
- $redirect_url = sprintf('%s?return_url=%s', $default_url, urlencode(base64_encode($current_site)));
+ $sso_request = Rhymix\Framework\Security::encrypt(Rhymix\Framework\URL::getCurrentURL());
+ $redirect_url = $default_url . '?sso_request=' . urlencode($sso_request);
header('Location:' . $redirect_url);
- return FALSE;
+ return false;
}
// Step 2: receive and process SSO validation request at the default site
- if($default_url === $current_site && self::get('return_url'))
+ if($default_url === $current_site && self::get('sso_request'))
{
// Get the URL of the origin site
- $url = base64_decode(self::get('return_url'));
- $url_info = parse_url($url);
+ $sso_request = Rhymix\Framework\Security::decrypt(self::get('sso_request'));
+ if (!$sso_request || !preg_match('!^https?://!', $sso_request))
+ {
+ self::displayErrorPage('SSO Error', 'Invalid SSO Request', 400);
+ return false;
+ }
// Check that the origin site is a valid site in this XE installation (to prevent open redirect vuln)
if(!getModel('module')->getSiteInfoByDomain(rtrim($url, '/'))->site_srl)
{
- htmlHeader();
- echo self::getLang("msg_invalid_request");
- htmlFooter();
- return FALSE;
+ self::displayErrorPage('SSO Error', 'Invalid SSO Request', 400);
+ return false;
}
// Redirect back to the origin site
- $url_info['query'] .= ($url_info['query'] ? '&' : '') . 'SSOID=' . session_id();
- $redirect_url = sprintf('%s://%s%s%s%s', $url_info['scheme'], $url_info['host'], $url_info['port'] ? (':' . $url_info['port']) : '', $url_info['path'], ($url_info['query'] ? ('?' . $url_info['query']) : ''));
- header('Location:' . $redirect_url);
- return FALSE;
+ $sso_response = Rhymix\Framework\Security::encrypt(session_id());
+ header('Location: ' . Rhymix\Framework\URL::modifyURL($sso_request, array('sso_response' => $sso_response)));
+ return false;
}
// Step 3: back at the origin site, set session ID to be the same as the default site
- if($default_url !== $current_site && self::get('SSOID'))
+ if($default_url !== $current_site && self::get('sso_response'))
{
- // Check that the session ID was given by the default site (to prevent session fixation CSRF)
+ // Check SSO response
+ $sso_response = Rhymix\Framework\Security::decrypt(self::get('sso_response'));
+ if ($sso_response === false)
+ {
+ self::displayErrorPage('SSO Error', 'Invalid SSO Response', 400);
+ return false;
+ }
+
+ // Check that the response was given by the default site (to prevent session fixation CSRF)
if(isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $default_url) !== 0)
{
- htmlHeader();
- echo self::getLang("msg_invalid_request");
- htmlFooter();
- return FALSE;
+ self::displayErrorPage('SSO Error', 'Invalid SSO Response', 400);
+ return false;
}
// Set session ID
- setcookie(session_name(), self::get('SSOID'));
+ setcookie(session_name(), $sso_response);
// Finally, redirect to the originally requested URL
- $url_info = parse_url(self::getRequestUrl());
- $url_info['query'] = preg_replace('/(^|\b)SSOID=([^&?]+)/', '', $url_info['query']);
- $redirect_url = sprintf('%s://%s%s%s%s', $url_info['scheme'], $url_info['host'], $url_info['port'] ? (':' . $url_info['port']) : '', $url_info['path'], ($url_info['query'] ? ('?' . $url_info['query']) : ''));
- header('Location:' . $redirect_url);
- return FALSE;
+ header('Location: ' . Rhymix\Framework\URL::getCurrentURL(array('sso_response' => null)));
+ return false;
}
// If none of the conditions above apply, proceed normally
@@ -1058,7 +1068,11 @@ class Context
*/
public static function convertEncodingStr($str)
{
- if(!$str) return null;
+ if (!$str || utf8_check($str))
+ {
+ return $str;
+ }
+
$obj = new stdClass;
$obj->str = $str;
$obj = self::convertEncoding($obj);
@@ -1073,15 +1087,7 @@ class Context
*/
public static function encodeIdna($domain)
{
- if(function_exists('idn_to_ascii'))
- {
- return idn_to_ascii($domain);
- }
- else
- {
- $encoder = new TrueBV\Punycode();
- return $encoder->encode($domain);
- }
+ return Rhymix\Framework\URL::encodeIdna($domain);
}
/**
@@ -1092,15 +1098,7 @@ class Context
*/
public static function decodeIdna($domain)
{
- if(function_exists('idn_to_utf8'))
- {
- return idn_to_utf8($domain);
- }
- else
- {
- $decoder = new TrueBV\Punycode();
- return $decoder->decode($domain);
- }
+ return Rhymix\Framework\URL::decodeIdna($domain);
}
/**
@@ -1283,11 +1281,15 @@ class Context
}
$xml = $GLOBALS['HTTP_RAW_POST_DATA'];
- if(Security::detectingXEE($xml))
+ if(!Rhymix\Framework\Security::checkXEE($xml))
{
header("HTTP/1.0 400 Bad Request");
exit;
}
+ if(function_exists('libxml_disable_entity_loader'))
+ {
+ libxml_disable_entity_loader(true);
+ }
$oXml = new XmlParser();
$xml_obj = $oXml->parse($xml);
@@ -1363,10 +1365,9 @@ class Context
* @see Cast variables, such as _srl, page, and cpage, into interger
* @param string $key Variable key
* @param string $val Variable value
- * @param string $do_stripslashes Whether to strip slashes
* @return mixed filtered value. Type are string or array
*/
- public function _filterRequestVar($key, $val, $do_stripslashes = 1)
+ public function _filterRequestVar($key, $val)
{
if(!($isArray = is_array($val)))
{
@@ -1392,19 +1393,6 @@ class Context
else
{
$result[$k] = $v;
-
- if($do_stripslashes && version_compare(PHP_VERSION, '5.4.0', '<') && get_magic_quotes_gpc())
- {
- if (is_array($result[$k]))
- {
- array_walk_recursive($result[$k], function(&$val) { $val = stripslashes($val); });
- }
- else
- {
- $result[$k] = stripslashes($result[$k]);
- }
- }
-
if(is_array($result[$k]))
{
array_walk_recursive($result[$k], function(&$val) { $val = trim($val); });
@@ -1490,13 +1478,9 @@ class Context
}
// Allow if the current user is in the list of allowed IPs.
- $allowed_list = config('lock.allow');
- foreach ($allowed_list as $allowed_ip)
+ if (Rhymix\Framework\Filters\IpFilter::inRanges(RX_CLIENT_IP, config('lock.allow')))
{
- if (Rhymix\Framework\IpFilter::inRange(RX_CLIENT_IP, $allowed_ip))
- {
- return;
- }
+ return;
}
// Set headers and constants for backward compatibility.
diff --git a/classes/db/DB.class.php b/classes/db/DB.class.php
index fbc205adc..e9f75a05f 100644
--- a/classes/db/DB.class.php
+++ b/classes/db/DB.class.php
@@ -24,7 +24,6 @@ class DB
*/
protected static $priority_dbms = array(
'mysqli' => 6,
- 'mysql' => 4,
'cubrid' => 2,
'mssql' => 1
);
@@ -271,9 +270,13 @@ class DB
// after creating instance of class, check is supported
foreach ($supported_list as $db_type)
{
+ if (strncasecmp($db_type, 'mysql', 5) === 0 && strtolower($db_type) !== 'mysqli')
+ {
+ continue;
+ }
$class_name = sprintf("DB%s%s", strtoupper(substr($db_type, 0, 1)), strtolower(substr($db_type, 1)));
$class_file = sprintf(_XE_PATH_ . "classes/db/%s.class.php", $class_name);
- if(!file_exists($class_file) || stripos($class_file, '_innodb') !== false)
+ if (!file_exists($class_file))
{
continue;
}
diff --git a/classes/db/DBCubrid.class.php b/classes/db/DBCubrid.class.php
index 9059b99ce..1491eb73b 100644
--- a/classes/db/DBCubrid.class.php
+++ b/classes/db/DBCubrid.class.php
@@ -81,9 +81,14 @@ class DBCubrid extends DB
define('__CUBRID_VERSION__', $cubrid_version);
}
- if(__CUBRID_VERSION__ >= '8.4.0')
- cubrid_set_autocommit($result, CUBRID_AUTOCOMMIT_TRUE);
-
+ if(version_compare(__CUBRID_VERSION__, '9.0', '<'))
+ {
+ $this->setError(-1, 'Rhymix requires CUBRID 9.0 or later. Current CUBRID version is ' . __CUBRID_VERSION__);
+ return;
+ }
+
+ cubrid_set_autocommit($result, CUBRID_AUTOCOMMIT_TRUE);
+
return $result;
}
diff --git a/classes/db/DBMssql.class.php b/classes/db/DBMssql.class.php
index c6d150b8c..a1473ac73 100644
--- a/classes/db/DBMssql.class.php
+++ b/classes/db/DBMssql.class.php
@@ -71,6 +71,16 @@ class DBMssql extends DB
$this->setError(-1, 'database connect fail' . PHP_EOL . $errors);
return;
}
+
+ $server_info = sqlsrv_server_info($result);
+ $server_version = $server_info['SQLServerVersion'];
+ if ($server_version && version_compare($server_version, '10', '<'))
+ {
+ $this->setError(-1, 'Rhymix requires Microsoft SQL Server 2008 or later. Current version is ' . $server_version);
+ return;
+ }
+
+
return $result;
}
diff --git a/classes/db/DBMysql.class.php b/classes/db/DBMysql.class.php
index 1b5264ed8..27e16b315 100644
--- a/classes/db/DBMysql.class.php
+++ b/classes/db/DBMysql.class.php
@@ -67,7 +67,8 @@ class DBMysql extends DB
$result = @mysql_connect($connection['host'], $connection['user'], $connection['pass']);
if(!$result)
{
- exit('Unable to connect to DB.');
+ $this->setError(-1, 'Unable to connect to DB.');
+ return;
}
if(mysql_error())
@@ -76,10 +77,10 @@ class DBMysql extends DB
return;
}
- // Error appears if the version is lower than 4.1.13
- if(version_compare(mysql_get_server_info($result), '4.1.13', '<'))
+ // Error appears if the version is lower than 5.0.7
+ if(version_compare(mysql_get_server_info($result), '5.0.7', '<'))
{
- $this->setError(-1, 'Rhymix requires MySQL 4.1.13 or later. Current MySQL version is ' . mysql_get_server_info());
+ $this->setError(-1, 'Rhymix requires MySQL 5.0.7 or later. Current MySQL version is ' . mysql_get_server_info());
return;
}
@@ -164,7 +165,8 @@ class DBMysql extends DB
{
if(!$connection)
{
- exit('Rhymix cannot handle DB connection.');
+ $this->setError(-1, 'Unable to connect to DB.');
+ return false;
}
// Run the query statement
$result = @mysql_query($query, $connection);
diff --git a/classes/db/DBMysqli.class.php b/classes/db/DBMysqli.class.php
index 8c425be45..ef8f845ba 100644
--- a/classes/db/DBMysqli.class.php
+++ b/classes/db/DBMysqli.class.php
@@ -80,8 +80,8 @@ class DBMysqli extends DBMysql
{
if ($connection === null)
{
- debug_print_backtrace();
- exit;
+ $this->setError(-1, 'Unable to connect to DB.');
+ return false;
}
if($this->use_prepared_statements == 'Y')
{
diff --git a/classes/display/DisplayHandler.class.php b/classes/display/DisplayHandler.class.php
index 8ed67bf13..ebbdbb3e4 100644
--- a/classes/display/DisplayHandler.class.php
+++ b/classes/display/DisplayHandler.class.php
@@ -12,6 +12,7 @@
class DisplayHandler extends Handler
{
public static $response_size = 0;
+ public static $debug_printed = 0;
var $content_size = 0; // /< The size of displaying contents
var $gz_enabled = FALSE; // / = 2 && substr_compare($source, './', 0, 2) === 0)
- {
- return _XE_PATH_ . substr($source, 2);
- }
-
- return $source;
+ return (strncmp($source, './', 2) === 0) ? (\RX_BASEDIR . substr($source, 2)) : $source;
}
/**
@@ -33,64 +27,11 @@ class FileHandler
* @param string $source_dir Path of source directory
* @param string $target_dir Path of target dir
* @param string $filter Regex to filter files. If file matches this regex, the file is not copied.
- * @param string $type If set as 'force'. Even if the file exists in target, the file is copied.
* @return void
*/
- public static function copyDir($source_dir, $target_dir, $filter = null, $type = null)
+ public static function copyDir($source_dir, $target_dir, $filter = null)
{
- $source_dir = self::getRealPath($source_dir);
- $target_dir = self::getRealPath($target_dir);
- if(!is_dir($source_dir))
- {
- return FALSE;
- }
-
- // generate when no target exists
- self::makeDir($target_dir);
-
- if(substr($source_dir, -1) != DIRECTORY_SEPARATOR)
- {
- $source_dir .= DIRECTORY_SEPARATOR;
- }
-
- if(substr($target_dir, -1) != DIRECTORY_SEPARATOR)
- {
- $target_dir .= DIRECTORY_SEPARATOR;
- }
-
- $oDir = dir($source_dir);
- while($file = $oDir->read())
- {
- if($file{0} == '.')
- {
- continue;
- }
-
- if($filter && preg_match($filter, $file))
- {
- continue;
- }
-
- if(is_dir($source_dir . $file))
- {
- self::copyDir($source_dir . $file, $target_dir . $file, $type);
- }
- else
- {
- if($type == 'force')
- {
- @unlink($target_dir . $file);
- }
- else
- {
- if(!file_exists($target_dir . $file))
- {
- @copy($source_dir . $file, $target_dir . $file);
- }
- }
- }
- }
- $oDir->close();
+ return Rhymix\Framework\Storage::copyDirectory(self::getRealPath($source_dir), self::getRealPath($target_dir), $filter);
}
/**
@@ -104,18 +45,7 @@ class FileHandler
public static function copyFile($source, $target, $force = 'Y')
{
setlocale(LC_CTYPE, 'en_US.UTF8', 'ko_KR.UTF8');
- $source = self::getRealPath($source);
- $target_dir = self::getRealPath(dirname($target));
- $target = basename($target);
-
- self::makeDir($target_dir);
-
- if($force == 'Y')
- {
- @unlink($target_dir . DIRECTORY_SEPARATOR . $target);
- }
-
- @copy($source, $target_dir . DIRECTORY_SEPARATOR . $target);
+ return Rhymix\Framework\Storage::copy(self::getRealPath($source), self::getRealPath($target));
}
/**
@@ -126,12 +56,7 @@ class FileHandler
*/
public static function readFile($filename)
{
- if(($filename = self::exists($filename)) === FALSE || filesize($filename) < 1)
- {
- return;
- }
-
- return @file_get_contents($filename);
+ return Rhymix\Framework\Storage::read(self::getRealPath($filename));
}
/**
@@ -144,22 +69,7 @@ class FileHandler
*/
public static function writeFile($filename, $buff, $mode = "w")
{
- $filename = self::getRealPath($filename);
- $pathinfo = pathinfo($filename);
- self::makeDir($pathinfo['dirname']);
-
- $flags = 0;
- if(strtolower($mode) == 'a')
- {
- $flags = FILE_APPEND;
- }
-
- @file_put_contents($filename, $buff, $flags|LOCK_EX);
- @chmod($filename, 0644);
- if(function_exists('opcache_invalidate') && substr($filename, -4) === '.php')
- {
- @opcache_invalidate($filename, true);
- }
+ return Rhymix\Framework\Storage::write(self::getRealPath($filename), $buff, $mode);
}
/**
@@ -170,16 +80,7 @@ class FileHandler
*/
public static function removeFile($filename)
{
- if(($filename = self::exists($filename)) === false)
- {
- return false;
- }
- $status = @unlink($filename);
- if(function_exists('opcache_invalidate') && substr($filename, -4) === '.php')
- {
- @opcache_invalidate($filename, true);
- }
- return $status;
+ return Rhymix\Framework\Storage::delete(self::getRealPath($filename));
}
/**
@@ -193,7 +94,7 @@ class FileHandler
*/
public static function rename($source, $target)
{
- return @rename(self::getRealPath($source), self::getRealPath($target));
+ return Rhymix\Framework\Storage::move(self::getRealPath($source), self::getRealPath($target));
}
/**
@@ -205,12 +106,7 @@ class FileHandler
*/
public static function moveFile($source, $target)
{
- if(($source = self::exists($source)) !== FALSE)
- {
- self::removeFile($target);
- return self::rename($source, $target);
- }
- return FALSE;
+ return Rhymix\Framework\Storage::move(self::getRealPath($source), self::getRealPath($target));
}
/**
@@ -224,7 +120,7 @@ class FileHandler
*/
public static function moveDir($source_dir, $target_dir)
{
- self::rename($source_dir, $target_dir);
+ return Rhymix\Framework\Storage::move(self::getRealPath($source_dir), self::getRealPath($target_dir));
}
/**
@@ -240,45 +136,31 @@ class FileHandler
*/
public static function readDir($path, $filter = '', $to_lower = FALSE, $concat_prefix = FALSE)
{
- $path = self::getRealPath($path);
+ $list = Rhymix\Framework\Storage::readDirectory(self::getRealPath($path), $concat_prefix, true, false);
+ if (!$list)
+ {
+ return array();
+ }
+
$output = array();
-
- if(substr($path, -1) != '/')
+ foreach ($list as $filename)
{
- $path .= '/';
- }
-
- if(!is_dir($path))
- {
- return $output;
- }
-
- $files = scandir($path);
- foreach($files as $file)
- {
- if($file{0} == '.' || ($filter && !preg_match($filter, $file)))
+ $filename = str_replace(array('/\\', '//'), '/', $filename);
+ $basename = $concat_prefix ? basename($filename) : $filename;
+ if ($basename[0] === '.' || ($filter && !preg_match($filter, $basename)))
{
continue;
}
-
- if($to_lower)
+ if ($to_lower)
{
- $file = strtolower($file);
+ $filename = strtolower($filename);
}
-
if($filter)
{
- $file = preg_replace($filter, '$1', $file);
+ $filename = preg_replace($filter, '$1', $filename);
}
-
- if($concat_prefix)
- {
- $file = sprintf('%s%s', str_replace(_XE_PATH_, '', $path), $file);
- }
-
- $output[] = str_replace(array('/\\', '//'), '/', $file);
+ $output[] = $filename;
}
-
return $output;
}
@@ -292,16 +174,12 @@ class FileHandler
*/
public static function makeDir($path_string)
{
- if(self::exists($path_string) !== FALSE)
+ if (!ini_get('safe_mode'))
{
- return TRUE;
- }
-
- if(!ini_get('safe_mode'))
- {
- @mkdir($path_string, 0755, TRUE);
- @chmod($path_string, 0755);
+ $path = self::getRealPath($path_string);
+ return Rhymix\Framework\Storage::isDirectory($path) || Rhymix\Framework\Storage::createDirectory($path);
}
+
// if safe_mode is on, use FTP
else
{
@@ -372,37 +250,7 @@ class FileHandler
*/
public static function removeDir($path)
{
- if(($path = self::isDir($path)) === FALSE)
- {
- return;
- }
-
- if(self::isDir($path))
- {
- $files = array_diff(scandir($path), array('..', '.'));
-
- foreach($files as $file)
- {
- if(($target = self::getRealPath($path . DIRECTORY_SEPARATOR . $file)) === FALSE)
- {
- continue;
- }
-
- if(is_dir($target))
- {
- self::removeDir($target);
- }
- else
- {
- unlink($target);
- }
- }
- rmdir($path);
- }
- else
- {
- unlink($path);
- }
+ return Rhymix\Framework\Storage::deleteDirectory(self::getRealPath($path));
}
/**
@@ -413,27 +261,14 @@ class FileHandler
*/
public static function removeBlankDir($path)
{
- if(($path = self::isDir($path)) === FALSE)
+ $path = self::getRealPath($path);
+ if (Rhymix\Framework\Storage::isEmptyDirectory($path))
{
- return;
+ return Rhymix\Framework\Storage::deleteDirectory($path);
}
-
- $files = array_diff(scandir($path), array('..', '.'));
-
- if(count($files) < 1)
+ else
{
- rmdir($path);
- return;
- }
-
- foreach($files as $file)
- {
- if(($target = self::isDir($path . DIRECTORY_SEPARATOR . $file)) === FALSE)
- {
- continue;
- }
-
- self::removeBlankDir($target);
+ return false;
}
}
@@ -447,37 +282,7 @@ class FileHandler
*/
public static function removeFilesInDir($path)
{
- if(($path = self::getRealPath($path)) === FALSE)
- {
- return;
- }
-
- if(is_dir($path))
- {
- $files = array_diff(scandir($path), array('..', '.'));
-
- foreach($files as $file)
- {
- if(($target = self::getRealPath($path . DIRECTORY_SEPARATOR . $file)) === FALSE)
- {
- continue;
- }
-
- if(is_dir($target))
- {
- self::removeFilesInDir($target);
- }
- else
- {
- unlink($target);
- }
- }
- }
- else
- {
- if(self::exists($path)) unlink($path);
- }
-
+ return Rhymix\Framework\Storage::deleteDirectory(self::getRealPath($path), false);
}
/**
@@ -584,7 +389,14 @@ class FileHandler
if($response->success)
{
- return $response->body;
+ if (isset($request_config['filename']))
+ {
+ return true;
+ }
+ else
+ {
+ return $response->body;
+ }
}
else
{
@@ -611,13 +423,9 @@ class FileHandler
*/
public static function getRemoteFile($url, $target_filename, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array(), $request_config = array())
{
- if(!($body = self::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers,$cookies,$post_data,$request_config)))
- {
- return FALSE;
- }
-
- self::writeFile($target_filename, $body);
- return TRUE;
+ $request_config['filename'] = $target_filename;
+ $success = self::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers, $cookies, $post_data, $request_config);
+ return $success ? true : false;
}
/**
@@ -658,12 +466,17 @@ class FileHandler
$channels = 6; //for png
}
$memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64 ) * $TWEAKFACTOR);
- $availableMemory = self::returnBytes(ini_get('memory_limit')) - memory_get_usage();
+ $memoryLimit = self::returnBytes(ini_get('memory_limit'));
+ if($memoryLimit < 0)
+ {
+ return true;
+ }
+ $availableMemory = $memoryLimit - memory_get_usage();
if($availableMemory < $memoryNeeded)
{
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
/**
@@ -882,19 +695,13 @@ class FileHandler
*/
public static function readIniFile($filename)
{
- if(($filename = self::exists($filename)) === FALSE)
+ if(!Rhymix\Framework\Storage::isReadable($filename))
{
- return FALSE;
- }
- $arr = parse_ini_file($filename, TRUE);
- if(is_array($arr) && count($arr) > 0)
- {
- return $arr;
- }
- else
- {
- return array();
+ return false;
}
+
+ $arr = parse_ini_file($filename, true);
+ return is_array($arr) ? $arr : array();
}
/**
@@ -966,11 +773,9 @@ class FileHandler
*/
public static function openFile($filename, $mode)
{
- $pathinfo = pathinfo($filename);
- self::makeDir($pathinfo['dirname']);
-
- require_once("FileObject.class.php");
- return new FileObject($filename, $mode);
+ $filename = self::getRealPath($filename);
+ Rhymix\Framework\Storage::createDirectory(dirname($filename));
+ return new FileObject($filename, $mode);
}
/**
@@ -981,7 +786,7 @@ class FileHandler
*/
public static function hasContent($filename)
{
- return (is_readable($filename) && (filesize($filename) > 0));
+ return Rhymix\Framework\Storage::getSize(self::getRealPath($filename)) > 0;
}
/**
@@ -993,7 +798,7 @@ class FileHandler
public static function exists($filename)
{
$filename = self::getRealPath($filename);
- return file_exists($filename) ? $filename : FALSE;
+ return Rhymix\Framework\Storage::exists($filename) ? $filename : false;
}
/**
@@ -1005,7 +810,7 @@ class FileHandler
public static function isDir($path)
{
$path = self::getRealPath($path);
- return is_dir($path) ? $path : FALSE;
+ return Rhymix\Framework\Storage::isDirectory($path) ? $path : false;
}
/**
@@ -1017,22 +822,7 @@ class FileHandler
public static function isWritableDir($path)
{
$path = self::getRealPath($path);
- if(is_dir($path)==FALSE)
- {
- return FALSE;
- }
-
- $checkFile = $path . '/_CheckWritableDir';
-
- $fp = fopen($checkFile, 'w');
- if(!is_resource($fp))
- {
- return FALSE;
- }
- fclose($fp);
-
- self::removeFile($checkFile);
- return TRUE;
+ return Rhymix\Framework\Storage::isDirectory($path) && Rhymix\Framework\Storage::isWritable($path);
}
}
diff --git a/classes/mail/Mail.class.php b/classes/mail/Mail.class.php
index c2d9725db..465e623be 100644
--- a/classes/mail/Mail.class.php
+++ b/classes/mail/Mail.class.php
@@ -460,81 +460,7 @@ class Mail
*/
function returnMIMEType($filename)
{
- preg_match("|\.([a-z0-9]{2,4})$|i", $filename, $fileSuffix);
- switch(strtolower($fileSuffix[1]))
- {
- case "js" :
- return "application/x-javascript";
- case "json" :
- return "application/json";
- case "jpg" :
- case "jpeg" :
- case "jpe" :
- return "image/jpg";
- case "png" :
- case "gif" :
- case "bmp" :
- case "tiff" :
- return "image/" . strtolower($fileSuffix[1]);
- case "css" :
- return "text/css";
- case "xml" :
- return "application/xml";
- case "doc" :
- case "docx" :
- return "application/msword";
- case "xls" :
- case "xlt" :
- case "xlm" :
- case "xld" :
- case "xla" :
- case "xlc" :
- case "xlw" :
- case "xll" :
- return "application/vnd.ms-excel";
- case "ppt" :
- case "pps" :
- return "application/vnd.ms-powerpoint";
- case "rtf" :
- return "application/rtf";
- case "pdf" :
- return "application/pdf";
- case "html" :
- case "htm" :
- case "php" :
- return "text/html";
- case "txt" :
- return "text/plain";
- case "mpeg" :
- case "mpg" :
- case "mpe" :
- return "video/mpeg";
- case "mp3" :
- return "audio/mpeg3";
- case "wav" :
- return "audio/wav";
- case "aiff" :
- case "aif" :
- return "audio/aiff";
- case "avi" :
- return "video/msvideo";
- case "wmv" :
- return "video/x-ms-wmv";
- case "mov" :
- return "video/quicktime";
- case "zip" :
- return "application/zip";
- case "tar" :
- return "application/x-tar";
- case "swf" :
- return "application/x-shockwave-flash";
- default :
- if(function_exists("mime_content_type"))
- {
- $fileSuffix = mime_content_type($filename);
- }
- return "unknown/" . trim($fileSuffix[0], ".");
- }
+ return Rhymix\Framework\MIME::getTypeByFilename($filename);
}
}
diff --git a/classes/mobile/Mobile.class.php b/classes/mobile/Mobile.class.php
index 5b3528621..65b4276e3 100644
--- a/classes/mobile/Mobile.class.php
+++ b/classes/mobile/Mobile.class.php
@@ -55,9 +55,6 @@ class Mobile
return $this->ismobile = false;
}
- $xe_web_path = Context::pathToUrl(_XE_PATH_);
-
- // default setting. if there is cookie for a device, XE do not have to check if it is mobile or not and it will enhance performace of the server.
$this->ismobile = FALSE;
$m = Context::get('m');
@@ -87,28 +84,14 @@ class Mobile
}
else
{
- $this->ismobile = FALSE;
- setcookie("mobile", FALSE, 0, $xe_web_path);
- setcookie("user-agent", FALSE, 0, $xe_web_path);
- if(!self::isMobilePadCheckByAgent() && self::isMobileCheckByAgent())
- {
- $this->ismobile = TRUE;
- }
+ setcookie("mobile", FALSE, 0, RX_BASEURL);
+ setcookie("user-agent", FALSE, 0, RX_BASEURL);
+ $this->ismobile = Rhymix\Framework\UA::isMobile() && !Rhymix\Framework\UA::isTablet();
}
}
else
{
- if(self::isMobilePadCheckByAgent())
- {
- $this->ismobile = FALSE;
- }
- else
- {
- if(self::isMobileCheckByAgent())
- {
- $this->ismobile = TRUE;
- }
- }
+ $this->ismobile = Rhymix\Framework\UA::isMobile() && !Rhymix\Framework\UA::isTablet();
}
if($this->ismobile !== NULL)
@@ -118,18 +101,18 @@ class Mobile
if($_COOKIE['mobile'] != 'true')
{
$_COOKIE['mobile'] = 'true';
- setcookie("mobile", 'true', 0, $xe_web_path);
+ setcookie("mobile", 'true', 0, RX_BASEURL);
}
}
elseif(isset($_COOKIE['mobile']) && $_COOKIE['mobile'] != 'false')
{
$_COOKIE['mobile'] = 'false';
- setcookie("mobile", 'false', 0, $xe_web_path);
+ setcookie("mobile", 'false', 0, RX_BASEURL);
}
if(isset($_COOKIE['mobile']) && $_COOKIE['user-agent'] != md5($_SERVER['HTTP_USER_AGENT']))
{
- setcookie("user-agent", md5($_SERVER['HTTP_USER_AGENT']), 0, $xe_web_path);
+ setcookie("user-agent", md5($_SERVER['HTTP_USER_AGENT']), 0, RX_BASEURL);
}
}
@@ -143,31 +126,7 @@ class Mobile
*/
public static function isMobileCheckByAgent()
{
- static $UACheck;
- if(isset($UACheck))
- {
- return $UACheck;
- }
-
- $oMobile = Mobile::getInstance();
- $mobileAgent = array('iPod', 'iPhone', 'Android', 'BlackBerry', 'SymbianOS', 'Bada', 'Tizen', 'Kindle', 'Wii', 'SCH-', 'SPH-', 'CANU-', 'Windows Phone', 'Windows CE', 'POLARIS', 'Palm', 'Dorothy Browser', 'Mobile', 'Opera Mobi', 'Opera Mini', 'Minimo', 'AvantGo', 'NetFront', 'Nokia', 'LGPlayer', 'SonyEricsson', 'HTC');
-
- if($oMobile->isMobilePadCheckByAgent())
- {
- $UACheck = TRUE;
- return TRUE;
- }
-
- foreach($mobileAgent as $agent)
- {
- if(stripos($_SERVER['HTTP_USER_AGENT'], $agent) !== FALSE)
- {
- $UACheck = TRUE;
- return TRUE;
- }
- }
- $UACheck = FALSE;
- return FALSE;
+ return Rhymix\Framework\UA::isMobile();
}
/**
@@ -177,45 +136,7 @@ class Mobile
*/
public static function isMobilePadCheckByAgent()
{
- static $UACheck;
- if(isset($UACheck))
- {
- return $UACheck;
- }
- $padAgent = array('iPad', 'Android', 'webOS', 'hp-tablet', 'PlayBook');
-
- // Android with 'Mobile' string is not a tablet-like device, and 'Andoroid' without 'Mobile' string is a tablet-like device.
- // $exceptionAgent[0] contains exception agents for all exceptions.
- $exceptionAgent = array(0 => array('Opera Mini', 'Opera Mobi'), 'Android' => 'Mobile');
-
- foreach($padAgent as $agent)
- {
- if(strpos($_SERVER['HTTP_USER_AGENT'], $agent) !== FALSE)
- {
- if(!isset($exceptionAgent[$agent]))
- {
- $UACheck = TRUE;
- return TRUE;
- }
- elseif(strpos($_SERVER['HTTP_USER_AGENT'], $exceptionAgent[$agent]) === FALSE)
- {
- // If the agent is the Android, that can be either tablet and mobile phone.
- foreach($exceptionAgent[0] as $val)
- {
- if(strpos($_SERVER['HTTP_USER_AGENT'], $val) !== FALSE)
- {
- $UACheck = FALSE;
- return FALSE;
- }
- }
- $UACheck = TRUE;
- return TRUE;
- }
- }
- }
-
- $UACheck = FALSE;
- return FALSE;
+ return Rhymix\Framework\UA::isTablet();
}
/**
diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php
index 0dafb4390..c433ccbf3 100644
--- a/classes/module/ModuleHandler.class.php
+++ b/classes/module/ModuleHandler.class.php
@@ -96,10 +96,13 @@ class ModuleHandler extends Handler
{
if(Context::get('_use_ssl') == 'optional' && Context::isExistsSSLAction($this->act) && !RX_SSL)
{
- if(Context::get('_https_port')!=null) {
- header('location:https://' . $_SERVER['HTTP_HOST'] . ':' . Context::get('_https_port') . $_SERVER['REQUEST_URI']);
- } else {
- header('location:https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
+ if(Context::get('_https_port') != null)
+ {
+ header('location: https://' . $_SERVER['HTTP_HOST'] . ':' . Context::get('_https_port') . $_SERVER['REQUEST_URI']);
+ }
+ else
+ {
+ header('location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
return;
}
@@ -165,12 +168,21 @@ class ModuleHandler extends Handler
// Get module's information based on document_srl, if it's specified
if($this->document_srl)
{
-
$module_info = $oModuleModel->getModuleInfoByDocumentSrl($this->document_srl);
+
// If the document does not exist, remove document_srl
if(!$module_info)
{
- unset($this->document_srl);
+ if(Context::getRequestMethod() == 'GET')
+ {
+ $this->error = 'The document does not exist';
+ $this->httpStatusCode = '404';
+ return true;
+ }
+ else
+ {
+ unset($this->document_srl);
+ }
}
else
{
@@ -178,19 +190,17 @@ class ModuleHandler extends Handler
// if mids are not matching, set it as the document's mid
if(!$this->mid || ($this->mid != $module_info->mid))
{
-
if(Context::getRequestMethod() == 'GET')
{
- $this->mid = $module_info->mid;
- header('location:' . getNotEncodedSiteUrl($site_module_info->domain, 'mid', $this->mid, 'document_srl', $this->document_srl));
- return FALSE;
+ Context::setCacheControl(0);
+ header('location: ' . getNotEncodedSiteUrl($site_module_info->domain, 'mid', $module_info->mid, 'document_srl', $this->document_srl), true, 301);
+ return false;
}
else
{
$this->mid = $module_info->mid;
Context::set('mid', $this->mid);
}
-
}
// if requested module is different from one of the document, remove the module information retrieved based on the document number
if($this->module && $module_info->module != $this->module)
@@ -198,7 +208,6 @@ class ModuleHandler extends Handler
unset($module_info);
}
}
-
}
// If module_info is not set yet, and there exists mid information, get module information based on the mid
@@ -211,9 +220,10 @@ class ModuleHandler extends Handler
// redirect, if module_site_srl and site_srl are different
if(!$this->module && !$module_info && $site_module_info->site_srl == 0 && $site_module_info->module_site_srl > 0)
{
+ Context::setCacheControl(0);
$site_info = $oModuleModel->getSiteInfo($site_module_info->module_site_srl);
- header("location:" . getNotEncodedSiteUrl($site_info->domain, 'mid', $site_module_info->mid));
- return FALSE;
+ header('location: ' . getNotEncodedSiteUrl($site_info->domain, 'mid', $site_module_info->mid), true, 301);
+ return false;
}
// If module_info is not set still, and $module does not exist, find the default module
@@ -228,7 +238,7 @@ class ModuleHandler extends Handler
}
// redirect, if site_srl of module_info is different from one of site's module_info
- if($module_info && $module_info->site_srl != $site_module_info->site_srl && !isCrawler())
+ if($module_info && $module_info->site_srl != $site_module_info->site_srl && !Rhymix\Framework\UA::isRobot())
{
// If the module is of virtual site
if($module_info->site_srl)
@@ -241,10 +251,20 @@ class ModuleHandler extends Handler
{
$redirect_url = getNotEncodedSiteUrl(Context::getDefaultUrl(), 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry'));
}
- header("Location: $redirect_url");
- return FALSE;
+
+ Context::setCacheControl(0);
+ header("Location: $redirect_url", true, 301);
+ return false;
}
-
+
+ // redirect, if site start module
+ if(isset($_GET['mid']) && $_GET['mid'] === $site_module_info->mid && !$this->act && !$this->module && !$this->document_srl)
+ {
+ Context::setCacheControl(0);
+ header('location: ' . getNotEncodedSiteUrl($site_module_info->domain), true, 301);
+ return false;
+ }
+
// If module info was set, retrieve variables from the module information
if($module_info)
{
@@ -290,6 +310,7 @@ class ModuleHandler extends Handler
{
$this->error = 'msg_module_is_not_exists';
$this->httpStatusCode = '404';
+ return true;
}
// If mid exists, set mid into context
@@ -303,13 +324,13 @@ class ModuleHandler extends Handler
if(!$output->toBool())
{
$this->error = $output->getMessage();
- return TRUE;
+ return true;
}
// Set current module info into context
Context::set('current_module_info', $this->module_info);
- return TRUE;
+ return true;
}
/**
@@ -465,7 +486,6 @@ class ModuleHandler extends Handler
// If there is no such action in the module object
if(!isset($xml_info->action->{$this->act}) || !method_exists($oModule, $this->act))
{
-
if(!Context::isInstalled())
{
self::_setInputErrorToContext();
@@ -760,10 +780,6 @@ class ModuleHandler extends Handler
}
self::_setInputValueToSession();
}
- else
- {
-
- }
if($error != 0)
{
@@ -884,7 +900,7 @@ class ModuleHandler extends Handler
if($_SESSION['XE_VALIDATOR_RETURN_URL'])
{
- header('location:' . $_SESSION['XE_VALIDATOR_RETURN_URL']);
+ header('location: ' . $_SESSION['XE_VALIDATOR_RETURN_URL']);
return;
}
@@ -939,13 +955,11 @@ class ModuleHandler extends Handler
if($layout_srl && !$oModule->getLayoutFile())
{
-
// If layout_srl exists, get information of the layout, and set the location of layout_path/ layout_file
$oLayoutModel = getModel('layout');
$layout_info = $oLayoutModel->getLayout($layout_srl);
if($layout_info)
{
-
// Input extra_vars into $layout_info
if($layout_info->extra_var_count)
{
@@ -1283,6 +1297,8 @@ class ModuleHandler extends Handler
$statusMessageList = array(
'100' => 'Continue',
'101' => 'Switching Protocols',
+ '102' => 'Processing',
+ '103' => 'Checkpoint',
'200' => 'OK',
'201' => 'Created',
'202' => 'Accepted',
@@ -1290,13 +1306,18 @@ class ModuleHandler extends Handler
'204' => 'No Content',
'205' => 'Reset Content',
'206' => 'Partial Content',
+ '207' => 'Multi-Status',
+ '208' => 'Already Reported',
+ '226' => 'IM Used',
'300' => 'Multiple Choices',
'301' => 'Moved Permanently',
'302' => 'Found',
'303' => 'See Other',
'304' => 'Not Modified',
'305' => 'Use Proxy',
+ '306' => 'Switch Proxy',
'307' => 'Temporary Redirect',
+ '308' => 'Permanent Redirect',
'400' => 'Bad Request',
'401' => 'Unauthorized',
'402' => 'Payment Required',
@@ -1310,19 +1331,39 @@ class ModuleHandler extends Handler
'410' => 'Gone',
'411' => 'Length Required',
'412' => 'Precondition Failed',
- '413' => 'Request Entity Too Large',
- '414' => 'Request-URI Too Long',
+ '413' => 'Payload Too Large',
+ '414' => 'URI Too Long',
'415' => 'Unsupported Media Type',
- '416' => 'Requested Range Not Satisfiable',
+ '416' => 'Range Not Satisfiable',
'417' => 'Expectation Failed',
+ '418' => 'I\'m a teapot',
+ '420' => 'Enhance Your Calm',
+ '421' => 'Misdirected Request',
+ '422' => 'Unprocessable Entity',
+ '423' => 'Locked',
+ '424' => 'Failed Dependency',
+ '425' => 'Unordered Collection',
+ '426' => 'Upgrade Required',
+ '428' => 'Precondition Required',
+ '429' => 'Too Many Requests',
+ '431' => 'Request Header Fields Too Large',
+ '444' => 'No Response',
+ '449' => 'Retry With',
+ '451' => 'Unavailable For Legal Reasons',
'500' => 'Internal Server Error',
'501' => 'Not Implemented',
'502' => 'Bad Gateway',
'503' => 'Service Unavailable',
'504' => 'Gateway Timeout',
'505' => 'HTTP Version Not Supported',
+ '506' => 'Variant Also Negotiates',
+ '507' => 'Insufficient Storage',
+ '508' => 'Loop Detected',
+ '509' => 'Bandwidth Limit Exceeded',
+ '510' => 'Not Extended',
+ '511' => 'Network Authentication Required',
);
- $statusMessage = $statusMessageList[$code];
+ $statusMessage = $statusMessageList[strval($code)];
if(!$statusMessage)
{
$statusMessage = 'OK';
diff --git a/classes/security/EmbedFilter.class.php b/classes/security/EmbedFilter.class.php
index 2f90a753e..47d529b9f 100644
--- a/classes/security/EmbedFilter.class.php
+++ b/classes/security/EmbedFilter.class.php
@@ -3,313 +3,78 @@
class EmbedFilter
{
-
/**
- * allow script access list
+ * Deprecated properties
* @var array
*/
- var $allowscriptaccessList = array();
-
- /**
- * allow script access key
- * @var int
- */
- var $allowscriptaccessKey = 0;
- var $whiteUrlList = array();
- var $whiteIframeUrlList = array();
- var $mimeTypeList = array();
- var $extList = array();
- var $parser = NULL;
-
- /**
- * @constructor
- * @return void
- */
- function __construct()
- {
- $this->_makeWhiteDomainList();
- }
+ public $whiteUrlList = array();
+ public $whiteIframeUrlList = array();
+ public $mimeTypeList = array();
+ public $extList = array();
/**
* Return EmbedFilter object
- * This method for singleton
+ *
* @return EmbedFilter
*/
function getInstance()
{
- if(!isset($GLOBALS['__EMBEDFILTER_INSTANCE__']))
- {
- $GLOBALS['__EMBEDFILTER_INSTANCE__'] = new EmbedFilter();
- }
- return $GLOBALS['__EMBEDFILTER_INSTANCE__'];
+ return new self();
}
-
+
public function getWhiteUrlList()
{
- return $this->whiteUrlList;
+ return Rhymix\Framework\Filters\MediaFilter::getObjectWhitelist();
}
-
+
public function getWhiteIframeUrlList()
{
- return $this->whiteIframeUrlList;
+ return Rhymix\Framework\Filters\MediaFilter::getIframeWhitelist();
}
-
- /**
- * Check the content.
- * @return void
- */
- function check(&$content)
- {
- $content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content);
- $content = preg_replace_callback('/