TriplyDB / Yasgui

Yet Another Sparql GUI
https://yasgui.triply.cc
MIT License
190 stars 55 forks source link

change default namespace substitution for yasgui #183

Closed wmelder closed 3 years ago

wmelder commented 3 years ago

Our data contains a lot of Classes and properties from https://schema.org. When we edit the default query with 'schema:' then yasqe adds PREFIX schema: <http://schema.org/>. I want this behaviour to change, so that PREFIX schema: <http**s**://schema.org/> is inserted. How can I set this prefix when I use the standard code for creating yasgui?

    const yasgui = new Yasgui(document.getElementById("yasgui"), {
  requestConfig: { endpoint: "my-custom-endpoint" },
  copyEndpointOnNewTab: true,
});

Note: the autocompletion of classes and properties is a nice feature and we don't want to ruin that.

wmelder commented 3 years ago

Note: I tried this, but that doesn't achieve what I need, it seems.


    const yasgui = new Yasgui(document.getElementById("yasgui"), {
  requestConfig: { endpoint: "http://my_endpoint/sparql",
   },
   yasqe: { defaults: `"PREFIX schema: <https://schema.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT * WHERE {
  ?sub ?pred ?obj .

} LIMIT 10"`},
  copyEndpointOnNewTab: true,
});```
GerwinBosch commented 3 years ago

In regards to picking a prefix, we currently use prefix.cc to get autocompletion suggestions for prefixes, Currently the http version of schema has the highest amount of votes (https://prefix.cc/schema) As a workaround you can use the sdo prefix (https://prefix.cc/sdo) which does refer to the https version of schema

As for your changes, your config seems to miss a "layer". With this snippet, each new query should open with the desired query

const yasgui = new Yasgui(document.getElementById("yasgui"), {
  requestConfig: { endpoint: "http://my_endpoint/sparql",
   },
   yasqe: { defaults: { value: `"PREFIX schema: <https://schema.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT * WHERE {
  ?sub ?pred ?obj .

} LIMIT 10"`}},
  copyEndpointOnNewTab: true,
});

Let me know if this has resolved your issues

wmelder commented 3 years ago

Ah thanks! Great to know it uses prefix.cc. I changed the prefix on the server and now using sdo: in yasgui triggers indeed the https version. Only autocompletion doesn't seem to be available for sdo: ?

GerwinBosch commented 3 years ago

Hmm, I unfortunately need to disappoint you here, for the autocompletion we use the LOV API, and it seems they only have the http version of schema in there

wmelder commented 3 years ago

Thanks. I guess we need to do without completion then. Thanks for explaining a bit about yasgui.

By the way, the example snippet for the defaults configuration didn't result in another default for new tabs. I might have to get back to that later. For now it's OK.