From a9cf185e692fdc9dea2a9b127826ea8e0f9f1021 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 15 Sep 2009 13:53:16 +0000 Subject: Updated XHR return markup for Realtime plugin --- plugins/Realtime/realtimeupdate.js | 42 +++++++++----------------------------- 1 file changed, 10 insertions(+), 32 deletions(-) (limited to 'plugins/Realtime') diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index d55db5859..eba8ac1d9 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -1,8 +1,8 @@ // add a notice encoded as JSON into the current timeline // +// TODO: i18n RealtimeUpdate = { - _userid: 0, _replyurl: '', _favorurl: '', @@ -50,26 +50,15 @@ RealtimeUpdate = { "

"+html+"

"+ ""+ "
"+ - "
"+ - "
Published
"+ - "
"+ - ""+ + ""+ "a few seconds ago"+ " "+ - "
"+ - "
"+ - "
"+ - "
From
"+ - "
"+source+"
"+ // may have a link, I think - "
"; - + ""+ + "from "+ + "+source+"++ // may have a link + ""; if (data['in_reply_to_status_id']) { - ni = ni+"
"+ - "
To
"+ - "
"+ - "in reply to"+ - "
"+ - "
"; + ni = ni+" in context"; } ni = ni+"
"+ @@ -96,7 +85,7 @@ RealtimeUpdate = { ff = "
"+ "
"+ - "Favor this notice"+ // XXX: i18n + "Favor this notice"+ ""+ ""+ ""+ @@ -108,13 +97,7 @@ RealtimeUpdate = { makeReplyLink: function(id, nickname) { var rl; - rl = "
"+ - "
Reply to this notice
"+ - "
"+ - "Reply "+id+""+ - ""+ - "
"+ - "
"; + rl = "Reply "+id+""; return rl; }, @@ -123,12 +106,7 @@ RealtimeUpdate = { var dl, delurl; delurl = RealtimeUpdate._deleteurl.replace("0000000000", id); - dl = "
"+ - "
Delete this notice
"+ - "
"+ - "Delete"+ - "
"+ - "
"; + dl = "Delete"; return dl; }, -- cgit v1.2.3-54-g00ecf From 6568a3202d3acfde694b359e2524d52d93dc83dd Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 16 Sep 2009 13:29:46 +0000 Subject: Fixed typo --- plugins/Realtime/realtimeupdate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/Realtime') diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index eba8ac1d9..b2c8bb56d 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -55,7 +55,7 @@ RealtimeUpdate = { " "+ ""+ "from "+ - "+source+"++ // may have a link + "+source+"+ // may have a link ""; if (data['in_reply_to_status_id']) { ni = ni+" in context"; -- cgit v1.2.3-54-g00ecf From d9953e015b593965150bb528536f1f90674620ae Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 16 Sep 2009 16:04:19 +0000 Subject: Fixed missing quotes --- plugins/Realtime/realtimeupdate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/Realtime') diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index b2c8bb56d..faec8d89c 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -55,7 +55,7 @@ RealtimeUpdate = { " "+ ""+ "from "+ - "+source+"+ // may have a link + ""+source+""+ // may have a link ""; if (data['in_reply_to_status_id']) { ni = ni+" in context"; -- cgit v1.2.3-54-g00ecf From 49e91ec7d068fa7b98576207696d2192418baf5b Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Sun, 20 Sep 2009 15:14:46 +0000 Subject: Added realtime streams for all and showstream timelines --- plugins/Meteor/meteorupdater.js | 11 ++++++++++- plugins/Realtime/RealtimePlugin.php | 34 +++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 16 deletions(-) (limited to 'plugins/Realtime') diff --git a/plugins/Meteor/meteorupdater.js b/plugins/Meteor/meteorupdater.js index 2e688336f..e8bca3eb4 100644 --- a/plugins/Meteor/meteorupdater.js +++ b/plugins/Meteor/meteorupdater.js @@ -7,8 +7,17 @@ var MeteorUpdater = function() init: function(server, port, timeline) { + var screen_name; + Meteor.callbacks["process"] = function(data) { - RealtimeUpdate.receive(JSON.parse(data)); + var d = JSON.parse(data); + screen_name = d['user']['screen_name']; + + if (timeline == 'public' || + $('address .url')[0].href+screen_name+'/all' == window.location.href || + $('address .url')[0].href+screen_name == window.location.href) { + RealtimeUpdate.receive(d); + } }; Meteor.host = server; diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index 82eca3d08..1703ef099 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -63,20 +63,22 @@ class RealtimePlugin extends Plugin { $path = null; - switch ($action->trimmed('action')) { - case 'public': - $path = array('public'); - break; - case 'tag': - $tag = $action->trimmed('tag'); - if (!empty($tag)) { - $path = array('tag', $tag); - } else { + $a = $action->trimmed('action'); + + switch ($a) { + case 'public': case 'all': case 'replies': case 'showstream': + $path = array($a); + break; + case 'tag': + $tag = $action->trimmed('tag'); + if (!empty($tag)) { + $path = array('tag', $tag); + } else { + return true; + } + break; + default: return true; - } - break; - default: - return true; } $timeline = $this->_pathToChannel($path); @@ -108,11 +110,13 @@ class RealtimePlugin extends Plugin { $paths = array(); - // XXX: Add other timelines; this is just for the public one + // TODO: Replies timeline if ($notice->is_local || ($notice->is_local == 0 && !common_config('public', 'localonly'))) { - $paths[] = array('public'); + foreach (array('public', 'all', 'replies', 'showstream') as $a) { + $paths[] = array($a); + } } $tags = $this->getNoticeTags($notice); -- cgit v1.2.3-54-g00ecf From 470b34ea47ff97bbcbffb49c8a456da358b29578 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 21 Sep 2009 18:30:22 +0000 Subject: Escaping internal JavaScript --- plugins/Realtime/RealtimePlugin.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'plugins/Realtime') diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index 1703ef099..7a612a406 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -98,9 +98,13 @@ class RealtimePlugin extends Plugin } $action->elementStart('script', array('type' => 'text/javascript')); - $action->raw("$(document).ready(function() { "); - $action->raw($this->_updateInitialize($timeline, $user_id)); - $action->raw(" });"); + $action->raw(' + + '); $action->elementEnd('script'); return true; -- cgit v1.2.3-54-g00ecf From acd5a53257f6d0677d1630e4f6cae80706cdbdba Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 21 Sep 2009 19:17:37 +0000 Subject: Initial UI to allow certain timelines to be viewed in a new window in realtime --- plugins/Realtime/RealtimePlugin.php | 2 + plugins/Realtime/icon_external.gif | Bin 0 -> 90 bytes plugins/Realtime/jquery.getUrlParam.js | 72 +++++++++ plugins/Realtime/realtimeupdate.js | 263 +++++++++++++++++++-------------- 4 files changed, 225 insertions(+), 112 deletions(-) create mode 100644 plugins/Realtime/icon_external.gif create mode 100644 plugins/Realtime/jquery.getUrlParam.js (limited to 'plugins/Realtime') diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index 7a612a406..611b1d86c 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -97,6 +97,8 @@ class RealtimePlugin extends Plugin $user_id = 0; } + $action->script('plugins/Realtime/jquery.getUrlParam.js'); + $action->elementStart('script', array('type' => 'text/javascript')); $action->raw(' - '); + + $script = ' $(document).ready(function() { '. + $this->_updateInitialize($timeline, $user_id). + '}); '; + + $action->raw($script); + $action->elementEnd('script'); return true; @@ -146,6 +139,47 @@ class RealtimePlugin extends Plugin return true; } + function onStartShowPageNotice($action) + { + $timeline = $this->_getTimeline($action); + if (!empty($timeline)) { + $base = $action->selfUrl(); + if (mb_strstr($url, '?')) { + $url = $base . '&realtime=1'; + } else { + $url = $base . '?realtime=1'; + } + $title = $action->title(); + $code = "window.open('$url', '$title', 'toolbar=no,resizable=yes,scrollbars=yes,status=yes,height=640,width=575');"; + $action->element('a', array('href' => $base, + 'onclick' => $code, + 'id' => 'realtime_timeline', + 'title' => _('Pop up')), + 'Pop up'); + + } + return true; + } + + function onStartShowBody($action) + { + $realtime = $action->boolean('realtime'); + if (!$realtime) { + return true; + } + + $action->elementStart('body', + (common_current_user()) ? array('id' => $action->trimmed('action'), + 'class' => 'user_in') + : array('id' => $action->trimmed('action'))); + if (common_logged_in()) { + $action->showNoticeForm(); + } + $action->showContent(); + $action->elementEnd('body'); + return false; // No default processing + } + function noticeAsJson($notice) { // FIXME: this code should be abstracted to a neutral third @@ -230,4 +264,30 @@ class RealtimePlugin extends Plugin { return ''; } + + function _getTimeline($action) + { + $path = null; + $timeline = null; + + switch ($action->trimmed('action')) { + case 'public': + $path = array('public'); + break; + case 'tag': + $tag = $action->trimmed('tag'); + if (!empty($tag)) { + $path = array('tag', $tag); + } + break; + default: + break; + } + + if (!is_null($path)) { + $timeline = $this->_pathToChannel($path); + } + + return $timeline; + } } diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index da2f9ed3a..3293ef6e9 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -1,152 +1,114 @@ -$(document).ready(function() { - if (!$(document).getUrlParam('realtime')) { - $('#site_nav_local_views .current a').append(''); - - $('#realtime_timeline').css({ - 'margin':'2px 0 0 11px', - 'background':'transparent url('+$('address .url')[0].href+'/plugins/Realtime/icon_external.gif) no-repeat 45% 45%', - 'text-indent':'-9999px', - 'width':'16px', - 'height':'16px', - 'padding':'0', - 'display':'block', - 'float':'right', - 'border':'none', - 'cursor':'pointer' - }); - - $('#realtime_timeline').click(function() { - window.open($(this).parent('a').attr('href')+'?realtime=1', - $(this).parent('a').attr('title'), - 'toolbar=no,resizable=yes,scrollbars=yes,status=yes'); - - return false; - }); - } - else { - window.resizeTo(575, 640); - address = $('address'); - content = $('#content'); - $('body').html(address); - $('address').hide(); - $('body').append(content); - $('#content').css({'width':'92%'}); - } - - - // add a notice encoded as JSON into the current timeline - // - // TODO: i18n - - RealtimeUpdate = { - _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; - - // Don't add it if it already exists - - if ($("#notice-"+id).length > 0) { - return; - } - - var noticeItem = RealtimeUpdate.makeNoticeItem(data); - $("#notices_primary .notices").prepend(noticeItem, true); - $("#notices_primary .notice:first").css({display:"none"}); - $("#notices_primary .notice:first").fadeIn(1000); - NoticeReply(); - }, - - makeNoticeItem: function(data) - { - user = data['user']; - html = data['html'].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"'); - source = data['source'].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"'); - - ni = "
  • "+ - "
    "+ - ""+ - ""+ - "\""+user['screen_name']+"\"/"+ - ""+user['screen_name']+""+ - ""+ - ""+ - "

    "+html+"

    "+ - "
    "+ - "
    "+ - ""+ - "a few seconds ago"+ - " "+ - ""+ - "from "+ +// add a notice encoded as JSON into the current timeline +// +// TODO: i18n + +RealtimeUpdate = { + _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; + + // Don't add it if it already exists + // + if ($("#notice-"+id).length > 0) { + return; + } + + var noticeItem = RealtimeUpdate.makeNoticeItem(data); + $("#notices_primary .notices").prepend(noticeItem, true); + $("#notices_primary .notice:first").css({display:"none"}); + $("#notices_primary .notice:first").fadeIn(1000); + NoticeReply(); + }, + + makeNoticeItem: function(data) + { + user = data['user']; + html = data['html'].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"'); + source = data['source'].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"'); + + ni = "
  • "+ + "
    "+ + ""+ + ""+ + "\""+user['screen_name']+"\"/"+ + ""+user['screen_name']+""+ + ""+ + ""+ + "

    "+html+"

    "+ + "
    "+ + "
    "+ + ""+ + "a few seconds ago"+ + " "+ + ""+ + "from "+ ""+source+""+ // may have a link - ""; - if (data['in_reply_to_status_id']) { - ni = ni+" in context"; - } + ""; + if (data['in_reply_to_status_id']) { + ni = ni+" in context"; + } - ni = ni+"
    "+ + ni = ni+""+ "
    "; - 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 (RealtimeUpdate._userid == data['user']['id']) { + 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 (RealtimeUpdate._userid == data['user']['id']) { ni = ni+RealtimeUpdate.makeDeleteLink(data['id']); - } - } + } + } - ni = ni+"
    "+ - "
  • "; - return ni; - }, + ni = ni+""+ + ""; + return ni; + }, - makeFavoriteForm: function(id, session_key) - { - var ff; + makeFavoriteForm: function(id, session_key) + { + var ff; - ff = ""+ + ff = ""+ "
    "+ - "Favor this notice"+ - ""+ - ""+ - ""+ + "Favor this notice"+ + ""+ + ""+ + ""+ "
    "+ - ""; - return ff; + ""; + return ff; + }, + + makeReplyLink: function(id, nickname) + { + var rl; + rl = "Reply "+id+""; + return rl; }, - makeReplyLink: function(id, nickname) - { - var rl; - rl = "Reply "+id+""; - return rl; - }, - - makeDeleteLink: function(id) - { - var dl, delurl; - delurl = RealtimeUpdate._deleteurl.replace("0000000000", id); - - dl = "Delete"; + makeDeleteLink: function(id) + { + var dl, delurl; + delurl = RealtimeUpdate._deleteurl.replace("0000000000", id); - return dl; - } - } + dl = "Delete"; -}); + return dl; + } +} -- cgit v1.2.3-54-g00ecf From 5152d31d2a4199306d656480ca5ff8d0978d8984 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 23 Sep 2009 17:28:14 -0400 Subject: Add some more realtime feeds --- plugins/Realtime/RealtimePlugin.php | 67 +++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 3 deletions(-) (limited to 'plugins/Realtime') diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index 22851a6c1..0f3e31071 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -107,13 +107,23 @@ class RealtimePlugin extends Plugin { $paths = array(); - // XXX: Add other timelines; this is just for the public one + // Add to the author's timeline + + $user = User::staticGet('id', $notice->profile_id); + + if (!empty($user)) { + $paths[] = array('showstream', $user->nickname); + } + + // Add to the public timeline if ($notice->is_local || ($notice->is_local == 0 && !common_config('public', 'localonly'))) { $paths[] = array('public'); } + // Add to the tags timeline + $tags = $this->getNoticeTags($notice); if (!empty($tags)) { @@ -122,6 +132,46 @@ class RealtimePlugin extends Plugin } } + // Add to inbox timelines + // XXX: do a join + + $inbox = new Notice_inbox(); + $inbox->notice_id = $notice->id; + + if ($inbox->find()) { + while ($inbox->fetch()) { + $user = User::staticGet('id', $inbox->user_id); + $paths[] = array('all', $user->nickname); + } + } + + // Add to the replies timeline + + $reply = new Reply(); + $reply->notice_id = $notice->id; + + if ($reply->find()) { + while ($reply->fetch()) { + $user = User::staticGet('id', $reply->profile_id); + if (!empty($user)) { + $paths[] = array('replies', $user->nickname); + } + } + } + + // Add to the group timeline + // XXX: join + + $gi = new Group_inbox(); + $gi->notice_id = $notice->id; + + if ($gi->find()) { + while ($gi->fetch()) { + $ug = User_group::staticGet('id', $gi->group_id); + $paths[] = array('showgroup', $ug->nickname); + } + } + if (count($paths) > 0) { $json = $this->noticeAsJson($notice); @@ -270,7 +320,9 @@ class RealtimePlugin extends Plugin $path = null; $timeline = null; - switch ($action->trimmed('action')) { + $action_name = $action->trimmed('action'); + + switch ($action_name) { case 'public': $path = array('public'); break; @@ -280,11 +332,20 @@ class RealtimePlugin extends Plugin $path = array('tag', $tag); } break; + case 'showstream': + case 'all': + case 'replies': + case 'showgroup': + $nickname = common_canonical_nickname($action->trimmed('nickname')); + if (!empty($nickname)) { + $path = array($action_name, $nickname); + } + break; default: break; } - if (!is_null($path)) { + if (!empty($path)) { $timeline = $this->_pathToChannel($path); } -- cgit v1.2.3-54-g00ecf From 36e009349d68d8f34fc50d77c26e6e3307116b2c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 23 Sep 2009 14:58:42 -0400 Subject: hack around address hack in util.js --- plugins/Realtime/RealtimePlugin.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'plugins/Realtime') diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index 0f3e31071..c41c9ce4a 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -222,6 +222,16 @@ class RealtimePlugin extends Plugin (common_current_user()) ? array('id' => $action->trimmed('action'), 'class' => 'user_in') : array('id' => $action->trimmed('action'))); + + // XXX hack to deal with JS that tries to get the + // root url from page output + + $action->elementStart('address'); + $action->element('a', array('class' => 'url', + 'href' => common_local_url('public')), + ''); + $action->elementEnd('address'); + if (common_logged_in()) { $action->showNoticeForm(); } -- cgit v1.2.3-54-g00ecf From bdbc2cb8de370eef6d5d06412746f52797ea0458 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 23 Sep 2009 15:24:12 -0400 Subject: move some stuff around for realtime --- plugins/Realtime/RealtimePlugin.php | 32 ++++++++++---------------------- plugins/Realtime/realtimeupdate.js | 5 +++++ 2 files changed, 15 insertions(+), 22 deletions(-) (limited to 'plugins/Realtime') diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index c41c9ce4a..fde306021 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -76,6 +76,15 @@ class RealtimePlugin extends Plugin return true; } + $base = $action->selfUrl(); + if (mb_strstr($url, '?')) { + $url = $base . '&realtime=1'; + } else { + $url = $base . '?realtime=1'; + } + + $title = $action->title(); + $scripts = $this->_getScripts(); foreach ($scripts as $script) { @@ -94,6 +103,7 @@ class RealtimePlugin extends Plugin $script = ' $(document).ready(function() { '. $this->_updateInitialize($timeline, $user_id). + ' RealtimeUpdate.addPopup("'.$url.'", "'.$title.'"); '. '}); '; $action->raw($script); @@ -189,28 +199,6 @@ class RealtimePlugin extends Plugin return true; } - function onStartShowPageNotice($action) - { - $timeline = $this->_getTimeline($action); - if (!empty($timeline)) { - $base = $action->selfUrl(); - if (mb_strstr($url, '?')) { - $url = $base . '&realtime=1'; - } else { - $url = $base . '?realtime=1'; - } - $title = $action->title(); - $code = "window.open('$url', '$title', 'toolbar=no,resizable=yes,scrollbars=yes,status=yes,height=640,width=575');"; - $action->element('a', array('href' => $base, - 'onclick' => $code, - 'id' => 'realtime_timeline', - 'title' => _('Pop up')), - 'Pop up'); - - } - return true; - } - function onStartShowBody($action) { $realtime = $action->boolean('realtime'); diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index 3293ef6e9..04e07956d 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -109,6 +109,11 @@ RealtimeUpdate = { dl = "Delete"; return dl; + }, + + addPopup: function(url, title) + { + // FIXME: need to add the realtime popup button here } } -- cgit v1.2.3-54-g00ecf From 4d4bb089a5e3addfd4be2f82e5e4e257070f4058 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 23 Sep 2009 21:58:35 +0000 Subject: Created addPop() for Realtime plugin and added param to include iconurl --- plugins/Realtime/RealtimePlugin.php | 4 +++- plugins/Realtime/realtimeupdate.js | 25 +++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) (limited to 'plugins/Realtime') diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index fde306021..157c800d9 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -99,11 +99,13 @@ class RealtimePlugin extends Plugin $user_id = 0; } + $iconurl = $base.'plugins/Realtime/icon_external.gif'; + $action->elementStart('script', array('type' => 'text/javascript')); $script = ' $(document).ready(function() { '. $this->_updateInitialize($timeline, $user_id). - ' RealtimeUpdate.addPopup("'.$url.'", "'.$title.'"); '. + ' RealtimeUpdate.addPopup("'.$url.'", "'.$title.'", "'. $iconurl .'");' '}); '; $action->raw($script); diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index 04e07956d..2910e4a80 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -111,9 +111,30 @@ RealtimeUpdate = { return dl; }, - addPopup: function(url, title) + addPopup: function(url, title, iconurl) { - // FIXME: need to add the realtime popup button here + $('#site_nav_local_views .current a').append(''); + + $('#realtime_timeline').css({ + 'margin':'2px 0 0 11px', + 'background':'transparent url('+ iconurl + ') no-repeat 45% 45%', + 'text-indent':'-9999px', + 'width':'16px', + 'height':'16px', + 'padding':'0', + 'display':'block', + 'float':'right', + 'border':'none', + 'cursor':'pointer' + }); + + $('#realtime_timeline').click(function() { + window.open(url, + title, + 'toolbar=no,resizable=yes,scrollbars=yes,status=yes'); + + return false; + }); } } -- cgit v1.2.3-54-g00ecf From ddb9518c9949989f99c3e7b0323c9bbd01c1d5ee Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 23 Sep 2009 22:00:22 +0000 Subject: Some layout and rendering adjustment for Realtime plugin --- plugins/Realtime/RealtimePlugin.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'plugins/Realtime') diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index 157c800d9..f211c01f9 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -213,9 +213,9 @@ class RealtimePlugin extends Plugin 'class' => 'user_in') : array('id' => $action->trimmed('action'))); + $action->elementStart('div', array('id' => 'header')); // XXX hack to deal with JS that tries to get the // root url from page output - $action->elementStart('address'); $action->element('a', array('class' => 'url', 'href' => common_local_url('public')), @@ -225,7 +225,9 @@ class RealtimePlugin extends Plugin if (common_logged_in()) { $action->showNoticeForm(); } - $action->showContent(); + $action->elementEnd('div'); + + $action->showContentBlock(); $action->elementEnd('body'); return false; // No default processing } -- cgit v1.2.3-54-g00ecf From 1f12993a4ddad8eba29c604c55f6b82d08dc0127 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 23 Sep 2009 22:02:42 +0000 Subject: Added JavaScript to initialize the poped Window --- plugins/Realtime/RealtimePlugin.php | 13 ++++++++++--- plugins/Realtime/realtimeupdate.js | 7 +++++++ 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'plugins/Realtime') diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index f211c01f9..4fb8bf84e 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -99,15 +99,22 @@ class RealtimePlugin extends Plugin $user_id = 0; } - $iconurl = $base.'plugins/Realtime/icon_external.gif'; + // FIXME: Need to check if the current URL is a poped realtime window + if (1==2) { + $realtimeUI = ' RealtimeUpdate.initPopupWindow();'; + } + else { + // FIXME: This icon URL is no good if fancy URLs are off. + $iconurl = $base.'plugins/Realtime/icon_external.gif'; + $realtimeUI = ' RealtimeUpdate.addPopup("'.$url.'", "'.$title.'", "'. $iconurl .'");'; + } $action->elementStart('script', array('type' => 'text/javascript')); $script = ' $(document).ready(function() { '. $this->_updateInitialize($timeline, $user_id). - ' RealtimeUpdate.addPopup("'.$url.'", "'.$title.'", "'. $iconurl .'");' + $realtimeUI. '}); '; - $action->raw($script); $action->elementEnd('script'); diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index 2910e4a80..4fda5079d 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -135,6 +135,13 @@ RealtimeUpdate = { return false; }); + }, + + initPopupWindow: function() + { + window.resizeTo(575, 640); + $('address').hide(); + $('#content').css({'width':'92%'}); } } -- cgit v1.2.3-54-g00ecf From d86155ad943032918c2fab070ca49f0a3586f25d Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 23 Sep 2009 22:04:39 +0000 Subject: Using timeline string instead of title for WindowName because IE doesn't like names with whitespace. --- plugins/Realtime/RealtimePlugin.php | 4 +--- plugins/Realtime/realtimeupdate.js | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'plugins/Realtime') diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index 4fb8bf84e..7334f5657 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -83,8 +83,6 @@ class RealtimePlugin extends Plugin $url = $base . '?realtime=1'; } - $title = $action->title(); - $scripts = $this->_getScripts(); foreach ($scripts as $script) { @@ -106,7 +104,7 @@ class RealtimePlugin extends Plugin else { // FIXME: This icon URL is no good if fancy URLs are off. $iconurl = $base.'plugins/Realtime/icon_external.gif'; - $realtimeUI = ' RealtimeUpdate.addPopup("'.$url.'", "'.$title.'", "'. $iconurl .'");'; + $realtimeUI = ' RealtimeUpdate.addPopup("'.$url.'", "'.$timeline.'", "'. $iconurl .'");'; } $action->elementStart('script', array('type' => 'text/javascript')); diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index 4fda5079d..57fe0a843 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -111,7 +111,7 @@ RealtimeUpdate = { return dl; }, - addPopup: function(url, title, iconurl) + addPopup: function(url, timeline, iconurl) { $('#site_nav_local_views .current a').append(''); @@ -130,7 +130,7 @@ RealtimeUpdate = { $('#realtime_timeline').click(function() { window.open(url, - title, + timeline, 'toolbar=no,resizable=yes,scrollbars=yes,status=yes'); return false; -- cgit v1.2.3-54-g00ecf From 543e3e797277526ac0f0c6ac99be64897955258a Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 23 Sep 2009 23:04:25 -0400 Subject: some UI fixes --- plugins/Realtime/RealtimePlugin.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'plugins/Realtime') diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index 7334f5657..e30c41156 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -77,7 +77,7 @@ class RealtimePlugin extends Plugin } $base = $action->selfUrl(); - if (mb_strstr($url, '?')) { + if (mb_strstr($base, '?')) { $url = $base . '&realtime=1'; } else { $url = $base . '?realtime=1'; @@ -97,21 +97,19 @@ class RealtimePlugin extends Plugin $user_id = 0; } - // FIXME: Need to check if the current URL is a poped realtime window - if (1==2) { + if ($action->boolean('realtime')) { $realtimeUI = ' RealtimeUpdate.initPopupWindow();'; } else { - // FIXME: This icon URL is no good if fancy URLs are off. - $iconurl = $base.'plugins/Realtime/icon_external.gif'; + $iconurl = common_path('plugins/Realtime/icon_external.gif'); $realtimeUI = ' RealtimeUpdate.addPopup("'.$url.'", "'.$timeline.'", "'. $iconurl .'");'; } $action->elementStart('script', array('type' => 'text/javascript')); $script = ' $(document).ready(function() { '. - $this->_updateInitialize($timeline, $user_id). $realtimeUI. + $this->_updateInitialize($timeline, $user_id). '}); '; $action->raw($script); @@ -219,8 +217,10 @@ class RealtimePlugin extends Plugin : array('id' => $action->trimmed('action'))); $action->elementStart('div', array('id' => 'header')); + // XXX hack to deal with JS that tries to get the // root url from page output + $action->elementStart('address'); $action->element('a', array('class' => 'url', 'href' => common_local_url('public')), -- cgit v1.2.3-54-g00ecf