pypeng (owner)

Forks

Revisions

gist: 7735 Download_button fork
public
Description:
ubiquity command for douban
Public Clone URL: git://gist.github.com/7735.git
Embed All Files: show embed
douban-ubiquity-recommend.js #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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},
    });
  }
})