Commit 0b79eefd306b45b8418fb8aaaa42d51ff8d77814

  • avatar
  • blaise.ca <balleyne @d…b.privatedns.com>
  • Wed Nov 04 02:36:36 CET 2009
Refactored microblog formatting, adding formatting for Twitter favourites
  
144144}
145145
146146class MicroBlog extends Entry{
147
148 #TODO: add link to post ?
149 function getSingleTitle(){
150 $title = $this->getNeutralTitle();
151
147 function format($message) {
152148 // Replace URLs with links
153 $title = $this->linkify($title);
149 $message = $this->linkify($message);
154150
155151 // Default to Twitter if multiple...
156 $domain = count($this->icons) > 1 ? Twitter::$static_domain : $this->domain;
157 $search_path = count($this->icons) > 1 ? Twitter::$static_search_path : $this->search_path;
152 $domain = isset($this->icons) && count($this->icons) > 1 ? Twitter::$static_domain : $this->domain;
153 $search_path = isset($this->icons) && count($this->icons) > 1 ? Twitter::$static_search_path : $this->search_path;
158154
159155 // Link usernames
160 $title = preg_replace('/( |\.|^)@([\w_-]+)/i', '$1@<a href="http://'.$domain.'/$2">$2</a>', $title);
156 $message = preg_replace('/( |\.|^)@([\w_-]+)/i', '$1@<a href="http://'.$domain.'/$2">$2</a>', $message);
161157
162158 // Link hash tags
163 $title = preg_replace('/( |^)#([\w_-]+)/i', '$1#<a href="http://'.$search_path.'?q=%23$2">$2</a>', $title);
159 $message = preg_replace('/( |^)#([\w_-]+)/i', '$1#<a href="http://'.$search_path.'?q=%23$2">$2</a>', $message);
164160
165 return $title;
161 return $message;
162 }
163
164 #TODO: add link to post ?
165 function getSingleTitle(){
166 return $this->format( $this->getNeutralTitle() );
166167 }
167168
168169 function getSingleDescription(){
233233 return $this->getAuthor()." $this->action " . parent::getSingleTitle();
234234 }
235235
236 function getMultipleTitle(){
237 return parent::getSingleTitle();
238 }
236 function getMultipleTitle(){
237 return str_replace($this->getAuthor()." $this->action ",'', $this->getSingleTitle());
238 }
239239
240240 function multiple($other_entries, $more_threshold=5){
241241 $icon = $this->getIcon();
568568 public static $static_domain = 'identi.ca';
569569 public static $static_search_path = 'identi.ca/search/notice';
570570
571 function getSingleTitle(){
572 $title = parent::getSingleTitle();
571// function getSingleTitle(){
572// $title = parent::getSingleTitle();
573573
574 function format($message){
575 $message = parent::format($message);
576
574577 // Link groups
575 $title = preg_replace('/( |^)!([\w_-]+)/i', '$1!<a href="http://'.$this->domain.'/group/$2">$2</a>', $title);
578 $message = preg_replace('/( |^)!([\w_-]+)/i', '$1!<a href="http://'.$this->domain.'/group/$2">$2</a>', $message);
576579
577 return $title;
580 return $message;
578581 }
579582}
580583
618618
619619class TwitterFavorites extends Favorites{
620620 var $img = 'http://www.twitter.com/favicon.ico';
621 var $domain = 'twitter.com';
622 var $search_path = 'search.twitter.com/search';
623 public static $static_domain = 'twitter.com';
624 public static $static_search_path = 'search.twitter.com/search';
621625
626 function getSingleTitle(){
627 $message = Twitter::format($this->title);
628 $message = preg_replace('/^([\w]+)\: /i', '<a href="'.$this->link.'">$1</a>: ', $message);
629 return $this->getAuthor() ." $this->action ". $message;
630 }
631
622632 function getSingleDescription(){
623633 return '';
624634 }