Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ShareLink
=========
This extension adds a toolbar button to copy the shareable link to another user that have access to the notebook.

![printview toolbar button](share-link-button.png)

link preview: https://\<URL>/hub/user-redirect/notebooks/shared_folder/Untitled.ipynb?kernel_name=python3
32 changes: 32 additions & 0 deletions src/jupyter_contrib_nbextensions/nbextensions/share_link/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
define([
'base/js/namespace'
], function(
Jupyter
) {
function load_ipython_extension() {

var handler = function () {
var curUrl = window.location.href;
var rgx = curUrl.match("\/user\/.*?(?=\/)");
var editedUrl = curUrl.replace(rgx,"/hub/user-redirect");
console.log(editedUrl)
navigator.clipboard.writeText(editedUrl)
.then(() => alert('the URL have been copied to clipboard'));
};

var action = {
icon : 'fa-share-alt', // a font-awesome class used on buttons, etc
help : 'Copy Shareable Link to Clipboard',
handler : handler
};
var prefix = 'shareLink';
var action_name = 'share-link';

var full_action_name = Jupyter.actions.register(action, action_name, prefix); // returns 'custom_extension:share-link'
Jupyter.toolbar.add_buttons_group([full_action_name]);
}

return {
load_ipython_extension: load_ipython_extension
};
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Type: Jupyter Notebook Extension
Name: Share Link
Link: README.md
Description: "A little extension to copy shareable link"
Main: main.js
Compatibility: 4.x, 5.x