Skip to content

Instantly share code, notes, and snippets.

@wseaton
Last active Mar 16, 2021
Embed
What would you like to do?
add nbviewer button to jupyterhub
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