Skip to content

feat(tools): add SIB SPARQL editor page alongside YASGUI - #197

Open
ashleycaselli wants to merge 1 commit into
mainfrom
feat/sib-sparql-editor
Open

feat(tools): add SIB SPARQL editor page alongside YASGUI#197
ashleycaselli wants to merge 1 commit into
mainfrom
feat/sib-sparql-editor

Conversation

@ashleycaselli

Copy link
Copy Markdown
Member

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.htmlSIB's sparql-editor web component wired to that repository's endpoint. /page/<repo> now links both editors:

Endpoint: /repo/full
YASGUI: /tools/full/yasgui.html
SPARQL editor: /tools/full/sparql-editor.html

sparql-editor is itself built on YASGUI, but adds VoID-driven autocomplete for classes and properties, endpoint-provided example queries (SHACL sh: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.15 and 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:

  • Endpoint resolution. Done client-side against window.location: the instance sits behind nginx and has no reliable view of its external scheme and host. The repo path travels as a data- 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 through location / to the Vert.x server.)
  • Stylesheet bleed. /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.

Known gap

Unlike the YASGUI page, the editor does not open with Utils.defaultQuery prefilled. Yasgui sets consumeShareLink: null on 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.hml typo in the link text on the line above.

🤖 Generated with Claude Code

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>
@tkuhn

tkuhn commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Very nice!

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