From 306036c62613fd849a80c83c50cd220f75e64c90 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Mon, 24 Oct 2011 13:02:38 +0200 Subject: [PATCH 1/7] cache api --- boot.php | 1 + include/cache.php | 29 +++++++++++++++++++++++++++++ include/oembed.php | 16 ++++++---------- include/poller.php | 3 +-- 4 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 include/cache.php diff --git a/boot.php b/boot.php index 017e21814b..9623b4b141 100644 --- a/boot.php +++ b/boot.php @@ -6,6 +6,7 @@ require_once('include/plugin.php'); require_once('include/text.php'); require_once("include/pgettext.php"); require_once('include/nav.php'); +require_once('include/cache.php'); define ( 'FRIENDIKA_PLATFORM', 'Free Friendika'); define ( 'FRIENDIKA_VERSION', '2.3.1140' ); diff --git a/include/cache.php b/include/cache.php new file mode 100644 index 0000000000..082974c61a --- /dev/null +++ b/include/cache.php @@ -0,0 +1,29 @@ + + + diff --git a/include/poller.php b/include/poller.php index cef0647b59..a19f0716f6 100644 --- a/include/poller.php +++ b/include/poller.php @@ -64,8 +64,7 @@ function poller_run($argv, $argc){ } // clear old cache - q("DELETE FROM `cache` WHERE `updated` < '%s'", - dbesc(datetime_convert('UTC','UTC',"now - 30 days"))); + Cache::clear(); $manual_id = 0; $generation = 0; From a9fb8e4d6052dbb5db95939128d491897b4f6a0c Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Mon, 24 Oct 2011 14:30:11 +0200 Subject: [PATCH 2/7] Use oembed for bookmark, audio, video, youtube --- include/bbcode.php | 41 ++++++++++++++++++++++++++++++++++++----- mod/item.php | 1 - 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index b33be686e4..81f37ca047 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -9,6 +9,22 @@ function stripcode_br_cb($s) { return '[code]' . str_replace('
', '', $s[1]) . '[/code]'; } +function tryoembed($match){ + $url = ((count($match)==2)?$match[1]:$match[2]); + + $o = oembed_fetch_url($url); + + //echo "
"; var_dump($match, $url, $o); killme();
+
+	if ($o->type=="error") return $match[0];
+	
+	$html = oembed_format_object($o);
+	
+	return $html;
+	
+}
+
+
 
 	// BBcode 2 HTML was written by WAY2WEB.net
 	// extended to work with Mistpark/Friendika - Mike Macgirvin
@@ -40,11 +56,14 @@ function bbcode($Text,$preserve_nl = false) {
 	// Set up the parameters for a MAIL search string
 	$MAILSearchString = $URLSearchString;
 
+
 	// Perform URL Search
-
-
 	$Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1$2', $Text);
+	
+	$Text = preg_replace_callback("/\[bookmark\=([^\]]*)\].*?\[\/bookmark\]/ism",'tryoembed',$Text);
+	$Text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",'[url=$1]$2[/url]',$Text);
 
+	$Text = preg_replace_callback("/\[url\]([$URLSearchString]*)\[\/url\]/ism",'tryoembed',$Text);
 	$Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '$1', $Text);
 	$Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$2', $Text);
 	//$Text = preg_replace("/\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[\/url\]/ism", '$2', $Text);
@@ -120,6 +139,13 @@ function bbcode($Text,$preserve_nl = false) {
 	// [img]pathtoimage[/img]
 	$Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text);
 
+
+
+	// Try to Oembed
+	$Text = preg_replace_callback("/\[video\](.*?)\[\/video\]/ism", 'tryoembed', $Text);
+	$Text = preg_replace_callback("/\[audio\](.*?)\[\/audio\]/ism", 'tryoembed', $Text);
+
+
 	// html5 video and audio
 
 	$Text = preg_replace("/\[video\](.*?)\[\/video\]/ism", '', $Text);
@@ -129,17 +155,22 @@ function bbcode($Text,$preserve_nl = false) {
 	$Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/ism", '', $Text);
          
 
-	if (get_pconfig(local_user(), 'oembed', 'use_for_youtube' )==1){
+	/*if (get_pconfig(local_user(), 'oembed', 'use_for_youtube' )==1){
 		// use oembed for youtube links
 		$Text = preg_replace("/\[youtube\]/",'[embed]',$Text); 
 		$Text = preg_replace("/\[\/youtube\]/",'[/embed]',$Text); 
-	} else {
+	} else {*/
 		// Youtube extensions
+        $Text = preg_replace_callback("/\[youtube\](https?:\/\/www.youtube.com\/watch\?v\=.*?)\[\/youtube\]/ism", 'tryoembed', $Text);        
+        $Text = preg_replace_callback("/\[youtube\](https?:\/\/youtu.be\/.*?)\[\/youtube\]/ism",'tryoembed',$Text); 
+        
         $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text); 
         $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/embed\/(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text); 
         $Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text); 
+		
+        
 		$Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '', $Text);
-	}
+	//}
 
 	$Text = preg_replace("/\[vimeo\]https?:\/\/player.vimeo.com\/video\/([0-9]+)(.*?)\[\/vimeo\]/ism",'[vimeo]$1[/vimeo]',$Text); 
 	$Text = preg_replace("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism",'[vimeo]$1[/vimeo]',$Text); 
diff --git a/mod/item.php b/mod/item.php
index ab104735b9..0e855d54d9 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -338,7 +338,6 @@ function item_post(&$a) {
 	$bookmark = 0;
 	if(preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$body,$match)) {
 		$bookmark = 1;
-		$body = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",'[url=$1]$2[/url]',$body);
 	}
 
 

From ac474cf53c28d8fc05eacb1d9076f8c88f1f69ae Mon Sep 17 00:00:00 2001
From: Fabio Comuni 
Date: Mon, 24 Oct 2011 14:39:39 +0200
Subject: [PATCH 3/7] try to use oembed on vimeo tag

---
 include/bbcode.php | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/bbcode.php b/include/bbcode.php
index 81f37ca047..7045f196f8 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -172,6 +172,9 @@ function bbcode($Text,$preserve_nl = false) {
 		$Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '', $Text);
 	//}
 
+	$Text = preg_replace_callback("/\[vimeo\]https?:\/\/player.vimeo.com\/video\/([0-9]+)(.*?)\[\/vimeo\]/ism",'tryoembed',$Text); 
+	$Text = preg_replace_callback("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism",'tryoembed',$Text); 
+
 	$Text = preg_replace("/\[vimeo\]https?:\/\/player.vimeo.com\/video\/([0-9]+)(.*?)\[\/vimeo\]/ism",'[vimeo]$1[/vimeo]',$Text); 
 	$Text = preg_replace("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism",'[vimeo]$1[/vimeo]',$Text); 
 	$Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '', $Text);

From 718a9009be697ab8873a9ca41571f1d9701c97e7 Mon Sep 17 00:00:00 2001
From: Fabio Comuni 
Date: Mon, 24 Oct 2011 17:27:38 +0200
Subject: [PATCH 4/7] new icon "play"

---
 images/icons/10/play.png | Bin 0 -> 420 bytes
 images/icons/16/play.png | Bin 0 -> 508 bytes
 images/icons/22/play.png | Bin 0 -> 601 bytes
 images/icons/48/play.png | Bin 0 -> 1017 bytes
 images/icons/Makefile    |   3 ++-
 images/icons/play.png    | Bin 0 -> 6285 bytes
 6 files changed, 2 insertions(+), 1 deletion(-)
 create mode 100644 images/icons/10/play.png
 create mode 100644 images/icons/16/play.png
 create mode 100644 images/icons/22/play.png
 create mode 100644 images/icons/48/play.png
 create mode 100644 images/icons/play.png

diff --git a/images/icons/10/play.png b/images/icons/10/play.png
new file mode 100644
index 0000000000000000000000000000000000000000..a9f99e4d1835692906dec8b571c53a3b6ebb4be6
GIT binary patch
literal 420
zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V3y@T|W;X*;Ea{HEjtmSN`)Ym%P6qNBi-X*q
z7}lMWc?skwBzpw;GB8xBGB7kWGcf%852S(Or3MTPuM!v-tY$DUi04m=Kk5cl%ar8p
z?!xfDz5mR9Adj=aBeIx*fm;}a85w5HkpK$L^>lFz;kcfhaDYidQXWu75^^fQJs0%d3OWJ+>*YSI|=c2~QZ}x}zIv%9At^aRtSTpHY)aUfq
z|9%MP1WQCnNZ1+GB>p&X;LL~lA2**+-Z^=V(|(}nK7*RnKSw^izP#BteffH8-7mjo
znYoz{Yqyo}uY0rKw*I)^+w(j;?-l%t(te!y-um}gHrpQthC6?)UVFZMvj^x<)e_f;
zl9a@fRIB8oR3OD*WMF8hYiOWrWD;U%W@T(*WoWEzU}R-r@M-e5KokwR`6-!cl|T&!
lmbwNOx`vh^Mn+aZJ*Gww4WU!!-2iG}@O1TaS?83{1OPfem4W~O

literal 0
HcmV?d00001

diff --git a/images/icons/16/play.png b/images/icons/16/play.png
new file mode 100644
index 0000000000000000000000000000000000000000..19ad05bf2eeab8390990bc4a3b9270f639510e5e
GIT binary patch
literal 508
zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^xl_SO6joDAeM76-XI
zF|0c$^AgBWNcITwWnidMWngG%W?=aFA4mhmOAQzpUL`OvSj}Ky5YL|!f7A`AmMO{G
z-G$+Qd;gjJKptm-M`SSr1Gg{;GcwGYBLNir>gnPbqH#VsVS$K&6Gvd%Qy=^PwaFX@
z0}dQHaNxj)`42^z%V%WGkvPxH=A6SN0R;Ba#%CwSd^)*rR;qj$E04XzzRmwWrAMy5
zczmtk=^Ya58YI)4I<)(*%D36a{67fNcnO8!^^v0-|iNlV|(($
zW8F=h_L6l5K$SoKJ@_&4=kM~r)n`A*EAfSYnEjFa@afafr@e{({gCl+e2aM^mxR3S
zPP@wgkJ_h8)Fts3y4eMa)paTJX)`dax*M`7-F}xSFaT6bTq8)
zQ;AC2>eD?vy)3P*H1zoNZk;{aS$`m~a0+*^#3G+tSGFuXc0@yUS`_!fZ?Av06=A~(3_iZC{vFL`C7v@aLm6=y^BXOtIzQ>y)%gf%_
zpW)x?c})AUNM`XVr8n26#)VfTEjt*``FuhKhf!GWn!3vy(~5LvTtA&S^ElJglFep!
zAI*z;wXJb;&898~g%cCrToS)s&b(Q9t>Lf#k7cy9WfB@5_nEZ
zF?BWxoZr4r_W#0f9sj
zKlyB%pOW;#>I*{`$McG}?Zb|Evwu(@l$jL9SZj8c~vxSdwa$T$Bo=7>o=I
z4Rs9-bd5|x49%>JO{@%!wGE7{3=BR^{uYR$AvZrIGp!P+!N5}2z(Uv1GQ`Np3aH1_
W2%;f$%Dfvu4Gf;HelF{r5}E);Q}fLL

literal 0
HcmV?d00001

diff --git a/images/icons/48/play.png b/images/icons/48/play.png
new file mode 100644
index 0000000000000000000000000000000000000000..fce5893704bdd3c1771ae143818dc42178ee49f3
GIT binary patch
literal 1017
zcmVPx#AY({UO#lFTB>(_`g8%^e{{R4h=>PzAFaQARU;qF*
zm;eA5Z<1fdMgRZ+0%A)?L;(MXkIcUS000SaNLh0L01FcU01FcV0GgZ_0008=NklTE7^wN&IPxC>or;#SEL1uYL&RIiIUg;Gn+ihWzZJF}5(EuU@h!DVo1-I33^+ZF{
zt%tdZCK5k`j7oFfNs&m9AVB~R7}HDk7F9)z<2E*F6Z|V4i(oY3u|2ibb&aPhHmijt
zV<16{DjqBtz4pTX7d7{u9n@))lEG>d2J8;Q^;2&wH)>2ENkg<87Ka7G2vq_C!8xRmMZ2v%`^+&%nhH?17$c3e_rsAsRVczL%vD$mXKjDTKL4@Ul
zlAT~>$ONJ^?QOTWb_GV@f(L$Zv7d)EAR+()^F6)Iof8hYFo|Da)!joChzJPS#i79#
z>%ce32{(LLKt$ywS4Ko3B23Vh4qFd53L0Jnl&B{#fdo_=dI
z1_V0jL4ix0x;lfU?OaMarIa>Ue*kV_sRLLPYNY@G03~!qSaf7zbY(hYa%Ew3WdJfT
zF)=MMFfB4PR53O>Gc-CeGb=DMIxsNullD;n001R)MObuXVRU6WZEs|0W_bWIFfchS
nFgPtSIaD$-Ix#jnH8LwOGCD9YRg|9C00000NkvXXu0mjfn}(%W

literal 0
HcmV?d00001

diff --git a/images/icons/Makefile b/images/icons/Makefile
index 39428d1545..6a96fb6762 100644
--- a/images/icons/Makefile
+++ b/images/icons/Makefile
@@ -1,7 +1,8 @@
 
 IMAGES=add.png edit.png	gear.png info.png menu.png \
 		notify_off.png star.png  delete.png feed.png group.png \
-		lock.png notice.png notify_on.png user.png link.png
+		lock.png notice.png notify_on.png user.png link.png \
+		play.png
 
 DESTS=10/ 16/ 22/ 48/ \
 		$(addprefix 10/, $(IMAGES)) \
diff --git a/images/icons/play.png b/images/icons/play.png
new file mode 100644
index 0000000000000000000000000000000000000000..7c942072e739c2367610c3016fc5f6d94e48bfb7
GIT binary patch
literal 6285
zcmb7Hg;!MF*S-TI-Hn6;42VdlbT_%`4
zv5%I;O8_9H{cnPR-1kfXKw{vks%mKH;_c`C(#6{cqOGb5@p<9x?CRkJ0D+77#xN7(
zJqG#n)l(JSSok|#?q9p~F)H;r=&JJp!{1~egxh%8e}%t!)GR-wX9y&g5#
zH?Z+jPzgZ-^#Q1e8XP%ZV!1%TMYx>YLrxT77XS*JCM5z;`gtf})|gw$eU+SNAoyz#
z$}jbiE)kp#Pzp{`DFu`?K=Ax*9%G;o4A_o1*lz-c0)XxPi0x?ro_~=O0s^ewanOSb
zQvnFAQ>+@`A`4WbpT?^L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embeded videos in template. fix oembed
 discovery

---
 include/oembed.php    | 38 ++++++++++++++++++++++----------------
 view/oembed_video.tpl |  4 ++++
 2 files changed, 26 insertions(+), 16 deletions(-)
 create mode 100644 view/oembed_video.tpl

diff --git a/include/oembed.php b/include/oembed.php
index d40ceb3fd5..2933252b3e 100644
--- a/include/oembed.php
+++ b/include/oembed.php
@@ -7,7 +7,7 @@ function oembed_replacecb($matches){
 
 
 function oembed_fetch_url($embedurl){
-
+	
 	$txt = Cache::get($embedurl);
 				
 	if(is_null($txt)){
@@ -16,18 +16,18 @@ function oembed_fetch_url($embedurl){
 		// try oembed autodiscovery
 		$redirects = 0;
 		$html_text = fetch_url($embedurl, false, $redirects, 15);
-		if(! $html_text)
-			return;
-		$dom = @DOMDocument::loadHTML($html_text);
-		if ($dom){
-			$xpath = new DOMXPath($dom);
-			$attr = "oembed";
-		
-			$xattr = oe_build_xpath("class","oembed");
-			$entries = $xpath->query("//link[@type='application/json+oembed']");
-			foreach($entries as $e){
-				$href = $e->getAttributeNode("href")->nodeValue;
-				$txt = fetch_url($href);
+		if($html_text){
+			$dom = @DOMDocument::loadHTML($html_text);
+			if ($dom){
+				$xpath = new DOMXPath($dom);
+				$attr = "oembed";
+			
+				$xattr = oe_build_xpath("class","oembed");
+				$entries = $xpath->query("//link[@type='application/json+oembed']");
+				foreach($entries as $e){
+					$href = $e->getAttributeNode("href")->nodeValue;
+					$txt = fetch_url($href);
+				}
 			}
 		}
 		
@@ -59,9 +59,15 @@ function oembed_format_object($j){
 				/*$tw = (isset($j->thumbnail_width)) ? $j->thumbnail_width:200;
 				$th = (isset($j->thumbnail_height)) ? $j->thumbnail_height:180;*/
 				$tw=150; $th=120; 
-				$ret.= "";
-				$ret.= "";
-				$ret.= "";
+				$tpl=get_markup_template('oembed_video.tpl');
+				$ret.=replace_macros($tpl, array(
+					'$embedurl'=>$embedurl,
+					'$escapedhtml'=>urlencode($j->html),
+					'$tw'=>$tw,
+					'$th'=>$th,
+					'$turl'=>$j->thumbnail_url,
+				));
+				
 			} else {
 				$ret=$j->html;
 			}
diff --git a/view/oembed_video.tpl b/view/oembed_video.tpl
new file mode 100644
index 0000000000..29b5149ba2
--- /dev/null
+++ b/view/oembed_video.tpl
@@ -0,0 +1,4 @@
+
+	
+	
+
From 40ea48bdabb5b7b8c87cd3c37e12c0c24eb91014 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Mon, 24 Oct 2011 17:28:48 +0200 Subject: [PATCH 6/7] fix vimeo oembed bbcode regexp --- include/bbcode.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index 7045f196f8..a8c66d30fd 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -172,8 +172,8 @@ function bbcode($Text,$preserve_nl = false) { $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '', $Text); //} - $Text = preg_replace_callback("/\[vimeo\]https?:\/\/player.vimeo.com\/video\/([0-9]+)(.*?)\[\/vimeo\]/ism",'tryoembed',$Text); - $Text = preg_replace_callback("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism",'tryoembed',$Text); + $Text = preg_replace_callback("/\[vimeo\](https?:\/\/player.vimeo.com\/video\/[0-9]+).*?\[\/vimeo\]/ism",'tryoembed',$Text); + $Text = preg_replace_callback("/\[vimeo\](https?:\/\/vimeo.com\/[0-9]+).*?\[\/vimeo\]/ism",'tryoembed',$Text); $Text = preg_replace("/\[vimeo\]https?:\/\/player.vimeo.com\/video\/([0-9]+)(.*?)\[\/vimeo\]/ism",'[vimeo]$1[/vimeo]',$Text); $Text = preg_replace("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism",'[vimeo]$1[/vimeo]',$Text); From 2905df527f2fbc9b426ebc89a53adc5c6cf1ee47 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Mon, 24 Oct 2011 17:31:14 +0200 Subject: [PATCH 7/7] fix oembed video thumb display ratio --- include/oembed.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/oembed.php b/include/oembed.php index 2933252b3e..924e61289e 100644 --- a/include/oembed.php +++ b/include/oembed.php @@ -56,9 +56,11 @@ function oembed_format_object($j){ 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;*/ - $tw=150; $th=120; + $tw = (isset($j->thumbnail_width)) ? $j->thumbnail_width:200; + $th = (isset($j->thumbnail_height)) ? $j->thumbnail_height:180; + $tr = $tw/$th; + + $th=120; $tw = $th*$tr; $tpl=get_markup_template('oembed_video.tpl'); $ret.=replace_macros($tpl, array( '$embedurl'=>$embedurl,