Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Google reader view command for Firefox ubiquity (v0.5, use feb 15 for older)
var noun_type_readerviews = new CmdUtils.NounType( "GoogleReaderViews: Shared | Reading List (default)",
["Shared", "ReadingList", "Starred"]
);
CmdUtils.CreateCommand({
names: ["gread"],
author: {name: "Andy Edmonds", homepage: "http://surfmind.com/lab/mozilla/ubiquity/greader/"},
icon: "",
license: 'MPL',
arguments: [{role: "object", nountype: noun_type_readerviews, label: "places source"}],
preview: function( previewBlock, arguments) {
var urlString = 'http://www.google.com/reader/atom/user/-/state/com.google/';
if( arguments.object && arguments.object.text && arguments.object.text.length) {
CmdUtils.log(arguments.object.text);
if(arguments.object.text.toLowerCase() == 'shared') urlString = urlString + 'broadcast';
if(arguments.object.text.toLowerCase() == 'readinglist') urlString +='reading-list';
if(arguments.object.text.toLowerCase() == 'starred') urlString +='starred';
} else {
urlString+='reading-list';
}
CmdUtils.log("Fetching " + urlString);
jQuery.ajax({
type: "GET",
url: urlString,
dataType: "xml",
error: function() {
//previewBlock.innerHTML = "Error searching...";
},
success: function(responseData) {
var items = [];
xmlDoc = jQuery(responseData);
xmlDoc.find("entry").slice(0, 14).each(
function(itemIndex) {
var itemDetails = jQuery(this);
CmdUtils.log(itemDetails.find("source").find("link").text());
items.push({
title: itemDetails.find("title").text(),
url: itemDetails.find("link").attr("href")
});
});
var previewTemplate =
"{for item in items}" +
"<div style=\"clear: both; border-width: 1px 0px 8px 0px;\">" +
"<a href=\"${item.url}\" style=\"text-decoration:none !important;margin-bottom:6px; \">" +
"${item.title}</a> " +
" {/for}";
var previewData = {
items: items
};
previewBlock.innerHTML = CmdUtils.renderTemplate(previewTemplate, previewData);
}
})
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.