not for merging: factor out navigation tree - different options #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is really more of an issue but I wanted to include a quick code example.
Anyway, a big challenge right now is the output of make-site includes a full copy of the nav tree in every html file, which means that the resulting static site is huge - if you add Brick.ttl to the site and generate a site, you get 2.5 gigs of HTML. With this change it's cut down to 110 megs - still a lot, but not nearly as painful. (For reference, the current brick website is probably in the 60-ish meg size for a single version, it's a little hard to account for because it's spread out over a bunch of files in multiple parts of the tree and some JSON)
The code is straightforward, and basically copied from stackoverflow (https://stackoverflow.com/questions/8988855/include-another-html-file-in-a-html-file ) - in make-site, we dump out a tree as a fragment, and then at runtime jquery loads it and slips it into the DOM.
(Note that this pull request is incomplete - you need to actually add the jquery code. I tried added it to the main.ts in explorer-site/src/main.ts but the '$' introduced a whole slug of typescript errors on when running 'npm run build' for the tools around missing definitions for HTML elements- I tried for a while to add the right jquery typescript types but gave up, deleted my node_modules and started over - so after doing an 'npx rdf make site', I just replace public/site.min.js with the following file:
)
So this is one option that gets us part of the way there.
I think the main things that we'd like:
The jquery setup does the first 3 OK, but doesn't help us directly on the 4th.
On the 4th one, I don't think it'd be too hard to have the nav tree expand to the selected class when the page is opened. However, the tree right now can have multiple subtrees expanded and we wouldn't be able to do that without something keeping state or else simulating a page load without actually causing a full new page load.
(The current brickschema.org ontology browser opens the tree only to the current class but doesn't keep anything else in the tree expanded if anyone is clicking around and goes to the new class - if you're browsing in points and then open up equipment and click on VAV, when the VAV page loads the points tree is closed again)
We could try an iframe - I tried one for about 2 minutes and it's included in the PR though I think I'm doing it backwards, and I didn't even try to get the CSS to match and the javascript attached, but it might be the easiest way forward.
We could also go all-in and use something like vue.js and use the vue router (or react or angular or whatever) which can handle all of the client side work to keep the state of the nav tree stable while swapping out content, and keeping the URL history correct. Since we're generating a page for each thing I think we can still keep the static hosting reasonably OK, and I am hopeful that Google et al run enough of the javascript so someone could get a link to brickschema.org/ontology/brick/VAV.html if a searcher wanted to find the definitions directly.
I guess I'm maybe fine with jquery and maybe creating a sitemap file so the search engines can find all of the subpages?
@jbkoh @gtfierro