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

Consume new ghtutorial route when loading tutorials from github #10217

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

riknoll
Copy link
Member

@riknoll riknoll commented Oct 7, 2024

This consumes the newly proposed /api/ghtutorial/ endpoint. Opening as a draft PR because this endpoint isn't actually released yet.

When loading a tutorial from github, this takes the response from /api/ghtutorial/ and uses it to populate all of the caches that we maintain in indexeddb. The rest of the markdown loading pipeline is unchanged, the requests it makes simply hit the cache instead of actually making requests to the backend.

This PR also makes it so that we now cache the latest versions of github repos inside indexeddb just like we do everything else. Unlike the other things we cache, the entries for latest versions expire after an hour. I might end up increasing this period, though, since that isn't very much time at all.

I also added a skipgithubcache=1 query parameter that bypasses all of our local github repo caches to make it easier for content creators to verify their changes.

also tacked on an unrelated change making it so that the saveblocks query param is now case insensitive and accepts saveasblocks since I always accidentally try that first.

@riknoll riknoll requested a review from a team October 7, 2024 17:51
Copy link
Contributor

@eanders-ms eanders-ms left a comment

Choose a reason for hiding this comment

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

Looks good

@riknoll
Copy link
Member Author

riknoll commented Oct 17, 2024

updated with the changes I made to the API route. this now also works with tutorials in the docs folder of targets, uses etags, and proxies requests through the CDN.

here's an upload target you can use to test (micro:bit):

https://makecode.microbit.org/app/de79fa186a7b3225ed5aeb161ea70ec7796af70e-ac898cc414

and here's a URL that includes a docs tutorial that has a GitHub dependency:

https://makecode.microbit.org/app/de79fa186a7b3225ed5aeb161ea70ec7796af70e-ac898cc414?nocdn=1#tutorial:/projects/micro-coin

the ?nocdn=1 is a new query param i added to bypass the CDN. required for this example because the CDN hits our production backend which does not have the new API deployed yet. I recommend opening the tutorial link in an incognito window to make sure you aren't hitting any local caches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants