mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
added ability to read trees from github
This commit is contained in:
parent
0d7c892cab
commit
b6aceb4a82
2 changed files with 27 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue