Skip to content

Instantly share code, notes, and snippets.

@morygonzalez
Forked from technolize/21_Pinboard.js
Created January 13, 2011 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morygonzalez/777483 to your computer and use it in GitHub Desktop.
Save morygonzalez/777483 to your computer and use it in GitHub Desktop.
if(typeof(models)=='undefined')
this.models = models = new Repository();
var Pinboard = {
name : 'Pinboard',
ICON : 'http://pinboard.in/favicon.ico',
getCurrentUser : function() {
if(decodeURIComponent(getCookieString('pinboard.in', 'login')).match(/login=(.*?) /))
return RegExp.$1;
throw new Error(getMessage('error.notLoggedin'));
},
check : function(ps) {
return (/(photo|quote|link|video)/).test(ps.type) && !ps.file;
},
post : function(ps) {
return request('http://pinboard.in/add', {
queryString : {
url : ps.itemUrl,
title : ps.item,
description : null,
},
}).addCallback(function(res){
var doc = convertToHTMLDocument(res.responseText);
var elmForm = doc.getElementsByTagName('form')[0];
if (!elmForm)
throw new Error(getMessage('error.notLoggedin'));
return request('http://pinboard.in/add', {
redirectionLimit : 0,
sendContent : update(formContents(elmForm), {
title : ps.item,
description : joinText([ps.body, ps.description], ' ', true),
tags : joinText(ps.tags, ' '),
}),
});
});
},
};
models.register(Pinboard);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment