@@ -9,14 +9,20 @@ function quoteText(text) {
99 } ) . join ( "\n" ) ;
1010}
1111
12- function getContentAsync ( apiURL ) {
12+ function getContentAsync ( contentURL ) {
13+ if ( / ^ h t t p s : \/ \/ a p i .g i t h u b .c o m \/ r e p o s / . test ( contentURL ) ) {
1314 // https://github.com/jser/jser.info/edit/gh-pages/data/2015/08/index.json
1415 // => https://api.github.com/repos/jser/jser.info/contents/data/2015/08/index.json
15- return fetch ( apiURL ) . then ( function ( response ) {
16+ return fetch ( contentURL ) . then ( function ( response ) {
1617 return response . json ( ) ;
1718 } ) . then ( function ( response ) {
1819 return decodeURIComponent ( escape ( atob ( response . content ) ) ) ;
1920 } ) ;
21+ } else {
22+ return fetch ( contentURL ) . then ( function ( response ) {
23+ return response . text ( ) ;
24+ } ) ;
25+ }
2026}
2127
2228function getResourceURL ( config , filePath , branch ) {
@@ -29,11 +35,19 @@ function getResourceURL(config, filePath, branch) {
2935function getEditURL ( config , filePath , branch ) {
3036 return urlJoin ( `https://github.com/` , config . repo , `edit` , branch , filePath ) ;
3137}
32- function getAPIURL ( config , filePath ) {
33- if ( config [ "githubAPIBaseURL" ] ) {
34- return urlJoin ( config [ "githubAPIBaseURL" ] , filePath ) ;
38+ function getContentURL ( config , filePath ) {
39+ if ( config . private ) {
40+ return urlJoin (
41+ location . origin ,
42+ "gitbook/gitbook-plugin-github-issue-feedback/contents" ,
43+ filePath
44+ ) ;
45+ } else {
46+ if ( config [ "githubAPIBaseURL" ] ) {
47+ return urlJoin ( config [ "githubAPIBaseURL" ] , filePath ) ;
48+ }
49+ return urlJoin ( `https://api.github.com/repos/` , config . repo , `contents` , filePath ) ;
3550 }
36- return urlJoin ( `https://api.github.com/repos/` , config . repo , `contents` , filePath ) ;
3751}
3852
3953function getIssueURL ( config ) {
@@ -53,14 +67,14 @@ window.require(["gitbook"], function(gitbook) {
5367 var clickEvent = ( "ontouchstart" in window ) ? "touchend" : "click" ;
5468 reportElement . addEventListener ( clickEvent , function ( event ) {
5569 var pathname = path . join ( gitbook . state . config . root || "./" , gitbook . state . filepath ) ;
56- var apiURL = getAPIURL ( config , pathname ) ;
70+ var contentURL = getContentURL ( config , pathname ) ;
5771 var resourceURL = getResourceURL ( config , pathname , "master" ) ;
5872 var editURL = getEditURL ( config , pathname , "master" ) ;
5973 var chapterTitle = gitbook . state . chapterTitle ;
6074 var bug = new BugReporter ( getIssueURL ( config ) ) ;
6175 var selectedText = bug . getSelectedText ( ) . trim ( ) ;
6276 bug . setTitle ( chapterTitle ) ;
63- getContentAsync ( apiURL ) . then ( function ( markdown ) {
77+ getContentAsync ( contentURL ) . then ( function ( markdown ) {
6478 let body = 'URL : ' + resourceURL + "\n\n" ;
6579 if ( selectedText && selectedText . length > 0 ) {
6680 var matches = findAllPositions ( {
0 commit comments