feat(tools): add SIB SPARQL editor page alongside YASGUI - #197
Open
ashleycaselli wants to merge 1 commit into
Open
feat(tools): add SIB SPARQL editor page alongside YASGUI#197ashleycaselli wants to merge 1 commit into
ashleycaselli wants to merge 1 commit into
Conversation
SIB's sparql-editor (https://github.com/sib-swiss/sparql-editor) is itself built on YASGUI, but adds VoID-driven autocomplete for classes and properties, endpoint-provided example queries, and a class overview. Which of the two is more useful depends on what a repository actually carries, so this adds it as a second option rather than swapping out the existing editor: /page/<repo> now links both /tools/<repo>/yasgui.html and /tools/<repo>/sparql-editor.html. The new page follows SpacesListingRoute: rendering is static and side-effect-free in its own class, so the URL shape and the escaping are unit tested without a running server. The route accepts the same one- or two-segment repo names as the YASGUI route, since /repo/<repo> does too. The web component is pinned to @sib-swiss/sparql-editor@0.2.15 and loaded from jsDelivr, the CDN the YASGUI page already uses. Its published bundle is a self-contained ES module with no bare imports, so no import map or shim is needed — but it is ~5 MB, which is why this stays an opt-in page rather than anything loaded from the repo listing. Two details the page has to get right: - The endpoint is resolved client-side against window.location. This instance sits behind nginx and has no reliable view of its external scheme and host. It travels as a data attribute rather than being interpolated into the inline script, so a repo name can never reach script context. - /style.css is sized for plain listing pages; its 10pt body size and `td { white-space: nowrap }` would otherwise leak into the editor's widgets and result tables, so both are reset within the component. Unlike the YASGUI page, the editor does not open with Utils.defaultQuery prefilled. Yasgui disables Yasqe's #query= share-link consumption for its tabs, and the component exposes no attribute for an initial query, so seeding it would mean reaching into the component's internals. Also fixes the "yasgui.hml" typo in the link text on the line above. Refs #51 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
|
Very nice! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Addresses #51, with one deliberate deviation from the issue title: SIB's editor is added next to the plain YASGUI page, not instead of it.
What this adds
GET /tools/<repo>/sparql-editor.html— SIB'ssparql-editorweb component wired to that repository's endpoint./page/<repo>now links both editors:sparql-editoris itself built on YASGUI, but adds VoID-driven autocomplete for classes and properties, endpoint-provided example queries (SHACLsh:SPARQLExecutable), and a class overview. Which one is more useful depends on what a repository actually carries, so the choice is left to the user rather than made for them.Implementation notes
Follows
SpacesListingRoute: rendering lives in its own class, static and side-effect-free, so the URL shape and escaping are unit-tested without a running server. The route accepts the same one- or two-segment repo names as the YASGUI route (type/<hash>,pubkey/<hash>), since/repo/<repo>does too.The component is pinned to
@sib-swiss/sparql-editor@0.2.15and loaded from jsDelivr, the CDN the YASGUI page already uses. Its published bundle is a self-contained ES module — no bare imports, so no import map or shim — but it is ~5 MB, which is why this stays an opt-in page and isn't pulled into the repo listing.Two details the page has to get right:
window.location: the instance sits behind nginx and has no reliable view of its external scheme and host. The repo path travels as adata-attribute rather than being interpolated into the inline script, so a repo name can never reach script context. (No nginx change needed —/tools/*already falls throughlocation /to the Vert.x server.)/style.cssis sized for plain listing pages; its 10pt body size andtd { white-space: nowrap }would otherwise leak into the editor's widgets and result tables, so both are reset within the component.Known gap
Unlike the YASGUI page, the editor does not open with
Utils.defaultQueryprefilled. Yasgui setsconsumeShareLink: nullon the Yasqe instances it owns, so the#query=share-link mechanism is inert inside it, and the component exposes no attribute for an initial query. Seeding it would mean reaching into the component's internals (el.yasgui.getTab().getYasqe().setValue(...)) and guessing at Yasgui's own default value to avoid stomping a user's persisted tab. Left out as too fragile against a pinned third-party bundle — happy to add it if the empty start is a problem in practice.Verification
488 tests pass, 7 of them new. I was not able to load the page in a real browser from here, so please eyeball it once before merging — this is a third-party web component and the failure mode (bundle loads but the element never upgrades, or the editor renders but can't reach the endpoint) is not something the unit tests can see.
Also fixes the
yasgui.hmltypo in the link text on the line above.🤖 Generated with Claude Code