Permalink
Browse files

made request callback signatures consistent

  • Loading branch information...
1 parent b986464 commit cabba6c68402dc748768b27467f6abd08e2602cd @ChrisMissal ChrisMissal committed Mar 2, 2013
Showing with 31 additions and 30 deletions.
  1. +7 −7 plugins/dropbox/dropbox.js
  2. +23 −23 plugins/github/github.js
  3. +1 −0 public/js/dillinger.js
View
14 plugins/dropbox/dropbox.js
@@ -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()
@@ -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()
@@ -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()
View
46 plugins/github/github.js
@@ -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()
}
@@ -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.'})
@@ -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.'})
@@ -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'))
}
View
1 public/js/dillinger.js
@@ -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>'
})

0 comments on commit cabba6c

Please sign in to comment.