added ability to read trees from github

This commit is contained in:
coderaiser 2012-11-19 07:51:44 -05:00
parent 0d7c892cab
commit b6aceb4a82
2 changed files with 27 additions and 10 deletions

View file

@ -12,7 +12,7 @@ var CloudCommander, Util, DOM, $, Github, cb;
ClientIdURL = APIURL + '/client_id',
CLIENT_ID,
Cache = DOM.Cache,
GitHub,
GithubLocal,
User,
GithubStore = {};
@ -72,7 +72,7 @@ var CloudCommander, Util, DOM, $, Github, cb;
/* PUBLICK FUNCTIONS */
GithubStore.basicLogin = function(pUser, pPasswd){
cloudcmd.Storage.Github = GitHub = new Github({
cloudcmd.Storage.Github = GithubLocal = new Github({
username: pUser,
password: pPasswd,
auth : 'basic'
@ -80,12 +80,12 @@ var CloudCommander, Util, DOM, $, Github, cb;
};
GithubStore.Login = function(pToken){
cloudcmd.Storage.Github = Github = new Github({
cloudcmd.Storage.Github = GithubLocal = new Github({
token : pToken,
auth : 'oauth'
});
User = Github.getUser();
User = GithubLocal.getUser();
};
function init(pCallBack){
@ -124,18 +124,37 @@ var CloudCommander, Util, DOM, $, Github, cb;
}
function getUserData(){
var lShowRepos = function(pError, pRepos){
Util.log('Repositories: ');
var lName, lRepoNames,
lGetTree = function(pError ,pData){
Util.log('Tree of ripository ' + lRepoNames[0].name + ': ');
var lTree = pData || [];
if(!pError)
for(var i = 0, n = lTree.length; i < n ; i++)
if( !Util.isContainStr(lTree[i].path, '/') )
console.log(lTree[i].path);
else
Util.log(pError);
},
lShowRepos = function(pError, pRepos){
lRepoNames = pRepos || [];
Util.log('Repositories: ');
if(!pError){
for(var i = 0, n = pRepos.length; i < n ; i++)
console.log(pRepos[i].name);
var lRepo = GithubLocal.getRepo(lName, pRepos[0].name);
lRepo.getTree('master?recursive=true', lGetTree);
}
else
DOM.Cache.remove('token');
},
lShowUserInfo = function(pError, pData){
if(!pError){
console.log('Hello ' + pData.name + ' :)!');
lName = pData.name;
console.log('Hello ' + lName + ' :)!');
User.repos(lShowRepos);
}
else

View file

@ -44,9 +44,7 @@
lClientId = lEnv.oauth_client_id || lId,
lClientSecret = lEnv.oauth_client_secret || lSecret;
console.log(lEnv);
var data = qs.stringify({
client_id : lClientId,
client_secret : lClientSecret,