Skip to content

Commit

Permalink
made request callback signatures consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisMissal committed Mar 2, 2013
1 parent b986464 commit cabba6c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
14 changes: 7 additions & 7 deletions plugins/dropbox/dropbox.js
Expand Up @@ -68,11 +68,11 @@ exports.Dropbox = (function(){
}

// Create your auth_url for the view
request.get({url:url, oauth:oauth}, function (e, r, body) {
request.get({url:url, oauth:oauth}, function (e, r, d) {

if(e) return cb(e,null)

return cb(null,qs.parse(body))
return cb(null,qs.parse(d))

}) // end request.get()

Expand All @@ -86,11 +86,11 @@ exports.Dropbox = (function(){
, token_secret: dropbox_obj.oauth.access_token_secret
}

request.get({url: ACCOUNT_INFO_URI, oauth:oauth}, function (e, r, b) {
request.get({url: ACCOUNT_INFO_URI, oauth:oauth}, function (e, r, d) {

if(e) return cb(e,null)

return cb(null,b)
return cb(null,d)

}) // end request.post()

Expand Down Expand Up @@ -147,12 +147,12 @@ exports.Dropbox = (function(){
, token_secret: dropbox_obj.oauth.access_token_secret
}

request.get({url: uri, oauth:oauth}, function (e, r, b) {
request.get({url: uri, oauth:oauth}, function (e, r, d) {

if(e) return cb(e,null)

b = JSON.parse(b)
return cb(null,b)
d = JSON.parse(d)
return cb(null,d)

}) // end request.get()

Expand Down
46 changes: 23 additions & 23 deletions plugins/github/github.js
Expand Up @@ -43,14 +43,14 @@ exports.Github = (function(){

var uri = github_api + 'user?access_token=' + req.session.github.oauth

request.get(uri, function(err, resp, data){
if(err) {
console.error(err)
return res.redirect(resp.statusCode)
request.get(uri, function(e, r, d){
if(e) {
console.error(e)
return res.redirect(r.statusCode)
}
else if(!err && resp.statusCode === 200)
else if(!e && r.statusCode === 200)
{
var d = JSON.parse(data)
d = JSON.parse(d)
req.session.github.username = d.login
cb && cb()
}
Expand Down Expand Up @@ -104,17 +104,17 @@ exports.Github = (function(){
+ req.body.repo
+'/branches?access_token=' + req.session.github.oauth

request.get(uri, function(err, resp, data){
if(err) {
request.get(uri, function(e, r, d){
if(e) {
res.send(
{
error: 'Request error.'
, data: resp.statusCode
, d: r.statusCode
})
}
else if(!err && resp.statusCode === 200)
else if(!e && r.statusCode === 200)
{
res.send(data)
res.send(d)
} // end else if
else{
res.json({error: 'Unable to fetch repos from Github.'})
Expand All @@ -134,18 +134,18 @@ exports.Github = (function(){
+ '/git/trees/'
+ req.body.sha + '?recursive=1&access_token=' + req.session.github.oauth

request.get(uri, function(err, resp, data){
if(err) {
request.get(uri, function(e, r, d){
if(e) {
res.send(
{
error: 'Request error.'
, data: resp.statusCode
, data: r.statusCode
})
}
else if(!err && resp.statusCode === 200)
else if(!e && r.statusCode === 200)
{
data = JSON.parse(data)
res.json(data)
d = JSON.parse(d)
res.json(d)
} // end else if
else{
res.json({error: 'Unable to fetch repos from Github.'})
Expand All @@ -164,25 +164,25 @@ exports.Github = (function(){
url += '?access_token=' + req.session.github.oauth
}

request.get(url, function(err, resp, data){
if(err){
request.get(url, function(e, r, d){
if(e){
res.send(
{
error: 'Request error.'
, data: resp.statusCode
, data: r.statusCode
})
}
else if(!err && resp.statusCode === 200)
else if(!e && r.statusCode === 200)
{

var json_resp =
{
data: data
data: d
, error: false
}

if(isPrivateRepo){
var d = JSON.parse(data)
d = JSON.parse(d)
json_resp.data = (new Buffer(d.content, 'base64').toString('ascii'))
}

Expand Down
1 change: 1 addition & 0 deletions public/js/dillinger.js
Expand Up @@ -947,6 +947,7 @@ $(function(){
repos.sort(_alphaNumSort)

repos.forEach(function(item){
console.log(item['private'] );
list += '<li data-repo-name="' + item.name + '" data-repo-private="' + item['private'] + '"><a class="repo" href="#">' + item.name + '</a></li>'
})

Expand Down

0 comments on commit cabba6c

Please sign in to comment.