Porting Twitter script for Ubiquity to BlueTwit (internal twitter clone)
Turned out to be a piece of cake! (Note: replace xyz@us.ibm.com with your internal ibm id). Just open the command editor (chrome://ubiquity/content/editor.html), cut and paste this code below and run the bluetwit command.
const BLUETWIT_STATUS_MAXLEN = 160;
CmdUtils.CreateCommand({
name: "bluetwit",
takes: {status: noun_arb_text},
preview: function(previewBlock, statusText) {
var previewTemplate = "Updates your BlueTwit status to: <br/>" +
"<b>${status}</b><br /><br />" +
"Characters remaining: <b>${chars}</b>";
var truncateTemplate = "<br />The last <b>${truncate}</b> " +
"characters will be truncated!";
var previewData = {
status: statusText.text,
chars: BLUETWIT_STATUS_MAXLEN - statusText.text.length
};
var previewHTML = CmdUtils.renderTemplate(previewTemplate,
previewData);
if(previewData.chars < 0) {
var truncateData = {
truncate: 0 - previewData.chars
};
previewHTML += CmdUtils.renderTemplate(truncateTemplate,
truncateData);
}
previewBlock.innerHTML = previewHTML;
},
execute: function(statusText) {
if(statusText.text.length < 1) {
displayMessage("BlueTwit requires a status to be entered");
return;
}
var updateUrl = "https://bluetwit.hursley.ibm.com/BlueTwit2/xyz@us.ibm.com";
jQuery.ajax({
type: "POST",
url: updateUrl,
data: "comment=" + statusText.text,
dataType: "xml",
error: function() {
displayMessage("BlueTwit error - status not updated");
},
success: function() {
displayMessage("BlueTwit status updated");
}
});
}
});
I seem to get an error message but post is successful.
ragtag
September 2, 2008 at 5:06 pm
[...] Embraces Social Media, BusinessWeek by Stephen Baker Social Networking: The Twitterverse Debates Porting Twitter Script for Ubiquity to BlueTwit Twitter Behind the Firewall (Photos on Flickr) [...]
Enterprise Microsharing Apps: Read All About Em | Pistachio
November 3, 2008 at 3:07 am
Works for me…the ’success’ messages don’t work for me but it posts so what the heck. Thanks very much for the code.
emilyobyrne
January 6, 2009 at 7:48 am
Was able to eliminate the error seen by changing jQuery.ajax call data return type to “text” and not “xml” since the return is not xml.
John
February 3, 2009 at 11:38 am