Merge branch 'oembed' of https://github.com/fabrixxm/friendika into fabrixxm-oembed

This commit is contained in:
Friendika 2011-01-26 13:59:20 -08:00
revize 05350082fa
12 změnil soubory, kde provedl 178 přidání a 10 odebrání

Zobrazit soubor

@ -156,7 +156,8 @@ Current hooks:
'page_end' - called after HTML content functions have completed
$b is (string) HTML of content div
'jot_plugin' - add tools to jot toolbar
$b is (string) HTML for tool icon
*** = subject to change

10
addon/oembed/oembed.js Normal file
Zobrazit soubor

@ -0,0 +1,10 @@
function oembed(){
$("#oembed").toggleClass('hide');
}
function oembed_do(){
embed = "[embed]"+$('#oembed_url').attr('value')+"[/embed]";
tinyMCE.execCommand('mceInsertRawHTML',false,embed);
oembed();
}

101
addon/oembed/oembed.php Normal file
Zobrazit soubor

@ -0,0 +1,101 @@
<?php
/**
* oembed plugin
*
* oEmbed is a format for allowing an embedded representation of a URL on third party sites
* http://www.oembed.com/
*
*/
function oembed_install() {
register_hook('jot_tool', 'addon/oembed/oembed.php', 'oembed_hook_jot_tool');
register_hook('page_header', 'addon/oembed/oembed.php', 'oembed_hook_page_header');
register_hook('bbcode', 'addon/oembed/oembed.php', 'oembed_hook_bbcode');
}
function oembed_uninstall() {
unregister_hook('jot_tool', 'addon/oembed/oembed.php', 'oembed_hook_jot_tool');
unregister_hook('page_header', 'addon/oembed/oembed.php', 'oembed_hook_page_header');
unregister_hook('bbcode', 'addon/oembed/oembed.php', 'oembed_hook_bbcode');
}
function oembed_hook_page_header($a, &$b){
$b .= '<script src="addon/oembed/oembed.js"></script>
<style>#oembed.hide { display: none }
#oembed {
display:block; position: absolute; width: 300px; height:200px;
background-color:#fff; color: #000;
border:2px solid #8888FF; padding: 1em;
top: 200px; left: 400px; z-index:2000;
}
#oembed_url { width: 100%; margin-bottom:3px;}
</style>';
$b .= '
<div id="oembed" class="hide"><input id="oembed_url">&nbsp;
<input type="button" value="Embed" onclick="oembed_do()" style="float:left;">
<a onclick="oembed(); return false;" style="float:right;"><img onmouseout="imgdull(this);" onmouseover="imgbright(this);" class="wall-item-delete-icon" src="images/b_drophide.gif" style="width: 16px; height: 16px;"></a>
<p style="clear:both">Paste a link from 5min.com, Amazon Product Image, blip.tv, Clikthrough, CollegeHumor Video,
Daily Show with Jon Stewart, Dailymotion, dotSUB.com, Flickr Photos, Funny or Die Video,
Google Video, Hulu, Kinomap, LiveJournal UserPic, Metacafe, National Film Board of Canada,
Phodroid Photos, Photobucket, Qik Video, Revision3, Scribd, SlideShare, TwitPic, Twitter Status,
Viddler Video, Vimeo, Wikipedia, Wordpress.com, XKCD Comic, YFrog, YouTube</p>
</div>
';
}
function oembed_hook_jot_tool($a, &$b) {
$b .= '
<div class="tool-wrapper" style="display: $visitor;" >
<img class="tool-link" src="addon/oembed/oembed.png" alt="Embed" title="Embed" onclick="oembed();" />
</div>
';
}
function oembed_replacecb($matches){
$embedurl=$matches[1];
$ourl = "http://oohembed.com/oohembed/?url=".urlencode($embedurl);
$txt = fetch_url($ourl);
$j = json_decode($txt);
$ret="<!-- oembed $embedurl -->";
switch ($j->type) {
case "video": {
if (isset($j->thumbnail_url)) {
$tw = (isset($j->thumbnail_width)) ? $j->thumbnail_width:200;
$th = (isset($j->thumbnail_height)) ? $j->thumbnail_height:180;
$ret = "<a href='#' onclick='this.innerHTML=unescape(\"".urlencode($j->html)."\").replace(/\+/g,\" \"); return false;' >";
$ret.= "<img width='$tw' height='$th' src='".$j->thumbnail_url."'>";
$ret.= "</a>";
} else {
$ret=$j->html;
}
$ret.="<br>";
}; break;
case "photo": {
$ret = "<img width='".$j->width."' height='".$j->height."' src='".$j->url."'>";
$ret.="<br>";
}; break;
case "link": {
//$ret = "<a href='".$embedurl."'>".$j->title."</a>";
}; break;
case "rich": {
// not so safe..
$ret = "<blockquote>".$j->html."</blockquote>";
}; break;
}
$embedlink = (isset($j->title))?$j->title:$embedurl;
$ret .= "<a href='$embedurl'>$embedlink</a>";
if (isset($j->author_name)) $ret.=" by ".$j->author_name;
if (isset($j->provider_name)) $ret.=" on ".$j->provider_name;
$ret.="<!-- /oembed $embedurl -->";
return $ret;
}
function oembed_hook_bbcode($a, &$text){
$text = preg_replace_callback("/\[embed\](.+?)\[\/embed\]/is", oembed_replacecb ,$text);
}
?>

binární
addon/oembed/oembed.png Normal file

Binární soubor nebyl zobrazen.

Za

Šířka:  |  Výška:  |  Velikost: 417 B

Zobrazit soubor

@ -79,6 +79,9 @@ function network_content(&$a, $update = 0) {
$celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
$jotplugins = "";
call_hooks('jot_tool', $jotplugins);
$o .= replace_macros($tpl,array(
'$return_path' => $a->cmd,
'$baseurl' => $a->get_baseurl(),
@ -87,7 +90,8 @@ function network_content(&$a, $update = 0) {
'$lockstate' => $lockstate,
'$acl' => populate_acl((($group) ? $group_acl : $a->user), $celeb),
'$bang' => (($group) ? '!' : ''),
'$profile_uid' => $_SESSION['uid']
'$profile_uid' => $_SESSION['uid'],
'$jotplugins' => $jotplugins
));

Zobrazit soubor

@ -134,6 +134,10 @@ function profile_content(&$a, $update = 0) {
$lockstate = 'lock';
else
$lockstate = 'unlock';
$jotplugins = "";
call_hooks('jot_tool', $jotplugins);
$o .= replace_macros($tpl,array(
'$baseurl' => $a->get_baseurl(),
'$defloc' => (($is_owner) ? $a->user['default-location'] : ''),
@ -142,7 +146,8 @@ function profile_content(&$a, $update = 0) {
'$lockstate' => $lockstate,
'$bang' => '',
'$acl' => (($is_owner) ? populate_acl($a->user, $celeb) : ''),
'$profile_uid' => $a->profile['profile_uid']
'$profile_uid' => $a->profile['profile_uid'],
'$jotplugins' => $jotplugins
));
}

Zobrazit soubor

@ -53,6 +53,10 @@
rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
rep(/<span style=\"color:(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");
rep(/<font>(.*?)<\/font>/gi,"$1");
rep(/<img.*?width=\"(.*?)\".*?height=\"(.*?)\".*?src=\"(.*?)\".*?\/>/gi,"[img=$1x$2]$3[/img]");
rep(/<img.*?height=\"(.*?)\".*?width=\"(.*?)\".*?src=\"(.*?)\".*?\/>/gi,"[img=$2x$1]$3[/img]");
rep(/<img.*?src=\"(.*?)\".*?height=\"(.*?)\".*?width=\"(.*?)\".*?\/>/gi,"[img=$3x$2]$1[/img]");
rep(/<img.*?src=\"(.*?)\".*?width=\"(.*?)\".*?height=\"(.*?)\".*?\/>/gi,"[img=$2x$3]$1[/img]");
rep(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]");
rep(/<code>(.*?)<\/code>/gi,"[code]$1[/code]");
rep(/<\/(strong|b)>/gi,"[/b]");
@ -96,6 +100,7 @@
rep(/\[\/u\]/gi,"</u>");
rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");
rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");
rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3\" />");
rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");
rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<span style=\"color: $1;\">$2</span>");
// rep(/\[\/code\]\s*\[code\]/gi,"<br />"); // fold multiline code

Zobrazit soubor

@ -15,6 +15,11 @@
<textarea rows="5" cols="64" class="profile-jot-text" id="profile-jot-text" name="body" ></textarea>
<div id="profile-jot-plugin-wrapper" >
$jotplugins
</div>
<div id="profile-jot-plugin-end"></div>
<div id="profile-jot-submit-wrapper" >
<input type="submit" id="profile-jot-submit" name="submit" value="Share" />
<div id="profile-upload-wrapper" style="display: $visitor;" >

Zobrazit soubor

@ -15,6 +15,12 @@
<textarea rows="5" cols="64" class="profile-jot-text" id="profile-jot-text" name="body" ></textarea>
<div id="profile-jot-plugin-wrapper" >
$jotplugins
</div>
<div id="profile-jot-plugin-end"></div>
<div id="profile-jot-submit-wrapper" >
<input type="submit" id="profile-jot-submit" name="submit" value="Share" />
<div id="profile-upload-wrapper" style="display: $visitor;" >

Zobrazit soubor

@ -15,6 +15,11 @@
<textarea rows="5" cols="64" class="profile-jot-text" id="profile-jot-text" name="body" ></textarea>
<div id="profile-jot-plugin-wrapper" >
$jotplugins
</div>
<div id="profile-jot-plugin-end"></div>
<div id="profile-jot-submit-wrapper" >
<input type="submit" id="profile-jot-submit" name="submit" value="Condividi" />
<div id="profile-upload-wrapper" style="display: $visitor;" >
@ -40,6 +45,8 @@
<div id="profile-jot-acl-wrapper" style="display: none;" >$acl</div>
</div>
<div id="profile-jot-end"></div>
</form>
</div>

Zobrazit soubor

@ -1034,7 +1034,7 @@ input#dfrn-url {
margin-left: 110px;
margin-top: 10px;
}
#profile-jot-plugin-wrapper,
#profile-jot-submit-wrapper {
margin-top: 15px;
}
@ -1078,7 +1078,9 @@ input#dfrn-url {
#profile-jot-perms-end {
clear: both;
}
#profile-jot-plugin-end {
clear:both;
}
#profile-jot-end {
clear: both;
margin-bottom: 30px;
@ -2000,3 +2002,10 @@ a.mail-list-link {
margin-bottom: 15px;
}
.tool-wrapper {
float: left;
margin-left: 5px;
}
.tool-link {
cursor: pointer;
}

Zobrazit soubor

@ -809,6 +809,8 @@ input#dfrn-url {
}
.wall-item-wrapper {
float: left;
margin-right: 5px;
width: 80px;
}
.wall-item-lock {
height: 20px;
@ -851,7 +853,7 @@ input#dfrn-url {
}
.wall-item-content {
float: left;
width: 450px;
/*width: 450px;*/
margin-left: 10px;
margin-bottom: 20px;
padding: 20px;
@ -905,6 +907,7 @@ input#dfrn-url {
margin: 10px 0px 10px 110px;
}
#profile-jot-plugin-wrapper,
#profile-jot-submit-wrapper {
margin-top: 15px;
}
@ -950,6 +953,9 @@ input#dfrn-url {
height: 30px;
}
#profile-jot-plugin-end{
clear: both;
}
#profile-jot-end {
/*clear: both;*/
margin-bottom: 30px;
@ -1456,8 +1462,9 @@ input#dfrn-url {
margin-top: 10px;
}
a.mail-list-link {
display: block;
padding: 4px 5px;
display: block;
font-size: 1.3em;
padding: 4px 0;
}
/*
@ -1495,8 +1502,8 @@ a.mail-list-link {
}
.mail-conv-subject {
font-size: 1.1em;
margin-top: 10px;
font-size: 1.4em;
margin: 10px 0;
}
.mail-conv-outside-wrapper-end {
@ -1882,3 +1889,11 @@ a.mail-list-link {
margin-bottom: 15px;
}
.tool-wrapper {
float: left;
margin-left: 5px;
}
.tool-link {
cursor: pointer;
}