aboutsummaryrefslogtreecommitdiff
path: root/modules/pentadactyl/pentadactyl.dot/plugins.link/links.js
blob: 21434ef8910891610eaa0c0c1dfa4a67c57ab9bc (plain)
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
/**
 * Links plugin.
 */

"use strict";

XML.ignoreWhitespace = false;
XML.prettyPrinting   = false;

/* use strict */
var INFO =
["plugin",  { name:    "links",
              version: "0.1",
              href:    "http://dactyl.sf.net/pentadactyl/plugins#links-plugin",
              summary: "Scuttle published",
              xmlns:   "dactyl" },
["author",  { email:   "rhatto@riseup.net" }, "Silvio Rhatto"],
["license", { href:    "http://opensource.org/licenses/mit-license.php" }, "MIT"],
["project", { name:    "Pentadactyl", "min-version": "1.0" }],
    ["p", {},
        "This plugin provides a shortcut command to publish a link to a Scuttle site."],
    ["item", {},
        ["tags", {}, ":link"],
        ["strut"],
        ["spec", {}, ":link"],
        ["description", {},
            ["p", {},
                "Add the current page into the Scuttle site."
                ]]]];

group.commands.add(["link"],
    "Add link to scuttle",
    function (args) {
      var instance = 'https://links.sarava.org/bookmarks?action=add&address=';
      var doc      = content.document;
      var href     = encodeURIComponent(doc.location.href);
      var title    = encodeURIComponent(doc.title);
      var desc     = encodeURIComponent(doc.getSelection());
      var tags     = encodeURIComponent(args.toString().replace(/,,/g, ';').replace(/,/g, ' ').replace(/;/g, ', '));
      commands.execute('tabopen ' + instance + href + '&title=' + title + '&description=' + desc + '&tags=' + tags);
    },
    { argCount: "*" }, true);