diff --git a/src/inject.js b/src/inject.js index 0b41076..d2cbc8a 100755 --- a/src/inject.js +++ b/src/inject.js @@ -4,8 +4,8 @@ , SHOWN = 'octotree.shown' , REGEXP = /([^\/]+)\/([^\/]+)(?:\/([^\/]+))?/ // (username)/(reponame)/(subpart) , RESERVED_USER_NAMES = [ - 'settings', 'orgs', 'organizations', - 'site', 'blog', 'about', + 'settings', 'orgs', 'organizations', + 'site', 'blog', 'about', 'styleguide', 'showcases', 'trending', 'stars', 'dashboard', 'notifications' ] @@ -82,7 +82,7 @@ var match = location.pathname.match(REGEXP) if (!match) return false - + // Not a repository, skip if (~RESERVED_USER_NAMES.indexOf(match[1])) return false if (~RESERVED_REPO_NAMES.indexOf(match[2])) return false @@ -90,8 +90,8 @@ // Not a code page, skip if (match[3] && !~['tree', 'blob'].indexOf(match[3])) return false - return { - username : match[1], + return { + username : match[1], reponame : match[2], branch : $('*[data-master-branch]').data('ref') || $('*[data-master-branch] > .js-select-button').text() || 'master' } @@ -163,6 +163,11 @@ else message = 'You have exceeded the GitHub API hourly limit and need GitHub access token to make extra requests. Follow this link to create one and paste it in the textbox below.' } + else if (err.error === 409) { + header = 'Repository is empty or not yet available!' + message = 'This repository is not ready for browsing yet. Follow this link for details.' + } + updateSidebar('
' + header + '
', message) } @@ -183,19 +188,19 @@ .on('click', function(e) { var $target = $(e.target) if ($target.is('a.jstree-anchor') && $target.children(':first').hasClass('blob')) { - $.pjax({ - url : $target.attr('href'), + $.pjax({ + url : $target.attr('href'), timeout : 5000, //gives it more time, should really have a progress indicator... - container : $('#js-repo-pjax-container') + container : $('#js-repo-pjax-container') }) } }) .on('ready.jstree', function() { - var headerText = '
' + - repo.username + ' / ' + repo.reponame + + var headerText = '
' + + repo.username + ' / ' + repo.reponame + '
' + - '
' + - repo.branch + + '
' + + repo.branch + '
' updateSidebar(headerText) }) @@ -225,7 +230,7 @@ if (shown) $html.removeClass(PREFIX) else $html.addClass(PREFIX) store.set(SHOWN, !shown) - } + } function saveToken(event) { event.preventDefault()