-
-
Save morygonzalez/777483 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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