Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
const LACONICA_STATUS_MAXLEN = 140; const LACONICA_ROOT = "http://identi.ca/api/statuses/"; CmdUtils.CreateCommand({ name: "identica", takes: {status: noun_arb_text}, root: "http://identi.ca/api/statuses/", homepage: "http://theunfocused.net/moz/ubiquity/verbs/", author: {name: "Blair McBride; Find and replaced by Remy Porter", homepage: "http://theunfocused.net/"}, license: "MPL", preview: function(previewBlock, statusText) { var previewTemplate = "Updates your Identi.ca 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: LACONICA_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("Identi.ca requires a status to be entered"); return; } var updateUrl = LACONICA_ROOT + "update.json"; var updateParams = { source: "ubiquity", status: statusText.text.substring(0,140) }; jQuery.ajax({ type: "POST", url: updateUrl, data: updateParams, dataType: "json", error: function() { displayMessage("Identi.ca error - status not updated"); }, success: function() { displayMessage("Identi.ca status updated"); } }); } }); CmdUtils.CreateCommand({ name: "get-dents", //takes: {num_posts: noun}, homepage: "http://theunfocused.net/moz/ubiquity/verbs/", author: {name: "Remy Porter", homepage: "http://identi.ca/t3knomanser"}, license: "MPL", preview: function(previewBlock) { var dent_template = "<tr><td><img src=\"${imageUrl}\" height=\"25px\" width=\"25px\" /></td>" + "<th>${user}:</th><td>${dent}</td></tr>"; //previewBlock.innerHTML = "<table>" + CmdUtils.renderTemplate(dent_template, {user:"Joebob",status:"Testing dent"}) + "</table>"; var numPosts = 10; var updateURL; updateURL = LACONICA_ROOT + "friends_timeline.xml?count=" + numPosts; jQuery.ajax({ type: "GET", url: updateURL, success: function(xml) { var body = ""; jQuery("status", xml).each(function() { body += CmdUtils.renderTemplate(dent_template, {user:jQuery("screen_name", this).text(), dent:jQuery("text", this).text(), imageUrl:jQuery("profile_image_url", this).text()} ); }); previewBlock.innerHTML = "<table border=\"1\">" + body + "</table>"; }, error: function() {displayMessage("Failed getting dents."); } }); } });
This paste will be private.
From the Design Piracy series on my blog: