From ed2d224df5e52b2fe5ef5f076d147791e48c4dcf Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 14 Mar 2011 12:22:49 -0700 Subject: [PATCH 1/5] Check the site minifications etting for realtime plugin; debugging aid. --- plugins/Realtime/RealtimePlugin.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index 246b1f9735..f617c39060 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -323,7 +323,12 @@ class RealtimePlugin extends Plugin function _getScripts() { - return array(Plugin::staticPath('Realtime', 'realtimeupdate.min.js')); + if (common_config('site', 'minify')) { + $js = 'realtimeupdate.min.js'; + } else { + $js = 'realtimeupdate.js'; + } + return array(Plugin::staticPath('Realtime', $js)); } /** From 1e36593a23bd8e50e50d115c28a7f8fa024fb768 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 14 Mar 2011 12:32:39 -0700 Subject: [PATCH 2/5] Realtime work in progress: switch makeNoticeData to async -- next we'll load fresh copies from server, maintaining proper language and plugin enhancements. --- plugins/Realtime/realtimeupdate.js | 82 +++++++++++++++--------------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index e615895cab..73516a8ed9 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -163,50 +163,51 @@ RealtimeUpdate = { return; } - var noticeItem = RealtimeUpdate.makeNoticeItem(data); - var noticeItemID = $(noticeItem).attr('id'); + RealtimeUpdate.makeNoticeItem(data, function(noticeItem) { + var noticeItemID = $(noticeItem).attr('id'); - var list = $("#notices_primary .notices:first") - var prepend = true; + var list = $("#notices_primary .notices:first") + var prepend = true; - var threaded = list.hasClass('threaded-notices'); - if (threaded && data.in_reply_to_status_id) { - // aho! - var parent = $('#notice-' + data.in_reply_to_status_id); - if (parent.length == 0) { - // @todo fetch the original, insert it, and finish the rest - } else { - // Check the parent notice to make sure it's not a reply itself. - // If so, use it's parent as the parent. - var parentList = parent.closest('.notices'); - if (parentList.hasClass('threaded-replies')) { - parent = parentList.closest('.notice'); + var threaded = list.hasClass('threaded-notices'); + if (threaded && data.in_reply_to_status_id) { + // aho! + var parent = $('#notice-' + data.in_reply_to_status_id); + if (parent.length == 0) { + // @todo fetch the original, insert it, and finish the rest + } else { + // Check the parent notice to make sure it's not a reply itself. + // If so, use it's parent as the parent. + var parentList = parent.closest('.notices'); + if (parentList.hasClass('threaded-replies')) { + parent = parentList.closest('.notice'); + } + list = parent.find('.threaded-replies'); + if (list.length == 0) { + list = $(''); + parent.append(list); + } + prepend = false; } - list = parent.find('.threaded-replies'); - if (list.length == 0) { - list = $(''); - parent.append(list); - } - prepend = false; } - } - var newNotice = $(noticeItem); - if (prepend) { - list.prepend(newNotice); - } else { - var placeholder = list.find('li.notice-reply-placeholder') - if (placeholder.length > 0) { - newNotice.insertBefore(placeholder) + var newNotice = $(noticeItem); + if (prepend) { + list.prepend(newNotice); } else { - newNotice.appendTo(list); - SN.U.NoticeInlineReplyPlaceholder(parent); + var placeholder = list.find('li.notice-reply-placeholder') + if (placeholder.length > 0) { + newNotice.insertBefore(placeholder) + } else { + newNotice.appendTo(list); + SN.U.NoticeInlineReplyPlaceholder(parent); + } } - } - newNotice.css({display:"none"}).fadeIn(1000); + newNotice.css({display:"none"}).fadeIn(1000); - SN.U.NoticeReplyTo($('#'+noticeItemID)); - SN.U.NoticeWithAttachment($('#'+noticeItemID)); + SN.U.NoticeReplyTo($('#'+noticeItemID)); + SN.U.NoticeWithAttachment($('#'+noticeItemID)); + }); }, /** @@ -263,10 +264,11 @@ RealtimeUpdate = { }, /** - * Builds a notice HTML block from JSON API-style data. + * Builds a notice HTML block from JSON API-style data; + * loads data from server, so runs async. * * @param {Object} data: extended JSON API-formatted notice - * @return {String} HTML fragment + * @param {function} callback: function(str) to receive HTML fragment * * @fixme this replicates core StatusNet code, making maintenance harder * @fixme sloppy HTML building (raw concat without escaping) @@ -275,7 +277,7 @@ RealtimeUpdate = { * * @access private */ - makeNoticeItem: function(data) + makeNoticeItem: function(data, callback) { if (data.hasOwnProperty('retweeted_status')) { original = data['retweeted_status']; @@ -342,7 +344,7 @@ RealtimeUpdate = { ni = ni+""; ni = ni+""; - return ni; + callback(ni); }, /** From c7e7cc79da4255c42dbc8500fc5d6db25d1f90c3 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 14 Mar 2011 13:05:30 -0700 Subject: [PATCH 3/5] 'ajax' param on shownotice action so we can pull items in full html version for realtime --- actions/shownotice.php | 48 ++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/actions/shownotice.php b/actions/shownotice.php index 3978f03ea9..8d8ab326df 100644 --- a/actions/shownotice.php +++ b/actions/shownotice.php @@ -188,22 +188,27 @@ class ShownoticeAction extends OwnerDesignAction { parent::handle($args); - if ($this->notice->is_local == Notice::REMOTE_OMB) { - if (!empty($this->notice->url)) { - $target = $this->notice->url; - } else if (!empty($this->notice->uri) && preg_match('/^https?:/', $this->notice->uri)) { - // Old OMB posts saved the remote URL only into the URI field. - $target = $this->notice->uri; - } else { - // Shouldn't happen. - $target = false; - } - if ($target && $target != $this->selfUrl()) { - common_redirect($target, 301); - return false; + if ($this->boolean('ajax')) { + StatusNet::setApi(true); + $this->showAjax(); + } else { + if ($this->notice->is_local == Notice::REMOTE_OMB) { + if (!empty($this->notice->url)) { + $target = $this->notice->url; + } else if (!empty($this->notice->uri) && preg_match('/^https?:/', $this->notice->uri)) { + // Old OMB posts saved the remote URL only into the URI field. + $target = $this->notice->uri; + } else { + // Shouldn't happen. + $target = false; + } + if ($target && $target != $this->selfUrl()) { + common_redirect($target, 301); + return false; + } } + $this->showPage(); } - $this->showPage(); } /** @@ -232,6 +237,21 @@ class ShownoticeAction extends OwnerDesignAction $this->elementEnd('ol'); } + function showAjax() + { + header('Content-Type: text/xml;charset=utf-8'); + $this->xw->startDocument('1.0', 'UTF-8'); + $this->elementStart('html'); + $this->elementStart('head'); + $this->element('title', null, _('Notice')); + $this->elementEnd('head'); + $this->elementStart('body'); + $nli = new NoticeListItem($this->notice, $this); + $nli->show(); + $this->elementEnd('body'); + $this->elementEnd('html'); + } + /** * Don't show page notice * From 90d35885aeed68b11a80225ff255b6ac70a349b9 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 14 Mar 2011 13:29:35 -0700 Subject: [PATCH 4/5] Realtime plugin: fix i18n, thumbnails, location display, OStatus server display, micro-apps display. Switch from manual local formatting of notices (which lacks all the server-side goodness) to calling into the server-side with an AJAX variant of shownotice. --- plugins/Realtime/README | 7 +- plugins/Realtime/RealtimePlugin.php | 11 +-- plugins/Realtime/realtimeupdate.js | 98 ++++---------------------- plugins/Realtime/realtimeupdate.min.js | 2 +- 4 files changed, 22 insertions(+), 96 deletions(-) diff --git a/plugins/Realtime/README b/plugins/Realtime/README index 9b36d87f37..0c52427eb6 100644 --- a/plugins/Realtime/README +++ b/plugins/Realtime/README @@ -1,9 +1,12 @@ +As of StatusNet 1.0.x, actual formatting of the notices is done server-side, +loaded by AJAX after the real-time notification comes in. This has the drawback +that we may make extra HTTP requests and delay incoming notices a little, but +means that formatting and internationalization is consistent. + == TODO == -* i18n * Update mark behaviour (on notice send) * Pause, Send a notice ~ should not update counter * Pause ~ retain up to 50-100 most recent notices -* Add geo data * Make it work for Conversation page (perhaps a little tricky) * IE is updating the counter in document title all the time (Not sure if this is still an issue) diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index f617c39060..108a6c3b60 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -45,9 +45,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { */ class RealtimePlugin extends Plugin { - protected $replyurl = null; - protected $favorurl = null; - protected $deleteurl = null; + protected $showurl = null; /** * When it's time to initialize the plugin, calculate and @@ -56,11 +54,8 @@ class RealtimePlugin extends Plugin function onInitializePlugin() { - $this->replyurl = common_local_url('newnotice'); - $this->favorurl = common_local_url('favor'); - $this->repeaturl = common_local_url('repeat'); // FIXME: need to find a better way to pass this pattern in - $this->deleteurl = common_local_url('deletenotice', + $this->showurl = common_local_url('shownotice', array('notice' => '0000000000')); return true; } @@ -359,7 +354,7 @@ class RealtimePlugin extends Plugin function _updateInitialize($timeline, $user_id) { - return "RealtimeUpdate.init($user_id, \"$this->replyurl\", \"$this->favorurl\", \"$this->repeaturl\", \"$this->deleteurl\"); "; + return "RealtimeUpdate.init($user_id, \"$this->showurl\"); "; } function _connect() diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index 73516a8ed9..59e3fe72d7 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -44,10 +44,7 @@ */ RealtimeUpdate = { _userid: 0, - _replyurl: '', - _favorurl: '', - _repeaturl: '', - _deleteurl: '', + _showurl: '', _updatecounter: 0, _maxnotices: 50, _windowhasfocus: true, @@ -66,21 +63,15 @@ RealtimeUpdate = { * feed data into the RealtimeUpdate object! * * @param {int} userid: local profile ID of the currently logged-in user - * @param {String} replyurl: URL for newnotice action, used when generating reply buttons - * @param {String} favorurl: URL for favor action, used when generating fave buttons - * @param {String} repeaturl: URL for repeat action, used when generating repeat buttons - * @param {String} deleteurl: URL template for deletenotice action, used when generating delete buttons. + * @param {String} showurl: URL for shownotice action, used when fetching formatting notices. * This URL contains a stub value of 0000000000 which will be replaced with the notice ID. * * @access public */ - init: function(userid, replyurl, favorurl, repeaturl, deleteurl) + init: function(userid, showurl) { RealtimeUpdate._userid = userid; - RealtimeUpdate._replyurl = replyurl; - RealtimeUpdate._favorurl = favorurl; - RealtimeUpdate._repeaturl = repeaturl; - RealtimeUpdate._deleteurl = deleteurl; + RealtimeUpdate._showurl = showurl; RealtimeUpdate._documenttitle = document.title; @@ -268,83 +259,20 @@ RealtimeUpdate = { * loads data from server, so runs async. * * @param {Object} data: extended JSON API-formatted notice - * @param {function} callback: function(str) to receive HTML fragment - * - * @fixme this replicates core StatusNet code, making maintenance harder - * @fixme sloppy HTML building (raw concat without escaping) - * @fixme no i18n support - * @fixme local variables pollute global namespace + * @param {function} callback: function(DOMNode) to receive new code * * @access private */ makeNoticeItem: function(data, callback) { - if (data.hasOwnProperty('retweeted_status')) { - original = data['retweeted_status']; - repeat = data; - data = original; - unique = repeat['id']; - responsible = repeat['user']; - } else { - original = null; - repeat = null; - unique = data['id']; - responsible = data['user']; - } - - 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['conversation_url']) { - ni = ni+" in context"; - } - - if (repeat) { - ru = repeat['user']; - ni = ni + "Repeated by " + - "" + - ""+ ru['screen_name'] + ""; - } - - 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 == responsible['id']) { - ni = ni+RealtimeUpdate.makeDeleteLink(data['id']); - } else if (RealtimeUpdate._userid != user['id']) { - ni = ni+RealtimeUpdate.makeRepeatForm(data['id'], session_key); - } - } - - ni = ni+"
    "; - - ni = ni+"
  • "; - callback(ni); + var url = RealtimeUpdate._showurl.replace('0000000000', data.id); + $.get(url, {ajax: 1}, function(data, textStatus, xhr) { + var notice = $('li.notice:first', data); + if (notice.length) { + var node = document._importNode(notice[0], true); + callback(node); + } + }); }, /** diff --git a/plugins/Realtime/realtimeupdate.min.js b/plugins/Realtime/realtimeupdate.min.js index 931de982ef..7e77f90709 100644 --- a/plugins/Realtime/realtimeupdate.min.js +++ b/plugins/Realtime/realtimeupdate.min.js @@ -1 +1 @@ -RealtimeUpdate={_userid:0,_replyurl:"",_favorurl:"",_repeaturl:"",_deleteurl:"",_updatecounter:0,_maxnotices:50,_windowhasfocus:true,_documenttitle:"",_paused:false,_queuedNotices:[],init:function(c,b,d,e,a){RealtimeUpdate._userid=c;RealtimeUpdate._replyurl=b;RealtimeUpdate._favorurl=d;RealtimeUpdate._repeaturl=e;RealtimeUpdate._deleteurl=a;RealtimeUpdate._documenttitle=document.title;$(window).bind("focus",function(){RealtimeUpdate._windowhasfocus=true;RealtimeUpdate._updatecounter=0;RealtimeUpdate.removeWindowCounter()});$(window).bind("blur",function(){$("#notices_primary .notice").removeClass("mark-top");$("#notices_primary .notice:first").addClass("mark-top");RealtimeUpdate._windowhasfocus=false;return false})},receive:function(a){if(RealtimeUpdate.isNoticeVisible(a.id)){return}if(RealtimeUpdate._paused===false){RealtimeUpdate.purgeLastNoticeItem();RealtimeUpdate.insertNoticeItem(a)}else{RealtimeUpdate._queuedNotices.push(a);RealtimeUpdate.updateQueuedCounter()}RealtimeUpdate.updateWindowCounter()},insertNoticeItem:function(b){if(RealtimeUpdate.isNoticeVisible(b.id)){return}var a=RealtimeUpdate.makeNoticeItem(b);var c=$(a).attr("id");var d=$("#notices_primary .notices:first");var j=true;var e=d.hasClass("threaded-notices");if(e&&b.in_reply_to_status_id){var g=$("#notice-"+b.in_reply_to_status_id);if(g.length==0){}else{var h=g.closest(".notices");if(h.hasClass("threaded-replies")){g=h.closest(".notice")}d=g.find(".threaded-replies");if(d.length==0){d=$('
      ');g.append(d)}j=false}}var i=$(a);if(j){d.prepend(i)}else{var f=d.find("li.notice-reply-placeholder");if(f.length>0){i.insertBefore(f)}else{i.appendTo(d);SN.U.NoticeInlineReplyPlaceholder(g)}}i.css({display:"none"}).fadeIn(1000);SN.U.NoticeReplyTo($("#"+c));SN.U.NoticeWithAttachment($("#"+c))},isNoticeVisible:function(a){return($("#notice-"+a).length>0)},purgeLastNoticeItem:function(){if($("#notices_primary .notice").length>RealtimeUpdate._maxnotices){$("#notices_primary .notice:last").remove()}},updateWindowCounter:function(){if(RealtimeUpdate._windowhasfocus===false){RealtimeUpdate._updatecounter+=1;document.title="("+RealtimeUpdate._updatecounter+") "+RealtimeUpdate._documenttitle}},removeWindowCounter:function(){document.title=RealtimeUpdate._documenttitle},makeNoticeItem:function(c){if(c.hasOwnProperty("retweeted_status")){original=c.retweeted_status;repeat=c;c=original;unique=repeat.id;responsible=repeat.user}else{original=null;repeat=null;unique=c.id;responsible=c.user}user=c.user;html=c.html.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/&/g,"&");source=c.source.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/&/g,"&");ni='
    • '+user.screen_name+''+user.screen_name+'

      '+html+'

      a few seconds ago from '+source+"";if(c.conversation_url){ni=ni+' in context'}if(repeat){ru=repeat.user;ni=ni+'Repeated by '+ru.screen_name+""}ni=ni+"
      ";ni=ni+'
      ';if(RealtimeUpdate._userid!=0){var a=$("form#form_notice fieldset input#token");var b=a.val();ni=ni+RealtimeUpdate.makeFavoriteForm(c.id,b);ni=ni+RealtimeUpdate.makeReplyLink(c.id,c.user["screen_name"]);if(RealtimeUpdate._userid==responsible.id){ni=ni+RealtimeUpdate.makeDeleteLink(c.id)}else{if(RealtimeUpdate._userid!=user.id){ni=ni+RealtimeUpdate.makeRepeatForm(c.id,b)}}}ni=ni+"
      ";ni=ni+"
    • ";return ni},makeFavoriteForm:function(c,b){var a;a='
      Favor this notice
      ';return a},makeReplyLink:function(c,a){var b;b='Reply '+c+"";return b},makeRepeatForm:function(c,b){var a;a='
      Repeat this notice?
      ';return a},makeDeleteLink:function(c){var b,a;a=RealtimeUpdate._deleteurl.replace("0000000000",c);b='Delete';return b},initActions:function(a,b,c){$("#notices_primary").prepend('
      ');RealtimeUpdate._pluginPath=c;RealtimeUpdate.initPlayPause();RealtimeUpdate.initAddPopup(a,b,RealtimeUpdate._pluginPath)},initPlayPause:function(){if(typeof(localStorage)=="undefined"){RealtimeUpdate.showPause()}else{if(localStorage.getItem("RealtimeUpdate_paused")==="true"){RealtimeUpdate.showPlay()}else{RealtimeUpdate.showPause()}}},showPause:function(){RealtimeUpdate.setPause(false);RealtimeUpdate.showQueuedNotices();RealtimeUpdate.addNoticesHover();$("#realtime_playpause").remove();$("#realtime_actions").prepend('
    • ');$("#realtime_pause").text(SN.msg("realtime_pause")).attr("title",SN.msg("realtime_pause_tooltip")).bind("click",function(){RealtimeUpdate.removeNoticesHover();RealtimeUpdate.showPlay();return false})},showPlay:function(){RealtimeUpdate.setPause(true);$("#realtime_playpause").remove();$("#realtime_actions").prepend('
    • ');$("#realtime_play").text(SN.msg("realtime_play")).attr("title",SN.msg("realtime_play_tooltip")).bind("click",function(){RealtimeUpdate.showPause();return false})},setPause:function(a){RealtimeUpdate._paused=a;if(typeof(localStorage)!="undefined"){localStorage.setItem("RealtimeUpdate_paused",RealtimeUpdate._paused)}},showQueuedNotices:function(){$.each(RealtimeUpdate._queuedNotices,function(a,b){RealtimeUpdate.insertNoticeItem(b)});RealtimeUpdate._queuedNotices=[];RealtimeUpdate.removeQueuedCounter()},updateQueuedCounter:function(){$("#realtime_playpause #queued_counter").html("("+RealtimeUpdate._queuedNotices.length+")")},removeQueuedCounter:function(){$("#realtime_playpause #queued_counter").empty()},addNoticesHover:function(){$("#notices_primary .notices").hover(function(){if(RealtimeUpdate._paused===false){RealtimeUpdate.showPlay()}},function(){if(RealtimeUpdate._paused===true){RealtimeUpdate.showPause()}})},removeNoticesHover:function(){$("#notices_primary .notices").unbind()},initAddPopup:function(a,b,c){$("#realtime_timeline").append('');$("#realtime_popup").text(SN.msg("realtime_popup")).attr("title",SN.msg("realtime_popup_tooltip")).bind("click",function(){window.open(a,"","toolbar=no,resizable=yes,scrollbars=yes,status=no,menubar=no,personalbar=no,location=no,width=500,height=550");return false})},initPopupWindow:function(){$(".notices .entry-title a, .notices .entry-content a").bind("click",function(){window.open(this.href,"");return false});$("#showstream .entity_profile").css({width:"69%"})}}; \ No newline at end of file +RealtimeUpdate={_userid:0,_showurl:"",_updatecounter:0,_maxnotices:50,_windowhasfocus:true,_documenttitle:"",_paused:false,_queuedNotices:[],init:function(a,b){RealtimeUpdate._userid=a;RealtimeUpdate._showurl=b;RealtimeUpdate._documenttitle=document.title;$(window).bind("focus",function(){RealtimeUpdate._windowhasfocus=true;RealtimeUpdate._updatecounter=0;RealtimeUpdate.removeWindowCounter()});$(window).bind("blur",function(){$("#notices_primary .notice").removeClass("mark-top");$("#notices_primary .notice:first").addClass("mark-top");RealtimeUpdate._windowhasfocus=false;return false})},receive:function(a){if(RealtimeUpdate.isNoticeVisible(a.id)){return}if(RealtimeUpdate._paused===false){RealtimeUpdate.purgeLastNoticeItem();RealtimeUpdate.insertNoticeItem(a)}else{RealtimeUpdate._queuedNotices.push(a);RealtimeUpdate.updateQueuedCounter()}RealtimeUpdate.updateWindowCounter()},insertNoticeItem:function(a){if(RealtimeUpdate.isNoticeVisible(a.id)){return}RealtimeUpdate.makeNoticeItem(a,function(b){var c=$(b).attr("id");var d=$("#notices_primary .notices:first");var j=true;var e=d.hasClass("threaded-notices");if(e&&a.in_reply_to_status_id){var g=$("#notice-"+a.in_reply_to_status_id);if(g.length==0){}else{var h=g.closest(".notices");if(h.hasClass("threaded-replies")){g=h.closest(".notice")}d=g.find(".threaded-replies");if(d.length==0){d=$('
        ');g.append(d)}j=false}}var i=$(b);if(j){d.prepend(i)}else{var f=d.find("li.notice-reply-placeholder");if(f.length>0){i.insertBefore(f)}else{i.appendTo(d);SN.U.NoticeInlineReplyPlaceholder(g)}}i.css({display:"none"}).fadeIn(1000);SN.U.NoticeReplyTo($("#"+c));SN.U.NoticeWithAttachment($("#"+c))})},isNoticeVisible:function(a){return($("#notice-"+a).length>0)},purgeLastNoticeItem:function(){if($("#notices_primary .notice").length>RealtimeUpdate._maxnotices){$("#notices_primary .notice:last").remove()}},updateWindowCounter:function(){if(RealtimeUpdate._windowhasfocus===false){RealtimeUpdate._updatecounter+=1;document.title="("+RealtimeUpdate._updatecounter+") "+RealtimeUpdate._documenttitle}},removeWindowCounter:function(){document.title=RealtimeUpdate._documenttitle},makeNoticeItem:function(b,c){var a=RealtimeUpdate._showurl.replace("0000000000",b.id);$.get(a,{ajax:1},function(f,h,g){var e=$("li.notice:first",f);if(e.length){var d=document._importNode(e[0],true);c(d)}})},makeFavoriteForm:function(c,b){var a;a='
        Favor this notice
        ';return a},makeReplyLink:function(c,a){var b;b='Reply '+c+"";return b},makeRepeatForm:function(c,b){var a;a='
        Repeat this notice?
        ';return a},makeDeleteLink:function(c){var b,a;a=RealtimeUpdate._deleteurl.replace("0000000000",c);b='Delete';return b},initActions:function(a,b,c){$("#notices_primary").prepend('
        ');RealtimeUpdate._pluginPath=c;RealtimeUpdate.initPlayPause();RealtimeUpdate.initAddPopup(a,b,RealtimeUpdate._pluginPath)},initPlayPause:function(){if(typeof(localStorage)=="undefined"){RealtimeUpdate.showPause()}else{if(localStorage.getItem("RealtimeUpdate_paused")==="true"){RealtimeUpdate.showPlay()}else{RealtimeUpdate.showPause()}}},showPause:function(){RealtimeUpdate.setPause(false);RealtimeUpdate.showQueuedNotices();RealtimeUpdate.addNoticesHover();$("#realtime_playpause").remove();$("#realtime_actions").prepend('
      • ');$("#realtime_pause").text(SN.msg("realtime_pause")).attr("title",SN.msg("realtime_pause_tooltip")).bind("click",function(){RealtimeUpdate.removeNoticesHover();RealtimeUpdate.showPlay();return false})},showPlay:function(){RealtimeUpdate.setPause(true);$("#realtime_playpause").remove();$("#realtime_actions").prepend('
      • ');$("#realtime_play").text(SN.msg("realtime_play")).attr("title",SN.msg("realtime_play_tooltip")).bind("click",function(){RealtimeUpdate.showPause();return false})},setPause:function(a){RealtimeUpdate._paused=a;if(typeof(localStorage)!="undefined"){localStorage.setItem("RealtimeUpdate_paused",RealtimeUpdate._paused)}},showQueuedNotices:function(){$.each(RealtimeUpdate._queuedNotices,function(a,b){RealtimeUpdate.insertNoticeItem(b)});RealtimeUpdate._queuedNotices=[];RealtimeUpdate.removeQueuedCounter()},updateQueuedCounter:function(){$("#realtime_playpause #queued_counter").html("("+RealtimeUpdate._queuedNotices.length+")")},removeQueuedCounter:function(){$("#realtime_playpause #queued_counter").empty()},addNoticesHover:function(){$("#notices_primary .notices").hover(function(){if(RealtimeUpdate._paused===false){RealtimeUpdate.showPlay()}},function(){if(RealtimeUpdate._paused===true){RealtimeUpdate.showPause()}})},removeNoticesHover:function(){$("#notices_primary .notices").unbind()},initAddPopup:function(a,b,c){$("#realtime_timeline").append('');$("#realtime_popup").text(SN.msg("realtime_popup")).attr("title",SN.msg("realtime_popup_tooltip")).bind("click",function(){window.open(a,"","toolbar=no,resizable=yes,scrollbars=yes,status=no,menubar=no,personalbar=no,location=no,width=500,height=550");return false})},initPopupWindow:function(){$(".notices .entry-title a, .notices .entry-content a").bind("click",function(){window.open(this.href,"");return false});$("#showstream .entity_profile").css({width:"69%"})}}; \ No newline at end of file From 34e7d8ddf2cc95de329789eb67513d77e6245b28 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 14 Mar 2011 13:44:39 -0700 Subject: [PATCH 5/5] For good measure; trip short error mode in earlier on ajax shownotice --- actions/shownotice.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/actions/shownotice.php b/actions/shownotice.php index 8d8ab326df..b8927372bb 100644 --- a/actions/shownotice.php +++ b/actions/shownotice.php @@ -78,6 +78,9 @@ class ShownoticeAction extends OwnerDesignAction function prepare($args) { parent::prepare($args); + if ($this->boolean('ajax')) { + StatusNet::setApi(true); + } $id = $this->arg('notice'); @@ -189,7 +192,6 @@ class ShownoticeAction extends OwnerDesignAction parent::handle($args); if ($this->boolean('ajax')) { - StatusNet::setApi(true); $this->showAjax(); } else { if ($this->notice->is_local == Notice::REMOTE_OMB) {