Documentation
¶
Index ¶
- type ExtractedElement
- func ExtractAsyncElements(content string) ([]ExtractedElement, error)
- func ExtractColumnContainers(content string) ([]ExtractedElement, error)
- func ExtractColumnElements(content string) ([]ExtractedElement, error)
- func ExtractFacetElements(content string) ([]ExtractedElement, error)
- func ExtractSyncElements(content string) ([]ExtractedElement, error)
- type NamedGraph
- type PagePrefix
- type Preprocessor
- func (p *Preprocessor) ExecuteQuery(query string, resolveLabels bool, acceptLanguage string, endpoint string, ...) (sparql.QueryResult, error)
- func (p *Preprocessor) ExecuteQueryWithContext(ctx context.Context, query string, resolveLabels bool, acceptLanguage string, ...) (sparql.QueryResult, error)
- func (p *Preprocessor) FinalizeQuery(query string, acceptLanguage string, endpointURL string) string
- func (p *Preprocessor) ProcessTemplateFile(filepath string, iri string, acceptLanguage string) (TemplateData, error)
- func (p *Preprocessor) QueryRole(iri sparql.IRI, knownClass bool) (sparql.Role, error)
- func (p *Preprocessor) QueryTypes(iri sparql.IRI) ([]string, error)
- func (p *Preprocessor) ResolveBest(kind, iri, acceptLanguage string) string
- func (p *Preprocessor) SparqlPreprocessor() *sparql.Preprocessor
- type TemplateData
- type TreeQueries
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExtractedElement ¶
type ExtractedElement struct {
TagName string // "sparql-query", "sparql-table", etc.
ID string // Required id attribute
Content string // Text content between tags
Attributes map[string]string // All HTML attributes
}
ExtractedElement represents any SPARQL custom element found in a template
func ExtractAsyncElements ¶
func ExtractAsyncElements(content string) ([]ExtractedElement, error)
ExtractAsyncElements extracts SPARQL queries and returns all <sparql-async> elements. These are client-side async queries
func ExtractColumnContainers ¶
func ExtractColumnContainers(content string) ([]ExtractedElement, error)
ExtractColumnContainers returns all <sparql-columns> elements. Only the indexer uses them, to reject a container that carries column attributes — the one-letter difference between the container and its children makes that typo easy and its symptom (a column that silently never appears) hard to read.
func ExtractColumnElements ¶
func ExtractColumnElements(content string) ([]ExtractedElement, error)
ExtractColumnElements returns all <sparql-column> declarations in a template, in document order, with the base query id resolved.
A column names the query it decorates with for=. Inside a <sparql-columns for="…"> container it inherits that id instead, so a table writes it once and its columns stay one line each. An explicit for= on the column still wins, which keeps a lone declaration (no container) working.
This walks the DOM itself rather than going through extractElements: inheritance needs the parent chain, which a flat tag-name scan has already discarded.
func ExtractFacetElements ¶
func ExtractFacetElements(content string) ([]ExtractedElement, error)
ExtractFacetElements returns all <sparql-facet> elements in a template.
The element was replaced by <sparql-column>, which describes the whole column rather than only its filter. This extractor survives for one purpose: letting startup FAIL on a leftover declaration. Nothing reads sparql-facet any more, so without this check a missed rename would silently drop a table's filters instead of announcing itself.
func ExtractSyncElements ¶
func ExtractSyncElements(content string) ([]ExtractedElement, error)
ExtractSyncElements returns all <sparql-query> elements in a template — the queries executed server-side during the page render, as opposed to the <sparql-async> ones fetched afterwards.
The async index uses this to know which ids exist, so a <sparql-column> may decorate a synchronously-rendered table too. Only the ids are of interest there: the query text is executed by the page pipeline, not by a fragment handler.
type NamedGraph ¶
type NamedGraph struct {
IRI string // full graph IRI (used by the copy button)
Short string // prefixed form for display, falls back to full IRI
}
NamedGraph is a named graph containing the resource (as subject)
type PagePrefix ¶
type PagePrefix struct {
Name string `json:"name"`
IRI string `json:"iri"` // without angle brackets
}
PagePrefix is one prefix declaration as the browser receives it (the vs-prefixes island in base.html, read by static/js/prefixes.js).
func NewPagePrefixes ¶
func NewPagePrefixes(prefixes []config.Prefix) []PagePrefix
NewPagePrefixes converts config prefixes for the browser.
type Preprocessor ¶
type Preprocessor struct {
// contains filtered or unexported fields
}
Preprocessor handles template parsing and SPARQL query execution for templates
func New ¶
func New(config sparql.QueryInput) *Preprocessor
New creates a new Preprocessor with the given configuration
func (*Preprocessor) ExecuteQuery ¶
func (p *Preprocessor) ExecuteQuery(query string, resolveLabels bool, acceptLanguage string, endpoint string, opts ...sparql.Option) (sparql.QueryResult, error)
ExecuteQuery executes a raw SPARQL query and returns simplified results. Pass sparql.WithTypes() to additionally resolve resource icons.
func (*Preprocessor) ExecuteQueryWithContext ¶
func (p *Preprocessor) ExecuteQueryWithContext(ctx context.Context, query string, resolveLabels bool, acceptLanguage string, endpoint string, opts ...sparql.Option) (sparql.QueryResult, error)
ExecuteQueryWithContext executes a raw SPARQL query bound to the given context, allowing the caller to enforce a per-request timeout.
func (*Preprocessor) FinalizeQuery ¶
func (p *Preprocessor) FinalizeQuery(query string, acceptLanguage string, endpointURL string) string
FinalizeQuery returns the query as it would be sent to the endpoint (PREFIXes prepended, visoto:dispLang resolved) without executing it.
func (*Preprocessor) ProcessTemplateFile ¶
func (p *Preprocessor) ProcessTemplateFile(filepath string, iri string, acceptLanguage string) (TemplateData, error)
ProcessTemplateFile reads a template file, extracts and executes SPARQL queries, and returns the template data with query results
func (*Preprocessor) QueryRole ¶
QueryRole reports whether the given IRI is used as a class, a property or a named graph
func (*Preprocessor) QueryTypes ¶
func (p *Preprocessor) QueryTypes(iri sparql.IRI) ([]string, error)
QueryTypes queries the SPARQL endpoint for the rdf:type of a given IRI
func (*Preprocessor) ResolveBest ¶
func (p *Preprocessor) ResolveBest(kind, iri, acceptLanguage string) string
ResolveBest returns the single best value of a magic property ("label", "description") for iri; see sparql.Preprocessor.ResolveBest.
func (*Preprocessor) SparqlPreprocessor ¶
func (p *Preprocessor) SparqlPreprocessor() *sparql.Preprocessor
SparqlPreprocessor returns the underlying sparql.Preprocessor for callers that need direct access to query execution (e.g. search package).
type TemplateData ¶
type TemplateData struct {
ResourceIRI string // The IRI of the resource being rendered
Title string // The resource's single best label (language first, then property priority; IRI last segment as fallback). Feeds the page title.
Subtitle string // The resource's single best description, "" if none. Feeds the page subtitle.
ShortIRI string // Prefixed IRI (e.g. schema:Person), empty if no prefix match
NamedGraphs []NamedGraph // Named graphs containing the resource as subject
TemplateName string // Name of the template used to render this page (for debugging)
TemplateType string // IRI of the class this page is rendered as; "" when the template matched on the resource's own IRI or nothing matched. The breadcrumb's default segment.
QueryResults map[string]sparql.QueryResult // Results indexed by query ID defined in template
SparqlEndpoints []config.SparqlEndpoint // SPARQL endpoints for menu (no sensitive data)
SelectedEndpointName string // Name of the active endpoint, so the topbar can server-render <option selected> (don't rely on JS/cookie timing)
SelectedEndpointSlug string // Slug of the active endpoint — the only identifier used on the wire (?endpoint=, cookie)
EndpointTag string // Tag of the currently selected endpoint (e.g. "lindas", "stadtzuerich")
SearchProvider string // search_provider of the currently selected endpoint (e.g. "graphdb-lucene", "qlever") — doubles as the engine hint for engine-specific queries
GraphQueryURL string // Same-origin proxy path for browser-side SPARQL (Graph Explorer, schema diagram). NOT the endpoint URL: the upstream host and its credentials deliberately never reach the browser. See internal/sparqlproxy.
LabelPath string // The "label" magic property path (Graph Explorer's label property)
EndpointPrefixes []PagePrefix // Prefixes in effect for the active endpoint (global merged with its overrides); the only namespace source for browser JS
BaseURL string // Public base URL of this instance derived from the request (e.g. https://visoto.example.org)
}
TemplateData wraps all data retrieved for a resource
type TreeQueries ¶
type TreeQueries struct {
ID string // the for= value; the id a request names
Roles map[string]string // role name → query text, verbatim
}
TreeQueries is one <sparql-tree-queries> block: the tree id it configures and the query text of each role declared inside it.
func ExtractTreeQueries ¶
func ExtractTreeQueries(content string) ([]TreeQueries, error)
ExtractTreeQueries returns every <sparql-tree-queries> block in a template.
Structural mistakes are errors rather than silent omissions: the symptom of a dropped role is a tree that simply never expands, which reads as a data problem rather than a markup one. Prose that merely names the elements — documentation, or a {{/* … */}} comment, which is not an HTML comment and so is not skipped — declares no for= and is left alone; see parseTreeQueriesNode for why that is the signal used.