Skip to content

Instantly share code, notes, and snippets.

@whym
Created August 31, 2009 09:59
Show Gist options
  • Save whym/178378 to your computer and use it in GitHub Desktop.
Save whym/178378 to your computer and use it in GitHub Desktop.
Post to Google Docs. Right-click on a link -> Choose Share - Link - Target -> Choose GoogleDocs
models.register({
name : 'GoogleDocs',
ICON : 'http://docs.google.com/favicon.ico',
check : function(ps){
return ps.type == 'link' && !ps.file;
},
getAuthCookie : function(){
return getCookieString('www.google.com', 'secid').split('=').pop();
},
post : function(ps){
var endpoint = 'http://docs.google.com/DocAction?action=updoc';
if (!this.getAuthCookie())
throw new Error(getMessage('error.notLoggedin'));
return request(endpoint).addCallback(function(res){
var doc = convertToHTMLDocument(res.responseText);
return request(endpoint, {
redirectionLimit : 0,
sendContent : update(formContents(doc), {
uploadURL: ps.itemUrl,
DocName: ps.item
})
});
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment