aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-01-26 13:59:20 -0800
committerFriendika <info@friendika.com>2011-01-26 13:59:20 -0800
commit05350082fab123a1ba01340d3fef95f4edf6fb5b (patch)
tree82c1a04931b1942a2067d2cf60a26f96e127306c
parentc3691b3331d4aa26ff7fb1294b7ef5218aa241ec (diff)
parent43be72297a281b41e7b77ba6078aeb48ee007299 (diff)
downloadvolse-hubzilla-05350082fab123a1ba01340d3fef95f4edf6fb5b.tar.gz
volse-hubzilla-05350082fab123a1ba01340d3fef95f4edf6fb5b.tar.bz2
volse-hubzilla-05350082fab123a1ba01340d3fef95f4edf6fb5b.zip
Merge branch 'oembed' of https://github.com/fabrixxm/friendika into fabrixxm-oembed
-rw-r--r--addon/README3
-rw-r--r--addon/oembed/oembed.js10
-rw-r--r--addon/oembed/oembed.php101
-rw-r--r--addon/oembed/oembed.pngbin0 -> 417 bytes
-rw-r--r--mod/network.php6
-rw-r--r--mod/profile.php7
-rw-r--r--tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js5
-rw-r--r--view/en/jot.tpl5
-rw-r--r--view/fr/jot.tpl6
-rw-r--r--view/it/jot.tpl7
-rw-r--r--view/theme/default/style.css13
-rw-r--r--view/theme/duepuntozero/style.css25
12 files changed, 178 insertions, 10 deletions
diff --git a/addon/README b/addon/README
index 2e4ed6029..fb1c6340a 100644
--- a/addon/README
+++ b/addon/README
@@ -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
diff --git a/addon/oembed/oembed.js b/addon/oembed/oembed.js
new file mode 100644
index 000000000..54547a86e
--- /dev/null
+++ b/addon/oembed/oembed.js
@@ -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();
+}
diff --git a/addon/oembed/oembed.php b/addon/oembed/oembed.php
new file mode 100644
index 000000000..82183f3cc
--- /dev/null
+++ b/addon/oembed/oembed.php
@@ -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);
+}
+
+
+?> \ No newline at end of file
diff --git a/addon/oembed/oembed.png b/addon/oembed/oembed.png
new file mode 100644
index 000000000..6fc3794bb
--- /dev/null
+++ b/addon/oembed/oembed.png
Binary files differ
diff --git a/mod/network.php b/mod/network.php
index 02e458d8f..50d7134c1 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -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
));
diff --git a/mod/profile.php b/mod/profile.php
index 505edf5ce..c84b493c5 100644
--- a/mod/profile.php
+++ b/mod/profile.php
@@ -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
));
}
diff --git a/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js b/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js
index f12975ba2..ebccfb311 100644
--- a/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js
+++ b/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js
@@ -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
diff --git a/view/en/jot.tpl b/view/en/jot.tpl
index 6590cace8..de88fb84f 100644
--- a/view/en/jot.tpl
+++ b/view/en/jot.tpl
@@ -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;" >
diff --git a/view/fr/jot.tpl b/view/fr/jot.tpl
index 6590cace8..9a5c58153 100644
--- a/view/fr/jot.tpl
+++ b/view/fr/jot.tpl
@@ -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;" >
diff --git a/view/it/jot.tpl b/view/it/jot.tpl
index 5aaf9b923..b0c90ddf5 100644
--- a/view/it/jot.tpl
+++ b/view/it/jot.tpl
@@ -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>
diff --git a/view/theme/default/style.css b/view/theme/default/style.css
index fcc9c94a8..6e643d4fe 100644
--- a/view/theme/default/style.css
+++ b/view/theme/default/style.css
@@ -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;
+}
diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css
index 3351b35a1..7fbeed4fe 100644
--- a/view/theme/duepuntozero/style.css
+++ b/view/theme/duepuntozero/style.css
@@ -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;
+}