From cbdf8e51aa2826e11cc17c34bcbf568ca37e26ce Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 26 Aug 2009 14:34:41 +0000 Subject: Facebook app wasn't loading the theme css --- lib/facebookaction.php | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/facebookaction.php b/lib/facebookaction.php index 289e702c6..975ef9a50 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -96,6 +96,7 @@ class FacebookAction extends Action function showStylesheets() { $this->cssLink('css/display.css', 'base'); + $this->cssLink('css/display.css',null,'screen, projection, tv'); $this->cssLink('css/facebookapp.css', 'base'); } -- cgit v1.2.3-54-g00ecf From 6d60d74093005992701418edda5be4422e46262f Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 26 Aug 2009 15:40:51 -0400 Subject: Display linked oembed resources as enclosures if they are of non-html mime types --- classes/File.php | 50 +++++++++++++++++++++++++++++++++++++++++--------- classes/Notice.php | 9 +++++---- lib/rssaction.php | 23 ++++++++++++----------- lib/twitterapi.php | 9 +++++---- 4 files changed, 63 insertions(+), 28 deletions(-) (limited to 'lib') diff --git a/classes/File.php b/classes/File.php index b2c510340..1c64b4d33 100644 --- a/classes/File.php +++ b/classes/File.php @@ -195,17 +195,49 @@ class File extends Memcached_DataObject return 'http://'.$server.$path.$filename; } - function isEnclosure(){ + function getEnclosure(){ + $enclosure = (object) array(); + $enclosure->title=$this->title; + $enclosure->url=$this->url; + $enclosure->title=$this->title; + $enclosure->date=$this->date; + $enclosure->modified=$this->modified; + $enclosure->size=$this->size; + $enclosure->mimetype=$this->mimetype; + if(isset($this->filename)){ - return true; - } - $notEnclosureMimeTypes = array('text/html','application/xhtml+xml'); - $mimetype = strtolower($this->mimetype); - $semicolon = strpos($mimetype,';'); - if($semicolon){ - $mimetype = substr($mimetype,0,$semicolon); + return $enclosure; + }else{ + $notEnclosureMimeTypes = array('text/html','application/xhtml+xml'); + $mimetype = strtolower($this->mimetype); + $semicolon = strpos($mimetype,';'); + if($semicolon){ + $mimetype = substr($mimetype,0,$semicolon); + } + if(in_array($mimetype,$notEnclosureMimeTypes)){ + $ombed = File_oembed::staticGet('file_id',$this->id); + if($oembed){ + $mimetype = strtolower($ombed->mimetype); + $semicolon = strpos($mimetype,';'); + if($semicolon){ + $mimetype = substr($mimetype,0,$semicolon); + } + if(in_array($mimetype,$notEnclosureMimeTypes)){ + return false; + }else{ + if($ombed->mimetype) $enclosure->mimetype=$ombed->mimetype; + if($ombed->url) $enclosure->url=$ombed->url; + if($ombed->title) $enclosure->title=$ombed->title; + if($ombed->modified) $enclosure->modified=$ombed->modified; + unset($ombed->size); + } + }else{ + return $enclosure; + } + }else{ + return $enclosure; + } } - return(! in_array($mimetype,$notEnclosureMimeTypes)); } } diff --git a/classes/Notice.php b/classes/Notice.php index 48d4a0940..c4f163c31 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1199,10 +1199,11 @@ class Notice extends Memcached_DataObject $attachments = $this->attachments(); if($attachments){ foreach($attachments as $attachment){ - if ($attachment->isEnclosure()) { - $attributes = array('rel'=>'enclosure','href'=>$attachment->url,'type'=>$attachment->mimetype,'length'=>$attachment->size); - if($attachment->title){ - $attributes['title']=$attachment->title; + $enclosure=$attachment->getEnclosure(); + if ($enclosure) { + $attributes = array('rel'=>'enclosure','href'=>$enclosure->url,'type'=>$enclosure->mimetype,'length'=>$enclosure->size); + if($enclosure->title){ + $attributes['title']=$enclosure->title; } $xs->element('link', $attributes, null); } diff --git a/lib/rssaction.php b/lib/rssaction.php index 0aca96566..7e317010d 100644 --- a/lib/rssaction.php +++ b/lib/rssaction.php @@ -258,26 +258,27 @@ class Rss10Action extends Action $attachments = $notice->attachments(); if($attachments){ foreach($attachments as $attachment){ - if ($attachment->isEnclosure()) { + $enclosure=$attachment->getEnclosure(); + if ($enclosure) { // DO NOT move xmlns declaration to root element. Making it // the default namespace here improves compatibility with // real-world feed readers. $attribs = array( - 'rdf:resource' => $attachment->url, - 'url' => $attachment->url, + 'rdf:resource' => $enclosure->url, + 'url' => $enclosure->url, 'xmlns' => 'http://purl.oclc.org/net/rss_2.0/enc#' ); - if ($attachment->title) { - $attribs['dc:title'] = $attachment->title; + if ($enclosure->title) { + $attribs['dc:title'] = $enclosure->title; } - if ($attachment->modified) { - $attribs['dc:date'] = common_date_w3dtf($attachment->modified); + if ($enclosure->modified) { + $attribs['dc:date'] = common_date_w3dtf($enclosure->modified); } - if ($attachment->size) { - $attribs['length'] = $attachment->size; + if ($enclosure->size) { + $attribs['length'] = $enclosure->size; } - if ($attachment->mimetype) { - $attribs['type'] = $attachment->mimetype; + if ($enclosure->mimetype) { + $attribs['type'] = $enclosure->mimetype; } $this->element('enclosure', $attribs); } diff --git a/lib/twitterapi.php b/lib/twitterapi.php index 583007208..e0087e689 100644 --- a/lib/twitterapi.php +++ b/lib/twitterapi.php @@ -274,11 +274,12 @@ class TwitterapiAction extends Action $enclosures = array(); foreach ($attachments as $attachment) { - if ($attachment->isEnclosure()) { + $enclosure_o=$attachment->getEnclosure(); + if ($enclosure_o) { $enclosure = array(); - $enclosure['url'] = $attachment->url; - $enclosure['mimetype'] = $attachment->mimetype; - $enclosure['size'] = $attachment->size; + $enclosure['url'] = $enclosure_o->url; + $enclosure['mimetype'] = $enclosure_o->mimetype; + $enclosure['size'] = $enclosure_o->size; $enclosures[] = $enclosure; } } -- cgit v1.2.3-54-g00ecf From b7beac36c2dbebfa27982b2fc6c82cf2ebbaae8d Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 26 Aug 2009 21:54:57 -0400 Subject: Support multiple attachments per facebook update --- lib/facebookutil.php | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/facebookutil.php b/lib/facebookutil.php index e31a71f5e..67c6ecbdf 100644 --- a/lib/facebookutil.php +++ b/lib/facebookutil.php @@ -178,20 +178,38 @@ function format_attachments($attachments) $fbattachment = array(); $fbattachment['media'] = array(); - // Facebook only supports one attachment per item + foreach($attachments as $attachment) + { + $fbmedia = get_fbmedia_for_attachment($attachment); + if($fbmedia){ + $fbattachment['media'][]=$fbmedia; + }else{ + $fbattachment['name'] = ($attachment->title ? + $attachment->title : $attachment->url); + $fbattachment['href'] = $attachment->url; + } + } + if(count($fbattachment['media'])>0){ + unset($fbattachment['name']); + unset($fbattachment['href']); + } + return $fbattachment; +} - $attachment = $attachments[0]; +/** +* given an File objects, returns an associative array suitable for Facebook media +*/ +function get_fbmedia_for_attachment($attachment) +{ $fbmedia = array(); if (strncmp($attachment->mimetype, 'image/', strlen('image/')) == 0) { $fbmedia['type'] = 'image'; $fbmedia['src'] = $attachment->url; $fbmedia['href'] = $attachment->url; - $fbattachment['media'][] = $fbmedia; } else if ($attachment->mimetype == 'audio/mpeg') { $fbmedia['type'] = 'mp3'; $fbmedia['src'] = $attachment->url; - $fbattachment['media'][] = $fbmedia; }else if ($attachment->mimetype == 'application/x-shockwave-flash') { $fbmedia['type'] = 'flash'; @@ -200,14 +218,10 @@ function format_attachments($attachments) // $fbmedia['imgsrc']=''; $fbmedia['swfsrc'] = $attachment->url; - $fbattachment['media'][] = $fbmedia; }else{ - $fbattachment['name'] = ($attachment->title ? - $attachment->title : $attachment->url); - $fbattachment['href'] = $attachment->url; + return false; } - - return $fbattachment; + return $fbmedia; } function remove_facebook_app($flink) -- cgit v1.2.3-54-g00ecf From eb667d09d9c6ef5a1465a5f8d824661a9387a4da Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 26 Aug 2009 22:09:46 -0400 Subject: allow oEmbed resources to be facebook attachments --- lib/facebookutil.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/facebookutil.php b/lib/facebookutil.php index 67c6ecbdf..fc68f2b29 100644 --- a/lib/facebookutil.php +++ b/lib/facebookutil.php @@ -109,7 +109,6 @@ function facebookBroadcastNotice($notice) $can_update = $facebook->api_client->users_hasAppPermission('status_update', $fbuid); - if (!empty($attachments) && $can_publish == 1) { $fbattachment = format_attachments($attachments); $facebook->api_client->stream_publish($status, $fbattachment, @@ -180,7 +179,11 @@ function format_attachments($attachments) foreach($attachments as $attachment) { - $fbmedia = get_fbmedia_for_attachment($attachment); + if($enclosure = $attachment->getEnclosure()){ + $fbmedia = get_fbmedia_for_attachment($enclosure); + }else{ + $fbmedia = get_fbmedia_for_attachment($attachment); + } if($fbmedia){ $fbattachment['media'][]=$fbmedia; }else{ -- cgit v1.2.3-54-g00ecf