axemclion (owner)

Revisions

  • f15084 axemclion Tue Jul 14 00:52:29 -0700 2009
  • c3d999 axemclion Tue Jul 14 00:04:38 -0700 2009
  • 82cb83 axemclion Mon Jul 13 23:42:52 -0700 2009
  • bca57a axemclion Mon Apr 27 07:47:34 -0700 2009
  • b78aac axemclion Mon Dec 22 03:15:40 -0800 2008
  • 484bd8 axemclion Mon Dec 22 03:03:06 -0800 2008
  • 7087d0 axemclion Wed Dec 17 05:26:56 -0800 2008
  • ba1fd6 axemclion Wed Dec 17 05:23:24 -0800 2008
  • 088518 axemclion Tue Nov 18 21:17:49 -0800 2008
gist: 26425 Download_button fork
public
Description:
Ubiquity command to post bookmarks to delicious quickly
Public Clone URL: git://gist.github.com/26425.git
Embed All Files: show embed
x #
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* This is the command to add a bookmark to delicious */
CmdUtils.CreateCommand(
{
    name: ["bookmark"],
    icon: "http://l.yimg.com/hr/10363/img/delicious.20.gif",
    homepage: "http://dy-verse.blogspot.com",
    author: {
        name: "Parashuram",
        email: "n.parashuram@gmail.com"
    },
    license: "GPL",
    description: "Automatically adds a delicious bookmark for the existing page. Optionally, adds tags, description, etc",
    help: "Bookmark the existing page to your delicious account. Tags and Notes to the page are automatically added using external services.",
    
arguments: [
{role: 'object', nountype: noun_arb_text, label: 'query'}
],
    
    preview: function(pblock, args) {
        var template = "Bookmarking ${name} on delicious"
        pblock.innerHTML = CmdUtils.renderTemplate(template,
        {
            "name": Utils.url(Application.activeWindow.activeTab.document.documentURI).spec
        });
    },
    
    execute: function(args)
    {
        //CmdUtils.log("Getting Tags from Cloud Seeder");
        this.notes = args.object.text;
        this.url = Utils.url(Application.activeWindow.activeTab.document.documentURI).spec;
        this.desc = Application.activeWindow.activeTab.document.title
        this.getTags();
    },
    
    getTags: function()
    {
        var postUrl = "http://pipes.yahoo.com/pipes/pipe.run"
        var params =
        {
            "_id": "GGBgNrDK3RGsWw_fPxJ3AQ",
            "_render": "json",
            "url": (this.url)
        }
        
        this.tags = [];
        //CmdUtils.log("Getting tags for the page using YAHOO PIPES " + this.url);
        var curObj = this;
        jQuery.ajax(
        {
            data: params,
            url: postUrl,
            type: "GET",
            dataType: "json",
            error: function()
            {
                displayMessage(_("Error Posting to delicious"));
                //CmdUtils.log("Error getting tags for the current page");
                curObj.postToDelicious();
            },
            success: function(data)
            {
                displayMessage(_("Sucessfully generated tags for this page"));
                //CmdUtils.log(data);
                for (var i = 0; i < data.value.items.length && i < 30; i++)
                {
                    curObj.tags.push(data.value.items[i].content);
                }
                curObj.postToDelicious();
            }
        });
    },
    
    postToDelicious: function()
    {
        var postUrl = "https://api.del.icio.us/v1/posts/add"
        var params =
        {
            "url": this.url,
            "description": this.desc,
            "extended": this.notes,
            "tags": this.tags.join(" "),
            "dt": "",
            "replace": "yes",
            "shared": "yes"
        }
        //CmdUtils.log("Posting to delicious");
        jQuery.ajax(
        {
            type: "POST",
            url: postUrl,
            data: params,
            dataType: "xml",
            error: function()
            {
                displayMessage("Error Posting to delicious");
            },
            success: function(data)
            {
                displayMessage(data.getElementsByTagName("result")[0].getAttribute("code"));
                //CmdUtils.log(data.getElementsByTagName("result")[0].getAttribute("code"));
            }
        });
    }
});