Skip to content

Instantly share code, notes, and snippets.

@pypeng
Created August 28, 2008 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pypeng/7735 to your computer and use it in GitHub Desktop.
Save pypeng/7735 to your computer and use it in GitHub Desktop.
ubiquity command for douban
CmdUtils.CreateCommand({
name: "r-douban",
homepage: "http://www.douban.com/people/aka/",
author: { name: "Yu Peng", email: "pengyu.py@gmail.com"},
contributors: ["Yu Peng"],
license: "MPL",
description: "Recommend the current site to douban",
help: "posts the current tab url to douban with the comment input by the user.",
_params: function(comment,mods) {
var document = context.focusedWindow.document;
var params = {
uid: document.location,
title: (mods.entitled.text || document.title),
type: 'I',
comment: comment.text,
};
return params;
},
takes: {"comment": noun_arb_text},
modifiers: {entitled: noun_arb_text},
preview: function(pblock, comment, mods) {
var document = context.focusedWindow.document;
html = "title: " + (mods.entitled.text || document.title) + "<br />";
html += "comment: " + comment.text;
pblock.innerHTML = html;
},
execute: function(comment, mods) {
jQuery.ajax({
type: "POST",
dataType: "xml",
url: "http://www.douban.com/recommend/",
data: this._params(comment, mods),
});
}
})
CmdUtils.CreateCommand({
name: "s-douban",
homepage: "http://www.douban.com/people/aka/",
author: { name: "Yu Peng", email: "pengyu.py@gmail.com"},
contributors: ["Yu Peng"],
license: "MPL",
description: "I say to douban",
help: "posts saying to douban",
takes: {"say": noun_arb_text},
preview: function(pblock, say) {
html = "saying: " + say.text;
pblock.innerHTML = html;
},
execute: function(say) {
jQuery.ajax({
type: "POST",
dataType: "xml",
url: "http://www.douban.com/contacts/",
data: {'mb_text':say.text},
});
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment