Skip to content

Commit bf79ab3

Browse files
authored
Merge branch 'master' into update_051
2 parents b36c595 + a64846d commit bf79ab3

File tree

7 files changed

+46
-6
lines changed

7 files changed

+46
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ which makes it much easier to fill in each release's changelog :)
2525
-----
2626

2727
- Fix for navigation hotkeys [#1378](https://github.com/ipython-contrib/jupyter_contrib_nbextensions/pull/1378)
28-
- Make endpoint for gists configurable [#1364](https://github.com/ipython-contrib/jupyter_contrib_nbextensions/pull/1364)
28+
- `gist_it` Making github endpoint configurable to support publishing gists to Github Enterprise [#1364](https://github.com/ipython-contrib/jupyter_contrib_nbextensions/pull/1364)
2929
- Fix treefilter [#1359](https://github.com/ipython-contrib/jupyter_contrib_nbextensions/pull/1359)
3030
- Enable ruler extension in editor [#1296](https://github.com/ipython-contrib/jupyter_contrib_nbextensions/pull/1296)
3131
- Several spelling fixes

src/jupyter_contrib_nbextensions/nbextensions/codefolding/readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Three different folding modes are supported:
1717

1818
### Indent Folding
1919

20-
Python-style code folding, detetects indented code.
20+
In the image below, the Codefolding extension detects unfolded, Python-style indentations:
21+
2122
![Unfolded](codefolding_indent_unfolded.png)
2223

2324
The unfolded code above can be folded like this:

src/jupyter_contrib_nbextensions/nbextensions/gist_it/gist_it.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ Link: readme.md
77
Icon: icon.png
88
Parameters:
99
- name: gist_it_personal_access_token
10-
description: (optional) Github personal access token.
10+
description: Github personal access token. To write gists on a user's behalf, you need a token with the <a href="https://developer.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/">gist OAuth scope</a>.
1111
input_type: text
1212
- name: gist_it_default_to_public
1313
description: Gists default to public. If using a personal access token, gists will default to private. Set this to have them default to being public instead.
1414
input_type: checkbox
15+
- name: github_endpoint
16+
description: Github endpoint. Defaults to 'github.com'. Change this to publish to your enterprise github endpoint.
17+
input_type: text
18+
default: 'github.com'

src/jupyter_contrib_nbextensions/nbextensions/gist_it/main.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ define([
3939
var params = {
4040
gist_it_default_to_public: false,
4141
gist_it_personal_access_token: '',
42+
github_endpoint: 'github.com'
4243
};
4344

4445
var initialize = function () {
@@ -170,8 +171,10 @@ define([
170171
.addClass('fa-circle-o-notch fa-spin');
171172
// List commits as a way of checking whether the gist exists.
172173
// Listing commits appears to give the most concise response.
174+
var github_endpoint = params.github_endpoint !== '' ? params.github_endpoint : 'github.com';
175+
173176
$.ajax({
174-
url: 'https://api.github.com/gists/' + id + '/commits',
177+
url: 'https://api.'+ github_endpoint +'/gists/' + id + '/commits',
175178
dataType: 'json',
176179
beforeSend: add_auth_token,
177180
error: function(jqXHR, textStatus, errorThrown) {
@@ -190,7 +193,7 @@ define([
190193
help_block_html += '<p>' +
191194
'<i class="fa fa-pencil-square"></i>' +
192195
' gist ' +
193-
'<a href="https://gist.github.com/' + id +
196+
'<a href="https://'+ github_endpoint + '/gist/' + id +
194197
'" target="_blank">' + id + '</a> will be updated' +
195198
' (' + jqXHR.responseJSON.length +
196199
' revision' + (single ? '' : 's') +
@@ -440,9 +443,10 @@ define([
440443
var id = params.gist_it_personal_access_token !== '' ? id_input.val() : '';
441444
var method = id ? 'PATCH' : 'POST';
442445

446+
var github_endpoint = params.github_endpoint !== '' ? params.github_endpoint : 'github.com';
443447
// Create/edit the Gist
444448
$.ajax({
445-
url: 'https://api.github.com/gists' + (id ? '/' + id : ''),
449+
url: 'https://api.'+ github_endpoint +'/gists' + (id ? '/' + id : ''),
446450
type: method,
447451
dataType: 'json',
448452
data: JSON.stringify(data),

src/jupyter_contrib_nbextensions/nbextensions/init_cell/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ Options
1818
This nbextension provides option configurable using the
1919
[jupyter_nbextensions_configurator](https://github.com/Jupyter-contrib/jupyter_nbextensions_configurator).
2020

21+
Once the extension is enabled, turn on the cell toolbar within your Notebook using
22+
the "View > Cell Toolbar > Initialization Cell" menu
23+
![Cell Toobar Menu](cell_toolbar_menu.png)
24+
25+
2126
The running of initialization cells on kernel ready notification can be
2227
frustrating if your kernel is attached to multiple frontends, or is persistent
2328
between frontend reloads (e.g. reloading the notebook browser page without
43.5 KB
Loading

src/jupyter_contrib_nbextensions/nbextensions/toc2/toc2.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,17 @@
134134
$.ajax()
135135
}, 100);
136136
evt.preventDefault();
137+
// Each time a link is clicked in the toc, save the current position and target in the history
138+
var currentSection = $('#toc .highlight_on_scroll a').data('tocModifiedId')
139+
if (window.history.state != null){
140+
if (window.history.state.back != currentSection) {
141+
window.history.pushState({'back':currentSection},"",'')
142+
}
143+
}
137144
var trg_id = $(evt.currentTarget).attr('data-toc-modified-id');
145+
window.history.pushState({'back':trg_id},"",'');
146+
window.history.lastjump = trg_id;
147+
138148
// use native scrollIntoView method with semi-unique id
139149
// ! browser native click does't follow links on all browsers
140150
document.getElementById(trg_id).scrollIntoView(true)
@@ -149,6 +159,22 @@
149159
}
150160
};
151161

162+
//
163+
window.addEventListener('popstate',
164+
function(e) {
165+
if (e.state != null && e.state.back != null) {
166+
var back_id = e.state.back;
167+
document.getElementById(back_id).scrollIntoView(true)
168+
if (liveNotebook) {
169+
var cell = $(document.getElementById(back_id)).closest('.cell').data('cell');
170+
Jupyter.notebook.select(Jupyter.notebook.find_cell_index(cell));
171+
highlight_toc_item("toc_link_click", {
172+
cell: cell
173+
});
174+
}
175+
}
176+
});
177+
152178
var make_link = function(h, toc_mod_id) {
153179
var a = $('<a>')
154180
.attr({

0 commit comments

Comments
 (0)