diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-04-27 15:28:36 -0400 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-04-27 15:28:36 -0400 |
commit | 8cf8298dc02b1373fed53eb95982a33b969b42ee (patch) | |
tree | fdba11df68fc6d6bbe116d0463c2ef9e374015fd | |
parent | 7405d9dfa684975309150537069a1268a67ed6be (diff) | |
parent | e97223b2ba3f9f1818ba12b707c53c0ebdcab144 (diff) |
Merge branch 'cometplugin' into 0.7.x
-rw-r--r-- | plugins/Comet/CometPlugin.php | 37 | ||||
-rw-r--r-- | plugins/Comet/updatetimeline.js | 12 |
2 files changed, 48 insertions, 1 deletions
diff --git a/plugins/Comet/CometPlugin.php b/plugins/Comet/CometPlugin.php index a7a4f4b23..2e0bb40a4 100644 --- a/plugins/Comet/CometPlugin.php +++ b/plugins/Comet/CometPlugin.php @@ -62,6 +62,14 @@ class CometPlugin extends Plugin case 'public': $timeline = '/timelines/public'; break; + case 'tag': + $tag = $action->trimmed('tag'); + if (!empty($tag)) { + $timeline = '/timelines/tag/'.$tag; + } else { + return true; + } + break; default: return true; } @@ -94,6 +102,14 @@ class CometPlugin extends Plugin $timelines[] = '/timelines/public'; } + $tags = $this->getNoticeTags($notice); + + if (!empty($tags)) { + foreach ($tags as $tag) { + $timelines[] = '/timelines/tag/' . $tag; + } + } + if (count($timelines) > 0) { // Require this, since we need it require_once(INSTALLDIR.'/plugins/Comet/bayeux.class.inc.php'); @@ -127,6 +143,7 @@ class CometPlugin extends Plugin $arr = $act->twitter_status_array($notice, true); $arr['url'] = $notice->bestUrl(); + $arr['html'] = htmlspecialchars($notice->rendered); $profile = $notice->getProfile(); $arr['user']['profile_url'] = $profile->profileurl; @@ -134,6 +151,26 @@ class CometPlugin extends Plugin return $arr; } + function getNoticeTags($notice) + { + $tags = null; + + $nt = new Notice_tag(); + $nt->notice_id = $notice->id; + + if ($nt->find()) { + $tags = array(); + while ($nt->fetch()) { + $tags[] = $nt->tag; + } + } + + $nt->free(); + $nt = null; + + return $tags; + } + // Push this up to Plugin function log($level, $msg) diff --git a/plugins/Comet/updatetimeline.js b/plugins/Comet/updatetimeline.js index c6eefb447..de750baba 100644 --- a/plugins/Comet/updatetimeline.js +++ b/plugins/Comet/updatetimeline.js @@ -23,6 +23,14 @@ var updater = function() function receive(message) { + id = message.data.id; + + // Don't add it if it already exists + + if ($("#notice-"+id).length > 0) { + return; + } + var noticeItem = makeNoticeItem(message.data); $("#notices_primary .notices").prepend(noticeItem, true); $("#notices_primary .notice:first").css({display:"none"}); @@ -34,6 +42,8 @@ var updater = function() function makeNoticeItem(data) { user = data['user']; + html = data['html'].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); + ni = "<li class=\"hentry notice\" id=\"notice-"+data['id']+"\">"+ "<div class=\"entry-title\">"+ "<span class=\"vcard author\">"+ @@ -42,7 +52,7 @@ var updater = function() "<span class=\"nickname fn\">"+user['screen_name']+"</span>"+ "</a>"+ "</span>"+ - "<p class=\"entry-content\">"+data['text']+"</p>"+ + "<p class=\"entry-content\">"+html+"</p>"+ "</div>"+ "<div class=\"entry-content\">"+ "<dl class=\"timestamp\">"+ |