]> git.mxchange.org Git - friendica.git/commitdiff
API: Improved the timeline. Several (disabled) tests with caching of photos.
authorMichael Vogel <icarus@dabo.de>
Wed, 11 Apr 2012 17:31:01 +0000 (19:31 +0200)
committerMichael Vogel <icarus@dabo.de>
Wed, 11 Apr 2012 17:31:01 +0000 (19:31 +0200)
include/api.php
include/conversation.php
mod/photo.php
view/api_timeline_xml.tpl

index ab83d63be4c501eb93d3a8ab6a31ac7588b6fe36..0885a1434b19b773284f9b7d85b1a3d582e6c25f 100644 (file)
                                $in_reply_to_status_id = 0;
                        }
 
+                       // Workaround for ostatus messages where the title is identically to the body
+                       $statusbody = trim(html2plain(bbcode($item['body']), 0));
+                       $statustitle = trim($item['title']);
+
+                       if (($statustitle != '') and (strpos($statusbody, $statustitle) !== false))
+                               $statustext = trim($statusbody);
+                       else
+                               $statustext = trim($statustitle."\n\n".$statusbody);
+
                        $status = array(
-                               'text'          => trim($item['title']." \n".html2plain(bbcode($item['body']), 0)),
+                               'text'          => $statustext,
                                'truncated' => False,
                                'created_at'=> api_date($item['created']),
                                'in_reply_to_status_id' => $in_reply_to_status_id,
                                'geo' => '',
                                'favorited' => $item['starred'] ? true : false,
                                'user' =>  $status_user ,
-                               'statusnet_html'                => bbcode($item['body']),
-                               'statusnet_conversation_id'     => 0,
+                               'statusnet_html'                => trim(bbcode($item['body'])),
+                               'statusnet_conversation_id'     => $item['parent'],
                        );
 
                        // Seesmic doesn't like the following content
index df92a40ed000addbe70678ddae0200c1eff3932a..a32cbeb8ba9cae891991253fec5e348e10505a29 100644 (file)
@@ -626,10 +626,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                                else
                                        $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $thumb);
 
-
-
-
-
                                $like    = ((x($alike,$item['id'])) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
                                $dislike = ((x($dlike,$item['id'])) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
 
@@ -1089,4 +1085,3 @@ function render_location_google($item) {
        }
        return $location;
 }
-
index 3a702512005789bd187440d8cba585114b565641..ec53af899625e854048b9a0765ce1899a54a6c70 100644 (file)
@@ -4,6 +4,30 @@ require_once('include/security.php');
 
 function photo_init(&$a) {
 
+       // To-Do:
+       // - checking with realpath
+       // - checking permissions
+       /*
+       $cache = get_config('system','itemcache');
+        if (($cache != '') and is_dir($cache)) {
+               $cachefile = $cache."/".$a->argc."-".$a->argv[1]."-".$a->argv[2]."-".$a->argv[3];
+               if (file_exists($cachefile)) {
+                       $data = file_get_contents($cachefile);
+
+                       if(function_exists('header_remove')) {
+                               header_remove('Pragma');
+                               header_remove('pragma');
+                       }
+
+                       header("Content-type: image/jpeg");
+                       header("Expires: " . gmdate("D, d M Y H:i:s", time() + (3600*24)) . " GMT");
+                       header("Cache-Control: max-age=" . (3600*24));
+                       echo $data;
+                       killme();
+                       // NOTREACHED
+               }
+       }*/
+
        switch($a->argc) {
                case 4:
                        $person = $a->argv[3];
@@ -27,6 +51,7 @@ function photo_init(&$a) {
 
        if(isset($type)) {
 
+
                /**
                 * Profile photos
                 */
@@ -144,6 +169,10 @@ function photo_init(&$a) {
                }
        }
 
+       // Writing in cachefile
+       if ($cachefile != '')
+               file_put_contents($cachefile, $data);
+
        if(function_exists('header_remove')) {
                header_remove('Pragma');
                header_remove('pragma');
index 551439682a542869ffddf5988f2f7bba0365032d..4a32b411b58ae613919e80d115e5635b15516c23 100644 (file)
@@ -11,6 +11,7 @@
   <geo>$status.geo</geo>
   <favorited>$status.favorited</favorited>
 {{ inc api_user_xml.tpl with $user=$status.user }}{{ endinc }}  <statusnet:html>$status.statusnet_html</statusnet:html>
+  <statusnet:conversation_id>$status.statusnet_conversation_id</statusnet:conversation_id>
   <url>$status.url</url>
   <coordinates>$status.coordinates</coordinates>
   <place>$status.place</place>