Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Strip .ipynb extension for display in header and tab title #296

Merged
merged 4 commits into from
Dec 2, 2021

Conversation

JasonWeill
Copy link
Contributor

@JasonWeill JasonWeill commented Dec 1, 2021

Fixes #160 by stripping only .ipynb from the end of filenames displayed in the workbook title.

Before the change, "Untitled.ipynb" appears to the right of the Jupyter logo in the top area and in the tab title.
image

After the change, "Untitled" appears in these areas.
image

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2021

Binder 👈 Launch RetroLab on Binder

@JasonWeill
Copy link
Contributor Author

The "enforce-label" job failed, but the enhancement label is present on this issue.

@JasonWeill
Copy link
Contributor Author

Can someone please assign this issue to me?

@jtpio jtpio added the enhancement New feature or request label Dec 2, 2021
@jtpio jtpio added this to the 0.3.x milestone Dec 2, 2021
@jtpio
Copy link
Member

jtpio commented Dec 2, 2021

Thanks @jweill-aws!

Mind posting a small before / after screenshot in the top comment for reference?

@jtpio
Copy link
Member

jtpio commented Dec 2, 2021

We could also apply the same logic to the browser tab title:

image

Which is updated in this plugin:

/**
* A plugin to display the document title in the browser tab title
*/
const tabTitle: JupyterFrontEndPlugin<void> = {
id: '@retrolab/application-extension:tab-title',
autoStart: true,
requires: [IRetroShell],
activate: (app: JupyterFrontEnd, shell: IRetroShell) => {
const setTabTitle = () => {
const current = shell.currentWidget;
if (current instanceof ConsolePanel) {
const update = () => {
const title =
current.sessionContext.path || current.sessionContext.name;
const basename = PathExt.basename(title);
document.title = basename;
};
current.sessionContext.sessionChanged.connect(update);
update();
return;
} else if (current instanceof DocumentWidget) {
const update = () => {
const basename = PathExt.basename(current.context.path);
document.title = basename;
};
current.context.pathChanged.connect(update);
update();
}
};
shell.currentChanged.connect(setTabTitle);
setTabTitle();
}
};

@JasonWeill JasonWeill changed the title Strip .ipynb extension for display in header Strip .ipynb extension for display in header and tab title Dec 2, 2021
Copy link
Member

@jtpio jtpio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jtpio jtpio merged commit 49b9ae3 into jupyterlab:main Dec 2, 2021
@JasonWeill JasonWeill deleted the shorter-title branch December 3, 2021 18:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't display .ipynb in notebook title
2 participants