Skip to content
This repository was archived by the owner on Feb 1, 2018. It is now read-only.

Commit 03280d0

Browse files
committed
use github client_id and client_secret to get tree structure
1 parent 64aaf39 commit 03280d0

4 files changed

Lines changed: 44 additions & 24 deletions

File tree

dist/main.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,15 @@
201201
Events.bind();
202202
};
203203
if (!Docbase.versions) {
204-
$.get(Docbase.options.map.path + '/' + Docbase.options.map.file)
205-
.success(prepareMapFile)
206-
.error(function(error) {
207-
// no map available for labels
208-
jWindow.trigger('mapped');
209-
Events.bind();
210-
});
204+
jWindow.trigger('mapped');
205+
206+
// $.get(Docbase.options.map.path + '/' + Docbase.options.map.file)
207+
// .success(prepareMapFile)
208+
// .error(function(error) {
209+
// // no map available for labels
210+
// jWindow.trigger('mapped');
211+
// Events.bind();
212+
// });
211213
} else {
212214
prepareMapFile(Docbase.options.versions);
213215
}
@@ -685,7 +687,10 @@
685687

686688
var baseurl = 'https://api.github.com/repos/' + options.user + '/' + options.repo + '/';
687689

688-
var url = baseurl + 'contents/' + path;
690+
var url = baseurl + 'contents?ref=' + options.branch + path;
691+
if (options.client_id && options.client_secret) {
692+
url += '&client_id=' + options.client_id + '&client_secret=' + options.client_secret;
693+
}
689694

690695
$.get(url, {
691696
ref: options.branch
@@ -697,7 +702,12 @@
697702
});
698703
if (commitData[0]) {
699704
var sha = commitData[0].sha;
700-
$.get(baseurl + 'git/trees/' + sha + '?recursive=1')
705+
var treeUrl = baseurl + 'git/trees/' + sha + '?recursive=1';
706+
if (options.client_id && options.client_secret) {
707+
treeUrl += '&client_id=' + options.client_id + '&client_secret=' + options.client_secret;
708+
}
709+
710+
$.get(treeUrl)
701711
.success(function(tree) {
702712
tree = tree.tree.filter(function(each) {
703713
return endsWith(each.path, '.md');
@@ -743,8 +753,8 @@
743753
}
744754
});
745755

756+
map = Docbase._index(map);
746757
callback(null, map);
747-
748758
})
749759
.error(function(error) {
750760
callback(error);

0 commit comments

Comments
 (0)