From db84135d68e1f67373508d74b2c0ff0a542a6889 Mon Sep 17 00:00:00 2001 From: otsune Date: Wed, 2 Apr 2008 01:34:10 +0000 Subject: lang/javascript/vimperator-plugins/pukka.js: Add plugin git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@8627 d0d07461-0603-4401-acd4-de1884942a52 --- pukka.js | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 pukka.js (limited to 'pukka.js') diff --git a/pukka.js b/pukka.js new file mode 100644 index 0000000..ef3ce63 --- /dev/null +++ b/pukka.js @@ -0,0 +1,53 @@ +/* + * liberator plugin + * Add `pukka' http://codesorcery.net/pukka/ command to Bookmark del.icio.us + * For liberator 0.6pre + * @author otsune (based on teramako) + * @version 0.1 + */ + +(function(){ +liberator.commands.addUserCommand(['pukka','pu'], 'Post to Pukka', +function(args){ + if (!liberator.buffer.title || !liberator.buffer.URL || liberator.buffer.URL=='about:blank'){ + return false; + } + var str = "pukka:"; + var title = encodeURIComponent(liberator.buffer.title); + var url = encodeURIComponent(liberator.buffer.URL); + if (args){ + url = encodeURIComponent(args); + } + liberator.open(str + "url=" + url + "&title=" + title); +},{ + usage: ['pukka [url] ','pu [url]'], + completer: function(filter){ + return [0, [getNormalizedPermalink(liberator.buffer.URL), "Normalize URL"]]; + } +} +); + +liberator.mappings.addUserMap([liberator.modes.NORMAL], +[''], 'Post to Pukka', +function() { + liberator.commandline.open( + ':', + 'pukka ' + getNormalizedPermalink(liberator.buffer.URL), + liberator.modes.EX + ); +},{ +} +); + +// copied from trapezoid's direct-hb.js +function getNormalizedPermalink(url){ + var xhr = new XMLHttpRequest(); + xhr.open("GET","http://api.pathtraq.com/normalize_url?url=" + url,false); + xhr.send(null); + if(xhr.status != 200){ + liberator.echoerr("Pathtraq: URL normalize faild!!"); + return url; + } + return xhr.responseText; +} +})(); -- cgit v1.2.3