nbgallery / lab-extensions

Repo for JupyterLab NBGallery Extensions
MIT License
1 stars 2 forks source link

Why is .origin called when constructing url? #50

Closed marto1 closed 1 year ago

marto1 commented 1 year ago

Hi,

I'm trying to make the jupyterlab extensions work for sending notebooks from a Jupyter instance to NBGallery. It was refusing to work and I went through a couple of versions after which I arrived at the source of the issue: https://github.com/nbgallery/lab-extensions/blob/a1f07299aa94835da375b1b351235457f58efa09/gallerymenu/src/index.ts#L334

Can someone explain why the URLs are constructed using .origin instead of e.g. .href ? I have my nbgallery instance located at https://domain.com/nbgallery and the /nbgallery part is obviously cut off? Is this a bug or was there some different intention behind this?

I have the environment variables set like so:

NBGALLERY_URL=https://domain.com/nbgallery
NBGALLERY_CLIENT_NAME=""
NBGALLERY_ENABLE_AUTODOWNLOAD=0
mcrutch commented 1 year ago

So that specific one could be fixed easily but since I never got a suitable fix finalized for https://github.com/nbgallery/nbgallery/issues/686 I haven't really spent much time working on against a gallery not at running at server root.

Are you on Lab 4.x or 3.x? (affects what version I would have to patch) There will still be some annoying things to handle with linked a notebook (https://github.com/nbgallery/lab-extensions/blob/a1f07299aa94835da375b1b351235457f58efa09/gallerymenu/src/index.ts#L428C18-L470)

marto1 commented 1 year ago

Hi @mcrutch , Thanks for the quick turnaround! I'm using Version 3.2.3 with jupyterlab-nbgallery version 1.0.5 unfortunately since a further push would require a lot more package upgrades that I can't do right now since they will break a lot of other stuff.

I mostly raised the issue to make sure it's addressed upstream :-)

mcrutch commented 1 year ago

Try installing jupyterlab-nbgallery==1.0.6a0 and see if that works for you.

marto1 commented 1 year ago

It works! I also tested with NBGALLERY_URL=https://domain.com/nbgallery/ and then it breaks, nbgallery doesn't like the // in the url, just a note. Thank you!

mcrutch commented 1 year ago

1.0.6a1 might fix that. There were a couple spots I was still just doing string building manually rather than URLExt.join

mcrutch commented 1 year ago

link notebook is the only thing that isn't gonna work right now. and I am porting all of these changes to the 3.x line for Lab 4. Probably not going to patch 2.x because 2.x is lab 3.6+ only, 1.x will work in lab 3.6 and lab 4 should use 3.x of the library

mcrutch commented 1 year ago

1.0.6 final release is out. Link Notebook should now work, and save changes works properly now (the alpha releases were broken on save changes)