diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-07-14 17:06:29 -0400 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-07-14 17:06:29 -0400 |
commit | 420980f0e0cd1023902b23d4082a0734d16c67a5 (patch) | |
tree | 09828e6839bc482b39ee9b19da96cff340786f37 /plugins/Realtime | |
parent | 5ab718bf22fda29dc30fbd004f7866af82eeb879 (diff) |
changes to make realtime work for Meteor
Diffstat (limited to 'plugins/Realtime')
-rw-r--r-- | plugins/Realtime/RealtimePlugin.php | 14 | ||||
-rw-r--r-- | plugins/Realtime/realtimeupdate.js | 39 |
2 files changed, 32 insertions, 21 deletions
diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index c9483f991..d01da5a50 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -65,12 +65,12 @@ class RealtimePlugin extends Plugin switch ($action->trimmed('action')) { case 'public': - $timeline = '/timelines/public'; + $timeline = 'timelines-public'; break; case 'tag': $tag = $action->trimmed('tag'); if (!empty($tag)) { - $timeline = '/timelines/tag/'.$tag; + $timeline = 'timelines-tag-'.$tag; } else { return true; } @@ -112,14 +112,14 @@ class RealtimePlugin extends Plugin if ($notice->is_local || ($notice->is_local == 0 && !common_config('public', 'localonly'))) { - $timelines[] = '/timelines/public'; + $timelines[] = 'timelines-public'; } $tags = $this->getNoticeTags($notice); if (!empty($tags)) { foreach ($tags as $tag) { - $timelines[] = '/timelines/tag/' . $tag; + $timelines[] = 'timelines-tag-' . $tag; } } @@ -198,13 +198,13 @@ class RealtimePlugin extends Plugin function _getScripts() { - return array(common_local_path('plugins/Realtime/realtimeupdater.js'), - common_local_path('plugins/Realtime/json2.js')); + return array(common_path('plugins/Realtime/realtimeupdate.js'), + common_path('plugins/Realtime/json2.js')); } function _updateInitialize($timeline, $user_id) { - return '; '; + return "RealtimeUpdate.init($user_id, \"$this->replyurl\", \"$this->favorurl\", \"$this->deleteurl\"); "; } function _connect() diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index 9ad808740..d55db5859 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -3,7 +3,20 @@ RealtimeUpdate = { - receive: function(message) + _userid: 0, + _replyurl: '', + _favorurl: '', + _deleteurl: '', + + init: function(userid, replyurl, favorurl, deleteurl) + { + RealtimeUpdate._userid = userid; + RealtimeUpdate._replyurl = replyurl; + RealtimeUpdate._favorurl = favorurl; + RealtimeUpdate._deleteurl = deleteurl; + }, + + receive: function(data) { id = data.id; @@ -17,9 +30,8 @@ RealtimeUpdate = { $("#notices_primary .notices").prepend(noticeItem, true); $("#notices_primary .notice:first").css({display:"none"}); $("#notices_primary .notice:first").fadeIn(1000); - NoticeHover(); NoticeReply(); - } + }, makeNoticeItem: function(data) { @@ -63,12 +75,12 @@ RealtimeUpdate = { ni = ni+"</div>"+ "<div class=\"notice-options\">"; - if (_userid != 0) { + if (RealtimeUpdate._userid != 0) { var input = $("form#form_notice fieldset input#token"); var session_key = input.val(); ni = ni+RealtimeUpdate.makeFavoriteForm(data['id'], session_key); ni = ni+RealtimeUpdate.makeReplyLink(data['id'], data['user']['screen_name']); - if (_userid == data['user']['id']) { + if (RealtimeUpdate._userid == data['user']['id']) { ni = ni+RealtimeUpdate.makeDeleteLink(data['id']); } } @@ -76,13 +88,13 @@ RealtimeUpdate = { ni = ni+"</div>"+ "</li>"; return ni; - } + }, makeFavoriteForm: function(id, session_key) { var ff; - ff = "<form id=\"favor-"+id+"\" class=\"form_favor\" method=\"post\" action=\""+_favorurl+"\">"+ + ff = "<form id=\"favor-"+id+"\" class=\"form_favor\" method=\"post\" action=\""+RealtimeUpdate._favorurl+"\">"+ "<fieldset>"+ "<legend>Favor this notice</legend>"+ // XXX: i18n "<input name=\"token-"+id+"\" type=\"hidden\" id=\"token-"+id+"\" value=\""+session_key+"\"/>"+ @@ -91,7 +103,7 @@ RealtimeUpdate = { "</fieldset>"+ "</form>"; return ff; - } + }, makeReplyLink: function(id, nickname) { @@ -99,17 +111,17 @@ RealtimeUpdate = { rl = "<dl class=\"notice_reply\">"+ "<dt>Reply to this notice</dt>"+ "<dd>"+ - "<a href=\""+_replyurl+"?replyto="+nickname+"\" title=\"Reply to this notice\">Reply <span class=\"notice_id\">"+id+"</span>"+ + "<a href=\""+RealtimeUpdate._replyurl+"?replyto="+nickname+"\" title=\"Reply to this notice\">Reply <span class=\"notice_id\">"+id+"</span>"+ "</a>"+ "</dd>"+ "</dl>"; return rl; - } + }, makeDeleteLink: function(id) { var dl, delurl; - delurl = _deleteurl.replace("0000000000", id); + delurl = RealtimeUpdate._deleteurl.replace("0000000000", id); dl = "<dl class=\"notice_delete\">"+ "<dt>Delete this notice</dt>"+ @@ -119,6 +131,5 @@ RealtimeUpdate = { "</dl>"; return dl; - } -}; - + }, +} |