-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Sandcastle - Nested gallery structure #12631
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
base: sandcastle-v2
Are you sure you want to change the base?
Conversation
Thank you for the pull request, @jjspace! ✅ We can confirm we have a CLA on file for you. |
@ggetz I tried to split the commits a little between the new gallery files and actual code changes if that makes it easier to review |
const yamlFiles = globbySync([ | ||
`${galleryDirectory}/*/sandcastle.yaml`, | ||
`!${galleryDirectory}/list.json`, | ||
]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going with the globby
approach here instead of just listing the directories lets us "anchor" the existence of a Gallery example around a sandcastle.yaml
file.
id: billboards | ||
legacy-id: Billboards.html | ||
title: Billboards | ||
thumbnail: ./Billboards.jpg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the thumbnail
property here lets it be named anything. We had discussed maybe not including this and consistently requiring a thumbnail.png
or something the same as I am for index.html
and main.js
. Not sure which approach is better here.
The value is optional regardless if we check for a file or it's defined here.
function loadDemo(demo: GalleryDemo) { | ||
// do stuff | ||
setCode(demo.js ?? defaultJsCode, demo.html ?? defaultHtmlCode); | ||
const GALLERY_BASE = "/gallery"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that doing something like this would allow us to point it at literally any path as long as it conforms to the structure we'd expect. Namely that there's a list.json
at the root and [slug]/(index.html|main.js)
files. This could help us swap out where it points for different local/deployed builds or even potentially a different server entirely if someone wants to host their own gallery?
@ggetz I know there's still some scattered commented code and console logs. I'll do a cleanup pass on those before this gets merged but wanted to just validate the approach first. |
Description
Major changes/focus for this PR:
module
that should importCesium
andSandcastle
directlyimport
statements are not in the sandcastle code they will be added before loaded into thebucket
. AFAICT this should account for all existing sandcastles that relied on the global objectswindow
scope anymorewindow.startup
function specifically to account for modules loading out of order. Switching totype=module
eliminates thatCesium
andSandcastle
regardless of the importsindex.html
is the html/css code for a sandcastle,main.js
is the JS code for a sandcastle,sandcastle.yaml
holds the metadata and is what dictates that a subfolder is even a gallery example in the first placeindex.html
does not contain the full page structure withhead
andbody
tags. This means you can no longer load gallery items directly with a path likelocalhost:8080/Apps/Sandcastle/gallery/3D Models.html
.buildGallery.js
has been created to parse through the new gallery structure and generate a top levellist.json
file. This also does a little basic validation. Where this script lives and exactly what it does is still a little up in the airTODO:
Issue number and link
Part of #12566
Testing plan
node buildGallery.js
to generate the list filenpm run dev
and from the normal servernpm start
afternpm run build
Author checklist
CONTRIBUTORS.md
CHANGES.md
with a short summary of my change