Skip to content

Commit

Permalink
Trac #19885: Jupyter documentation fails for notebooks in subdirectories
Browse files Browse the repository at this point in the history
Exactly the same as #19469, but for help links.

Steps to reproduce:
* Start sage --notebook=jupyter
* In the Jupyter file browser, select New -> Folder
* Click on the newly-created "Untitled Folder" (name does not matter)
* Create a new Sage kernel notebook in this subfolder
* Click on Help -> Sage Documentation

Opened URL is `http://localhost:8888/notebooks/Untitled%20Folder/kernels
pecs/sagemath/doc/index.html`

Correct URL would be
`http://localhost:8888/kernelspecs/sagemath/doc/reference/index.html`

URL: http://trac.sagemath.org/19885
Reported by: vbraun
Ticket author(s): Volker Braun
Reviewer(s): Emmanuel Charpentier
  • Loading branch information
Release Manager authored and vbraun committed Jan 20, 2016
2 parents 0d8435c + 65cd4d2 commit 7841f42
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build/pkgs/notebook/package-version.txt
@@ -1 +1 @@
4.0.4.p2
4.0.4.p3
24 changes: 24 additions & 0 deletions build/pkgs/notebook/patches/help_link_url_fix.patch
@@ -0,0 +1,24 @@
Use require.toUrl for help_links

Dirty patch for the minified js, real PR is at
https://github.com/jupyter/notebook/pull/958


--- a/notebook/static/notebook/js/main.min.js 2016-01-15 10:20:30.769442884 +0100
+++ b/notebook/static/notebook/js/main.min.js 2016-01-15 10:20:53.073164049 +0100
@@ -28358,7 +28358,7 @@
.append($("<a>")
.attr('target', '_blank')
.attr('title', 'Opens in a new window')
- .attr('href', link.url)
+ .attr('href', require.toUrl(link.url))
.append($("<i>")
.addClass("fa fa-external-link menu-icon pull-right")
)
@@ -30547,4 +30547,4 @@
define("notebook/js/main", function(){});


-//# sourceMappingURL=main.min.js.map
\ No newline at end of file
+//# sourceMappingURL=main.min.js.map
11 changes: 8 additions & 3 deletions src/sage/repl/ipython_kernel/kernel.py
Expand Up @@ -81,22 +81,27 @@ def help_links(self):
See the Jupyter documentation.
.. NOTE::
Urls starting with "kernelspecs" are prepended by the
browser with the appropriate path.
EXAMPLES::
sage: from sage.repl.ipython_kernel.kernel import SageKernel
sage: sk = SageKernel.__new__(SageKernel)
sage: sk.help_links
[{'text': 'Sage Documentation',
'url': '../kernelspecs/sagemath/doc/index.html'},
'url': 'kernelspecs/sagemath/doc/index.html'},
...]
"""
from sage.repl.ipython_kernel.install import SageKernelSpec
identifier = SageKernelSpec.identifier()
kernel_url = lambda x: '../kernelspecs/{0}/{1}'.format(identifier, x)
kernel_url = lambda x: 'kernelspecs/{0}/{1}'.format(identifier, x)
return [
{
'text': 'Sage Documentation',
'url': kernel_url('doc/index.html')
'url': kernel_url('doc/index.html'),
},
{
'text': 'Sage Tutorial',
Expand Down

0 comments on commit 7841f42

Please sign in to comment.