Skip to content

Commit

Permalink
Merge pull request #623 from juanrg/master
Browse files Browse the repository at this point in the history
Fixed a bug on the Github Enterprise version of the github provider
  • Loading branch information
minrk committed Sep 5, 2016
2 parents 578c361 + 108aed5 commit c8f1f49
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions nbviewer/providers/github/handlers.py
Expand Up @@ -39,6 +39,9 @@
}


def _github_url():
return os.environ.get('GITHUB_URL') if os.environ.get('GITHUB_URL', '') else "https://github.com/"

class GithubClientMixin(object):
@property
def github_client(self):
Expand Down Expand Up @@ -100,7 +103,8 @@ def get(self, user):
url=repo['name'],
name=repo['name'],
))
provider_url = u"https://github.com/{user}".format(user=user)

provider_url = u"{github_url}{user}".format(user=user, github_url = _github_url())
html = self.render_template("userview.html",
entries=entries, provider_url=provider_url,
next_url=next_url, prev_url=prev_url,
Expand Down Expand Up @@ -152,8 +156,9 @@ def get(self, user, repo, ref, path):
base_url = u"/github/{user}/{repo}/tree/{ref}".format(
user=user, repo=repo, ref=ref,
)
provider_url = u"https://github.com/{user}/{repo}/tree/{ref}/{path}".format(
user=user, repo=repo, ref=ref, path=path,

provider_url = u"{github_url}{user}/{repo}/tree/{ref}/{path}".format(
user=user, repo=repo, ref=ref, path=path, github_url = _github_url()
)

breadcrumbs = [{
Expand Down Expand Up @@ -236,8 +241,8 @@ def get(self, user, repo, ref, path):
raw_url = u"https://raw.githubusercontent.com/{user}/{repo}/{ref}/{path}".format(
user=user, repo=repo, ref=ref, path=quote(path)
)
blob_url = u"https://github.com/{user}/{repo}/blob/{ref}/{path}".format(
user=user, repo=repo, ref=ref, path=quote(path),
blob_url = u"{github_url}{user}/{repo}/blob/{ref}/{path}".format(
user=user, repo=repo, ref=ref, path=quote(path), github_url=_github_url()
)
with self.catch_client_error():
tree_entry = yield self.github_client.get_tree_entry(
Expand Down

0 comments on commit c8f1f49

Please sign in to comment.