handle 409 error
This commit is contained in:
parent
46f14f6343
commit
1e8e4ef161
|
@ -4,8 +4,8 @@
|
||||||
, SHOWN = 'octotree.shown'
|
, SHOWN = 'octotree.shown'
|
||||||
, REGEXP = /([^\/]+)\/([^\/]+)(?:\/([^\/]+))?/ // (username)/(reponame)/(subpart)
|
, REGEXP = /([^\/]+)\/([^\/]+)(?:\/([^\/]+))?/ // (username)/(reponame)/(subpart)
|
||||||
, RESERVED_USER_NAMES = [
|
, RESERVED_USER_NAMES = [
|
||||||
'settings', 'orgs', 'organizations',
|
'settings', 'orgs', 'organizations',
|
||||||
'site', 'blog', 'about',
|
'site', 'blog', 'about',
|
||||||
'styleguide', 'showcases', 'trending',
|
'styleguide', 'showcases', 'trending',
|
||||||
'stars', 'dashboard', 'notifications'
|
'stars', 'dashboard', 'notifications'
|
||||||
]
|
]
|
||||||
|
@ -81,7 +81,7 @@
|
||||||
|
|
||||||
var match = location.pathname.match(REGEXP)
|
var match = location.pathname.match(REGEXP)
|
||||||
if (!match) return false
|
if (!match) return false
|
||||||
|
|
||||||
// Not a repository, skip
|
// Not a repository, skip
|
||||||
if (~RESERVED_USER_NAMES.indexOf(match[1])) return false
|
if (~RESERVED_USER_NAMES.indexOf(match[1])) return false
|
||||||
if (~RESERVED_REPO_NAMES.indexOf(match[2])) return false
|
if (~RESERVED_REPO_NAMES.indexOf(match[2])) return false
|
||||||
|
@ -89,8 +89,8 @@
|
||||||
// Not a code page, skip
|
// Not a code page, skip
|
||||||
if (match[3] && !~['tree', 'blob'].indexOf(match[3])) return false
|
if (match[3] && !~['tree', 'blob'].indexOf(match[3])) return false
|
||||||
|
|
||||||
return {
|
return {
|
||||||
username : match[1],
|
username : match[1],
|
||||||
reponame : match[2],
|
reponame : match[2],
|
||||||
branch : $('*[data-master-branch]').data('ref') || 'master'
|
branch : $('*[data-master-branch]').data('ref') || 'master'
|
||||||
}
|
}
|
||||||
|
@ -162,6 +162,11 @@
|
||||||
else message = 'You have exceeded the GitHub API hourly limit and need GitHub access token to make extra requests. Follow <a href="https://github.com/settings/tokens/new" target="_blank">this link</a> to create one and paste it in the textbox below.'
|
else message = 'You have exceeded the GitHub API hourly limit and need GitHub access token to make extra requests. Follow <a href="https://github.com/settings/tokens/new" target="_blank">this link</a> 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 <a href="https://developer.github.com/v3/git/" target="_blank">this link</a> for details.'
|
||||||
|
}
|
||||||
|
|
||||||
updateSidebar('<div class="octotree_header_error">' + header + '</div>', message)
|
updateSidebar('<div class="octotree_header_error">' + header + '</div>', message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,19 +187,19 @@
|
||||||
.on('click', function(e) {
|
.on('click', function(e) {
|
||||||
var $target = $(e.target)
|
var $target = $(e.target)
|
||||||
if ($target.is('a.jstree-anchor') && $target.children(':first').hasClass('blob')) {
|
if ($target.is('a.jstree-anchor') && $target.children(':first').hasClass('blob')) {
|
||||||
$.pjax({
|
$.pjax({
|
||||||
url : $target.attr('href'),
|
url : $target.attr('href'),
|
||||||
timeout : 5000, //gives it more time, should really have a progress indicator...
|
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() {
|
.on('ready.jstree', function() {
|
||||||
var headerText = '<div class="octotree_header_repo">' +
|
var headerText = '<div class="octotree_header_repo">' +
|
||||||
repo.username + ' / ' + repo.reponame +
|
repo.username + ' / ' + repo.reponame +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<div class="octotree_header_branch">' +
|
'<div class="octotree_header_branch">' +
|
||||||
repo.branch +
|
repo.branch +
|
||||||
'</div>'
|
'</div>'
|
||||||
updateSidebar(headerText)
|
updateSidebar(headerText)
|
||||||
})
|
})
|
||||||
|
@ -224,7 +229,7 @@
|
||||||
if (shown) $html.removeClass(PREFIX)
|
if (shown) $html.removeClass(PREFIX)
|
||||||
else $html.addClass(PREFIX)
|
else $html.addClass(PREFIX)
|
||||||
store.set(SHOWN, !shown)
|
store.set(SHOWN, !shown)
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveToken(event) {
|
function saveToken(event) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
Loading…
Reference in New Issue