Ubiquity script for LJ
Mon Sep 01 08:59:00 CDT 2008
From the tutorial, I've pieced together a script for Ubiquity that starts an lj entry with the selected text. I'm sure it could be improved upon easily. I experimented with posting to lj directly by filling out the form values. While this could be done, I noticed that lj is putting some security entries in the form, so, maybe not such a good idea? Chances are I'll want to edit the post, anyway.
preview: function(previewBlock, draftText) {
var previewTemplate = "Post to lj: <br/>" +
"<b>${status}</b>";
var previewData = {
status: draftText.text
};
var previewHTML = CmdUtils.renderTemplate(previewTemplate,
previewData);
previewBlock.innerHTML = previewHTML;
},
execute: function(blogText) { if(blogText.text.length < 1) { displayMessage("LJ needs some text to post"); return; }
var updateUrl = "http://www.livejournal.com/update.bml";
var updateParams = {
source: "ubiquity",
subject: "ubiquity test",
event: blogText.text,
formsubmit: "Post to xxxxx"
};
jQuery.post(updateUrl,updateParams,
function(data,status) {
var msg = "returned " + status + " - " + data;
CmdUtils.log(msg);
toJavaScriptConsole();
displayMessage(msg);
}
);
Utils.openUrlInBrowser(updateUrl+"?subject=Ubiquity&event="+encodeURIComponent(blogText.text));
} });