Changeset 204285
- Timestamp:
- 02/11/2010 05:57:35 PM (16 years ago)
- Location:
- lifestream/trunk
- Files:
-
- 2 edited
-
extensions/jaiku/extension.inc.php (modified) (2 diffs)
-
inc/core.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lifestream/trunk/extensions/jaiku/extension.inc.php
r191677 r204285 2 2 class Lifestream_JaikuFeed extends Lifestream_Feed 3 3 { 4 const ID = 'jaiku';5 const NAME = 'Jaiku';6 const URL = 'http://www.jaiku.com/';4 const ID = 'jaiku'; 5 const NAME = 'Jaiku'; 6 const URL = 'http://www.jaiku.com/'; 7 7 const NS_JAIKU = 'http://jaiku.com/ns'; 8 const LABEL = 'Lifestream_MessageLabel'; 9 const CAN_GROUP = false; 10 8 const LABEL = 'Lifestream_MessageLabel'; 9 const DESCRIPTION = 'Hiding or showing comments only affects new comments and not the ones already in your lifestream.'; 10 const AUTHOR = 'Unknown, Jonas Nockert'; 11 const CAN_GROUP = false; 12 11 13 function get_options() 12 14 { 13 15 return array( 14 16 'username' => array($this->lifestream->__('Username:'), true, '', ''), 17 'hide_comments' => array($this->lifestream->__('Hide Comments'), false, true, false), 15 18 ); 16 19 } … … 20 23 return 'http://'.$this->get_option('username').'.jaiku.com/feed/rss'; 21 24 } 22 25 23 26 function get_user_url($user) 24 27 { 25 28 return 'http://'.$user.'.jaiku.com'; 26 29 } 27 30 28 31 function get_user_link($user) 29 32 { 30 return $this->lifestream->get_anchor_html('@'.htmlspecialchars($user ), $this->get_user_url($user), array('class'=>'user'));33 return $this->lifestream->get_anchor_html('@'.htmlspecialchars($user[1]), $this->get_user_url($user[1]), array('class'=>'user')); 31 34 } 32 35 33 36 function parse_users($text) 34 37 { 35 return preg_replace_callback('/( [^\w]*)@([a-z0-9_\-\/]+)\b/i', array($this, 'get_user_link'), $text);38 return preg_replace_callback('/(?<=^|\s)@([a-zA-Z0-9_]+)\b/i', array($this, 'get_user_link'), $text); 36 39 } 37 40 38 41 function render_item($row, $item) 39 42 { 40 return $this->parse_users($this->parse_urls(htmlspecialchars($item['title']))).' ['.$this->lifestream->get_anchor_html(htmlspecialchars($this->get_option('username')), $item['link']).']'; 43 // Posts do not have URL fragment identifiers 44 if (strpos($item['guid'], '#') === false) 45 { 46 // Render a post using only the feed item title 47 return $this->parse_users($this->parse_urls(htmlspecialchars($item['title']))).' ['.$this->lifestream->get_anchor_html(htmlspecialchars($this->get_option('username')), $item['link']).']'; 48 } 49 50 /* Render a comment using the feed item description. We're rendering the comment 51 html directly here but given the below it should be safe enough: 52 1) Jaiku is trying hard to avoid rendering anything malicious anywhere. 53 2) It can be assumed that the source of the html will be text the user wrote 54 herself. */ 55 56 // Remove avatar image 57 $desc_without_image = preg_replace('/<a.+?$\s+/Amu', '', $item['description']); 58 59 // Remove comment author as it's always the stream owner. 60 $desc_without_author = preg_replace('!^(<p.*?>\s+)(Comment).+(on)$!um', '\\1<i>\\2 \\3', $desc_without_image); 61 62 // Remove relative time and location 63 $desc_without_time = preg_replace('!\s+[^\r\n]+\s+[^\r\n]+\s+</p>$!u', '</i>', $desc_without_author); 64 65 /* Line breaks instead of paragraphs. Nested paragraphs and 66 multiple empty paragraphs in a row should not give additional 67 line breaks */ 68 $desc_without_p = preg_replace('/<p.*?>/u', '', $desc_without_time); 69 $desc_without_p = preg_replace('!(\s*</p>\s*){1,}!u', '<br/><br/>', $desc_without_p); 70 71 return $desc_without_p . ' ['.$this->lifestream->get_anchor_html(htmlspecialchars($this->get_option('username')), $item['link']).']'; 41 72 } 42 73 43 74 function yield($row, $url, $key) 44 75 { 45 //I don't know what this is for, would not fetch when running46 //if (!lifestream_str_startswith($row->get_link(), 'http://'.$this->get_option('username').'.jaiku.com/presence/')) return;47 48 76 $data = parent::yield($row, $url, $key); 49 //preg_match('|<p>([^<]+)</p>|i', $row->get_title(), $matches); 50 //$data['title'] = $matches[1]; 51 $data['title'] = $row->get_title(); 77 // Comments have URL fragment identifiers while posts do not 78 if ($this->get_option('hide_comments') && strpos($data['guid'], '#') !== false) 79 { 80 return false; 81 } 82 $data['title'] = $this->lifestream->html_entity_decode($row->get_title()); 83 $data['description'] = $row->get_description(); 52 84 return $data; 53 85 } -
lifestream/trunk/inc/core.php
r202949 r204285 1722 1722 else 1723 1723 { 1724 1725 1724 $post = array( 1726 1725 'post_title' => 'Lifestream',
Note: See TracChangeset
for help on using the changeset viewer.