Repository navigation
feat(yasr): pick the result view with a #defaultView query comment - #233
Merged
Merged
Conversation
A '#defaultView:<plugin>' comment line in the query selects the plugin the results open in, like the Wikidata Query Service. Plugin names and labels match case-insensitively, and Wikidata view names (Map, BarChart, ...) map onto the Geo and Chart plugins. Added prefixes now go below the comment lines a query starts with, both for autocompleted prefixes and for the Prefixes button, so the comment stays on the first line. Closes #134
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.
Requested by Mathias · project thread
Before: the result view was chosen by plugin priority or by hand, so a CONSTRUCT always opened in Graph and a query could not ask for the map. Added prefixes were inserted on line 1, above any comment the query started with.
After: a
#defaultView:<name>comment line in the query picks the view its results open in, like the Wikidata Query Service.#defaultView:Geo,#defaultView:chartetc. match plugin names or labels case-insensitively, and the Wikidata names work too (Map→ Geo,LineChart/BarChart/ScatterChart/AreaChart/BubbleChart→ Chart). If the plugin can't render the results, yasr falls back as usual. Autocompleted prefixes and the Prefixes button now add prefixes below the leading comment lines.How: new
packages/yasr/src/defaultView.tsparses the comment and resolves it to a registered plugin;Yasr.selectPluginFromQuery()selects it without drawing, andTab.handleQueryResponsecalls it right beforesetResponse.addPrefixAsString(yasqe) andinsertPrefixes(yasgui) skip leading#lines. Documented under Plugin Selection and Prefix Management in the user guide.Tests: new unit tests for the parser/resolver, a browser test for
selectPluginFromQuery, and the autoadd-prefix browser test now checks the prefix lands below the leading comment. Full browser suite (48) and unit suite (1707) pass locally.Closes #134
Generated by Claude Code