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 = "
"+
- ""+
- "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+"
');$("#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