Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix opening files from the CLI#6946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jtpio merged 1 commit intojupyter:mainfromjtpio:redirect-regex
Jun 26, 2023
Merged

Conversation

@jtpio
Copy link
Member

Investigate ways tofix#6914

@github-actions
Copy link
Contributor

Binder 👈 Launch a Binder on branchjtpio/notebook/redirect-regex

@jtpiojtpio added this to the7.0 milestoneJun 23, 2023
@jtpio
Copy link
MemberAuthor

So the idea if that we should be able to open files from the CLI by using the existing/tree/<file> redirection logic.

@jtpio
Copy link
MemberAuthor

cc@parmentelat if you want to try with the built artifacts:https://github.com/jupyter/notebook/actions/runs/5356963835?pr=6946

@jtpiojtpio marked this pull request as ready for reviewJune 26, 2023 06:50
@jtpio
Copy link
MemberAuthor

For referencefile_url_prefix is documented here in Jupyter Server:https://jupyter-server.readthedocs.io/en/latest/developers/extensions.html#anatomy-of-an-extensionapp

file_url_prefix: the prefix URL added when opening a document directly from the command line. For example, classic Notebook uses /notebooks to open a document athttp://localhost:8888/notebooks/path/to/notebook.ipynb.

extension_url="/"
default_url=Unicode("/tree",config=True,help="The default URL to redirect to from `/`")
file_url_prefix="/notebooks"
file_url_prefix="/tree"
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

So the idea of using/tree is that there is already a redirect handler to open either with/edit or/notebooks:

asyncdefget(self,path=None):
"""
Display appropriate page for given path.
- A directory listing is shown if path is a directory
- Redirected to notebook page if path is a notebook
- Render the raw file if path is any other file
"""
path=path.strip("/")
cm=self.contents_manager
ifawaitensure_async(cm.dir_exists(path=path)):
ifawaitensure_async(cm.is_hidden(path))andnotcm.allow_hidden:
self.log.info("Refusing to serve hidden directory, via 404 Error")
raiseweb.HTTPError(404)
# Set treePath for routing to the directory
page_config=self.get_page_config()
page_config["treePath"]=path
tpl=self.render_template("tree.html",page_config=page_config)
returnself.write(tpl)
elifawaitensure_async(cm.file_exists(path)):
# it's not a directory, we have redirecting to do
model=awaitensure_async(cm.get(path,content=False))
ifmodel["type"]=="notebook":
url=ujoin(self.base_url,"notebooks",url_escape(path))
else:
# Return raw content if file is not a notebook
url=ujoin(self.base_url,"files",url_escape(path))
self.log.debug("Redirecting %s to %s",self.request.path,url)
self.redirect(url)
else:
raiseweb.HTTPError(404)

@jtpiojtpio merged commit27c00bc intojupyter:mainJun 26, 2023
@jtpiojtpio deleted the redirect-regex branchJune 26, 2023 07:50
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsJun 28, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

No reviews

Assignees

@jtpiojtpio

Labels

Projects

None yet

Milestone

7.0

Development

Successfully merging this pull request may close these issues.

cannot open a jupytext notebook in nb7

1 participant

@jtpio

[8]ページ先頭

©2009-2025 Movatter.jp