From 3ef4f251acbe8ebdfd9d7f1ea43b7344b7332b73 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 22 Mar 2009 16:58:38 -0400 Subject: One function for producing Atom entry for a Notice Took the various places that we create an atom entry for a notice, and jammed them together into one function of the notice class, and then used that function. Also, added Atom threading extension and categories for hashtags. --- lib/jabber.php | 57 ++++++++++++++++----------------------------------------- 1 file changed, 16 insertions(+), 41 deletions(-) (limited to 'lib/jabber.php') diff --git a/lib/jabber.php b/lib/jabber.php index 3cd3b0d37..9108d1c47 100644 --- a/lib/jabber.php +++ b/lib/jabber.php @@ -163,50 +163,25 @@ function jabber_send_notice($to, $notice) function jabber_format_entry($profile, $notice) { - // FIXME: notice url might be remote - - $noticeurl = common_local_url('shownotice', - array('notice' => $notice->id)); - - $msg = jabber_format_notice($profile, $notice); - - $self_url = common_local_url('userrss', array('nickname' => $profile->nickname)); - - $entry = "\n\n"; - $entry .= "\n"; - $entry .= "" . $profile->nickname . " - " . common_config('site', 'name') . "\n"; - $entry .= "\n"; - $entry .= "\n"; - $entry .= "" . $profile->nickname . "\n"; - $entry .= "" . $profile->avatarUrl(AVATAR_PROFILE_SIZE) . "\n"; - $entry .= "\n"; - $entry .= "" . htmlspecialchars($msg) . "\n"; - $entry .= "" . htmlspecialchars($msg) . "\n"; - $entry .= "\n"; - $entry .= "". $notice->uri . "\n"; - $entry .= "".common_date_w3dtf($notice->created)."\n"; - $entry .= "".common_date_w3dtf($notice->modified)."\n"; - if ($notice->reply_to) { - $replyurl = common_local_url('shownotice', - array('notice' => $notice->reply_to)); - $entry .= "\n"; + $entry = $notice->asAtomEntry(true, true); + + $xs = new XMLStringer(); + $xs->elementStart('html', array('xmlns' => 'http://jabber.org/protocol/xhtml-im')); + $xs->elementStart('body', array('xmlns' => 'http://www.w3.org/1999/xhtml')); + $xs->element('a', array('href' => $profile->profileurl), + $profile->nickname); + $xs->text(": "); + if (!empty($notice->rendered)) { + $xs->raw($notice->rendered); + } else { + $xs->raw(common_render_content($notice->content, $notice)); } - $entry .= "\n"; - - $html = "\n\n"; - $html .= "\n"; - $html .= "".$profile->nickname.": "; - $html .= ($notice->rendered) ? $notice->rendered : common_render_content($notice->content, $notice); - $html .= "\n\n"; - $html .= "\n\n"; - - $address = "\n"; - $address .= "
\n"; - $address .= "\n"; + $xs->elementEnd('body'); + $xs->elementEnd('html'); - // FIXME: include a pubsub event, too. + $html = $xs->asString(); - return $html . $entry . $address; + return $html . ' ' . $entry; } /** -- cgit v1.2.3-54-g00ecf