From c94cc980c82e20b52ec2af4679130c51b5166228 Mon Sep 17 00:00:00 2001 From: anekos Date: Fri, 24 Aug 2012 16:14:23 +0900 Subject: Support pinboard.in --- direct_bookmark.js | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'direct_bookmark.js') diff --git a/direct_bookmark.js b/direct_bookmark.js index 46d5a79..4f379fa 100644 --- a/direct_bookmark.js +++ b/direct_bookmark.js @@ -3,7 +3,7 @@ var PLUGIN_INFO = {NAME} Direct Post to Social Bookmarks Trapezoid - 0.17.0 + 0.18.0 GPL 2.0pre https://github.com/vimpr/vimperator-plugins/raw/master/direct_bookmark.js @@ -28,6 +28,7 @@ for Migemo search: require XUL/Migemo Extension 'l': livedoor clip 'g': Google Bookmarks 'p': Places (Firefox bookmarks) + 'P': pinboard.in Usage: let g:direct_sbm_use_services_by_tag = "hdl" ||< === g:direct_sbm_use_services_by_post === @@ -37,7 +38,7 @@ for Migemo search: require XUL/Migemo Extension 'd': del.icio.us 'l': livedoor clip 'g': Google Bookmarks - 'p': Places (Firefox bookmarks) + 'P': pinboard.in Usage: let g:direct_sbm_use_services_by_post = "hdl" ||< === g:direct_sbm_echo_type === @@ -584,6 +585,48 @@ for Migemo search: require XUL/Migemo Extension tags:function(user,password) Application.bookmarks.tags.children.map(function(x) x.title), }, + 'P': { + description:'pinboard', + account:['https://pinboard.in', 'https://pinboard.in', null], + loginPrompt:{ user:'', password:'', description:'Enter username and password.' }, + entryPage:'%URL%', + poster:function(user,password,url,title,comment,tags){ + var rate=0; + var starFullRate=5; + if(comment.match(/\*+$/)){ + comment = RegExp.leftContext; + rate = (RegExp.lastMatch.length > starFullRate)? starFullRate : RegExp.lastMatch.length; + } + var request_url = 'https://api.pinboard.in/v1/posts/add?' + [ + ['url', url], ['description', title], ['extended', comment], ['tags', tags.join(' ')], + ['shared', 'no'], ['toread', 'no'], + ].map(function(p) p[0] + '=' + encodeURIComponent(p[1])).join('&'); + return Deferred.http({ + method: "get", + url: request_url, + user: user, + password: password, + }).next(function(xhr){ + if(xhr.status != 200) { + throw "pinboard.in: failed"; + } + }); + }, + tags:function(user,password){ + const url = 'https://api.pinboard.in/v1/tags/get?'; + var xhr = new XMLHttpRequest(); + xhr.open("GET", url, false, user, password); + xhr.send(null); + + return [ + e.getAttribute("tag") + for ([, e] in Iterator(Array.slice(xhr.responseXML.querySelectorAll('tag')))) + ]; + }, + //icon:function(url){ + // return ''; + //}, + }, }; __context__.services = services; -- cgit v1.2.3