Last active
March 16, 2021 20:27
-
-
Save wseaton/653f8d87b1c3d7bdf12cec4a82946df4 to your computer and use it in GitHub Desktop.
add nbviewer button to jupyterhub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/notebook/templates/page.html b/notebook/templates/page.html | |
index 9e68da1b2..a5539711b 100644 | |
--- a/notebook/templates/page.html | |
+++ b/notebook/templates/page.html | |
@@ -133,7 +133,13 @@ dir="ltr"> | |
{% endblock %} | |
{% block header_buttons %} | |
- | |
+ | |
+ {% block nbviewer_button %} | |
+ <span id="nbviewer_widget"> | |
+ <button onclick="createLink()" id="logout" class="btn btn-sm navbar-btn">Nbviewer</button> | |
+ </span> | |
+ {% endblock %} | |
+ | |
{% block login_widget %} | |
<span id="login_widget"> | |
@@ -189,6 +195,13 @@ dir="ltr"> | |
} | |
} | |
} | |
+ function createLink() { | |
+ var p1 = /\/notebooks/ | |
+ var p2 = /\/user\/|tree/g | |
+ var pathname = window.location.pathname.replace(p1, '').replace(p2, '') | |
+ url = 'https://your.host.here.com:8000/services/nbviewer/localfile/' + pathname | |
+ window.open(url, '_blank'); | |
+ } | |
_remove_token_from_url(); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment