|
18 | 18 | clean_filename,
|
19 | 19 | quote,
|
20 | 20 | response_text,
|
| 21 | + url_path_join, |
21 | 22 | )
|
22 | 23 |
|
23 | 24 | from ..github.handlers import GithubClientMixin
|
@@ -97,8 +98,11 @@ def get(self, user, **namespace):
|
97 | 98 | notebooks=notebooks,
|
98 | 99 | description=gist['description'] or '',
|
99 | 100 | ))
|
100 |
| - gist_url = os.environ.get('GIST_URL', 'https://gist.github.com/') |
101 |
| - provider_url = gist_url + u"{user}".format(user=user) |
| 101 | + if self.github_url == 'https://github.com/': |
| 102 | + gist_base_url = 'https://gist.github.com/' |
| 103 | + else: |
| 104 | + gist_base_url = url_path_join(self.github_url, 'gist/') |
| 105 | + provider_url = url_path_join(gist_base_url, u"{user}".format(user=user)) |
102 | 106 | html = self.render_usergists_template(entries=entries, user=user, provider_url=provider_url,
|
103 | 107 | prev_url=prev_url, next_url=next_url, **namespace
|
104 | 108 |
|
@@ -158,12 +162,15 @@ def tree_get(self, user, gist_id, gist, files):
|
158 | 162 | e['class'] = 'fa-book'
|
159 | 163 | ipynbs.append(e)
|
160 | 164 | else:
|
161 |
| - gist_url = os.environ.get('GIST_URL', 'https://gist.github.com/') |
162 |
| - provider_url = gist_url + u"{user}/{gist_id}#file-{clean_name}".format( |
| 165 | + if self.github_url == 'https://github.com/': |
| 166 | + gist_base_url = 'https://gist.github.com/' |
| 167 | + else: |
| 168 | + gist_base_url = url_path_join(self.github_url, 'gist/') |
| 169 | + provider_url = url_path_join(gist_base_url, u"{user}/{gist_id}#file-{clean_name}".format( |
163 | 170 | user=user,
|
164 | 171 | gist_id=gist_id,
|
165 | 172 | clean_name=clean_filename(file['filename']),
|
166 |
| - ) |
| 173 | + )) |
167 | 174 | e['url'] = provider_url
|
168 | 175 | e['class'] = 'fa-share'
|
169 | 176 | others.append(e)
|
@@ -316,11 +323,11 @@ def uri_rewrites(rewrites=[]):
|
316 | 323 | u'/{1}'),
|
317 | 324 | ]
|
318 | 325 | # github enterprise
|
319 |
| - if os.environ.get('GIST_URL', '') != '': |
320 |
| - gist_url = os.environ.get('GIST_URL') |
| 326 | + if os.environ.get('GITHUB_API_URL', '') != '': |
| 327 | + gist_base_url = url_path_join(os.environ.get('GITHUB_API_URL').split('/api/v3')[0], 'gist/') |
321 | 328 | gist_rewrites.extend([
|
322 |
| - # embedded in URL |
323 |
| - (r'^' + gist_url + r'([^\/]+/)?([a-f0-9]+)/?$', |
| 329 | + # Fetching the Gist ID which is embedded in the URL, but with a different base URL |
| 330 | + (r'^' + gist_base_url + r'([^\/]+/)?([a-f0-9]+)/?$', |
324 | 331 | u'/{1}'),
|
325 | 332 | ])
|
326 | 333 |
|
|
0 commit comments