Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS: Refactor link & badge generation, use URLs (not string) for base URLs #1778

Merged
merged 2 commits into from
Oct 18, 2023

Conversation

yuvipanda
Copy link
Collaborator

@yuvipanda yuvipanda commented Oct 16, 2023

This is two changes that were easier to make together

  • BASE_URL and BADGE_BASE_URL are now URL objects rather than strings that are manipulated. With this done, we no longer use string manipulation for URLs anywhere!
  • Both BASE_URL and BADGE_BASE_URL are now always set, as we had a bunch of code that was using BADGE_BASE_URL if available but falls back to BASE_URL + origin if it was not set. This fallback
    is now implemented globally, and correctly.
  • BASE_URL is also now always fully qualified, and we document that
    the python code ensures it has a trailing slash always.
  • The function to make links and generate badge markup is moved into @jupyterhub/binderhub-client as it is reasonably generic and not super specific to our frontend alone. This also involves them not reading BASE_URL and BADGE_BASE_URL globally, but having that information be passed in. Tests are also added here to catch any future issues that may arise.
  • Note for future fix - BADGE_BASE_URL is really PUBLIC_BASE_URL or similar, as it is used both for the location of the badge image (original intent) but also for the links we generate to share. This is relevant only for federation, where we want shared links to point to mybinder.org even though the API call itself may go to a specific member of the federation. I will do this deprecation + rename in a future PR so as to not make this PR bigger.

Here is a screen recording of me testing this out. You can see url generation + badge generation work fine for a couple cases, as well as building + launching.

Screen.Recording.2023-10-16.at.2.04.36.PM.mov

Ref #774

@yuvipanda yuvipanda changed the title JS: Refactor link & badge generation, use URLs (not string) for base … JS: Refactor link & badge generation, use URLs (not string) for base URLs Oct 16, 2023
@yuvipanda yuvipanda added tests code:html/js/css html/js/css changes. code:js-binderhub-client js changes to binderhub-client labels Oct 16, 2023
@yuvipanda yuvipanda force-pushed the badgey branch 2 times, most recently from 38fbf20 to 969df0e Compare October 16, 2023 08:43
…URLs

This is two changes that were easier to make together

- BASE_URL and BADGE_BASE_URL are now URL objects rather than strings
  that are manipulated. With this done, we no longer use string
  manipulation for URLs anywhere!
- Both BASE_URL and BADGE_BASE_URL are now always set, as we had a
  bunch of code that was using BADGE_BASE_URL if available but
  falls back to BASE_URL + origin if it was not set. This fallback
  is now implemented globally, and correctly.
- BASE_URL is also now always fully qualified, and we document that
  the python code ensures it has a trailing slash always.
- The function to make links and generate badge markup is moved into
  `@jupyterhub/binderhub-client` as it is reasonably generic and
  not super specific to our frontend alone. This also involves them
  not reading BASE_URL and BADGE_BASE_URL globally, but having that
  information be passed in. Tests are also added here to catch any
  future issues that may arise.
- Note for future fix - BADGE_BASE_URL is really PUBLIC_BASE_URL or
  similar, as it is used both for the location of the badge image
  (original intent) but also for the links we generate to share. This
  is relevant only for federation, where we want shared links to
  point to mybinder.org even though the API call itself may go to
  a specific member of the federation. I will do this deprecation +
  rename in a future PR so as to not make this PR bigger.

Ref jupyterhub#774
@yuvipanda
Copy link
Collaborator Author

Test failures still unrelated

@yuvipanda yuvipanda requested a review from minrk October 17, 2023 09:42
@consideRatio
Copy link
Member

Like in #1773 (comment)

I think its a good call to opt for a merge at this point even though I'm not so confident reviewing this, it helps with Yuvi's contribution momentum and we aren't introducing new API or similar that we commit to long term in this PR either.

I've done my best to review this, and I think it looks good!

@consideRatio consideRatio merged commit 9f6ea44 into jupyterhub:main Oct 18, 2023
13 of 15 checks passed
@consideRatio consideRatio added maintenance Under the hood improvements and fixes and removed tests labels Oct 18, 2023
@consideRatio
Copy link
Member

I removed tests and added maintenance. maintenance is a label respected by github-activity, while tests isn't.

@yuvipanda
Copy link
Collaborator Author

Thanks @consideRatio, I appreciate it! When both these PRs are merged, I'll roll them out to mybinder.org and keep an eye out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code:html/js/css html/js/css changes. code:js-binderhub-client js changes to binderhub-client maintenance Under the hood improvements and fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants