### Run Example Instance Source: https://github.com/zazuko/trifid/blob/main/packages/entity-renderer/README.md Starts an example instance of the Trifid application with the entity renderer plugin enabled. Access the instance at http://localhost:3000/. ```sh npm run example-instance ``` -------------------------------- ### Plugin Configuration in YAML and JSON Source: https://github.com/zazuko/trifid/wiki/Configuration Illustrates how to configure plugins, specifying the module to load, loading order, paths, and custom configurations. This example shows the setup for a static assets plugin. ```yaml plugins: static-assets: module: trifid-core/plugins/static.js order: 0 paths: /static-assets config: directory: file:static ``` ```json { "plugins": { "static-assets": { "module": "trifid-core/plugins/static.js" "order": 10, "paths": "/static-assets", "config": { "directory": "file:static" } } } } ``` -------------------------------- ### Start Trifid Server Source: https://github.com/zazuko/trifid/blob/main/README.md Starts the Trifid Web server. This is the basic command to run Trifid after installation. ```sh npx trifid ``` -------------------------------- ### Trifid Plugin Factory Example Source: https://github.com/zazuko/trifid/wiki/Configuration An example of how to create a plugin using the Trifid plugin factory. It demonstrates accessing configuration, using the logger, and defining route handlers. ```javascript const factory = async (trifid) => { const { config, logger } = trifid; // access a configuration property: const { particularField } = config; // …do things return { // Register default paths and methods, in case none was provided in the configuration file defaultConfiguration: async () => { return { paths: ["/plugin/path"], methods: ["GET"], }; }, routeHandler: async () => { // …do some things const handler = async (_request, reply) => { logger.debug("reached my custom plugin"); // …do some things return reply.type("text/plain").send("Hello, world!\n"); }; return handler; }, }; }; ``` -------------------------------- ### Global and Scoped Plugin Configuration in YAML and JSON Source: https://github.com/zazuko/trifid/wiki/Configuration Shows how to configure plugins with global settings that can be overridden by scoped configurations. This example demonstrates setting an endpoint URL for a SPARQL proxy plugin. ```yaml globals: endpointUrl: env:SPARQL_ENDPOINT_URL plugins: sparql-proxy: module: "@zazuko/trifid-plugin-sparql-proxy" paths: /query config: endpointUrl: env:ENDPOINT_URL ``` ```json { "globals": { "endpointUrl": "env:SPARQL_ENDPOINT_URL" }, "plugins": { "sparql-proxy": { "module": "@zazuko/trifid-plugin-sparql-proxy", "paths": "/query", "config": { "endpointUrl": "env:ENDPOINT_URL" } } } } ``` -------------------------------- ### Install trifid-handler-fetch using npm Source: https://github.com/zazuko/trifid/blob/main/packages/handler-fetch/README.md This command installs the trifid-handler-fetch package as a dependency for your project. ```sh npm install trifid-handler-fetch ``` -------------------------------- ### Install trifid-plugin-yasgui Source: https://github.com/zazuko/trifid/blob/main/packages/yasgui/README.md Installs the trifid-plugin-yasgui using npm. This is the first step to integrate YASGUI with Trifid. ```sh npm install trifid-plugin-yasgui ``` -------------------------------- ### Example Trifid Layout with Handlebars Source: https://github.com/zazuko/trifid/wiki/Customize-the-templates This is a comprehensive example of a Trifid layout using Handlebars. It includes configurations for title, header, footer, and body, along with dynamic inclusion of stylesheets and scripts. ```hbs {{#if title}}{{title}}{{else}}Trifid{{/if}} {{#each styles}} {{/each}} {{#unless disableHeader}} {{{header}}} {{/unless}}
{{{body}}}
{{#unless disableFooter}} {{{footer}}} {{/unless}} {{#each scripts}} {{/each}} ``` -------------------------------- ### Install trifid-plugin-spex Source: https://github.com/zazuko/trifid/blob/main/packages/spex/README.md Installs the trifid-plugin-spex using npm. This is the first step to integrate SPEX functionality into Trifid. ```sh npm install trifid-plugin-spex ``` -------------------------------- ### Install Trifid npm Package Source: https://github.com/zazuko/trifid/blob/main/README.md Installs the Trifid Node.js package globally using npm. This command requires Node.js and npm to be installed on the system. ```sh npm install -g trifid ``` -------------------------------- ### Install Trifid Markdown Content Plugin Source: https://github.com/zazuko/trifid/blob/main/packages/markdown-content/README.md Installs the Trifid Markdown Content plugin using npm. This is the first step to integrate Markdown file serving capabilities into your Trifid project. ```sh npm install @zazuko/trifid-markdown-content ``` -------------------------------- ### Server Configuration in YAML and JSON Source: https://github.com/zazuko/trifid/wiki/Configuration Details the server configuration, including listener settings (port, host) and logging options (logLevel, logFormat). It shows how to configure trustProxy for security. ```yaml server: listener: port: 8080 host: 0.0.0.0 logLevel: info logFormat: pretty options: trustProxy: true ``` ```json { "server": { "listener": { "port": 8080, "host": "0.0.0.0" }, "logLevel": "info", "logFormat": "pretty", "options": { "trustProxy": true } } } ``` -------------------------------- ### Install Trifid IIIF Plugin Source: https://github.com/zazuko/trifid/blob/main/packages/iiif/README.md Installs the Trifid IIIF plugin using npm. This is the first step to integrate the plugin into your Trifid project. ```sh npm install @zazuko/trifid-plugin-iiif ``` -------------------------------- ### Install trifid-plugin-graph-explorer Source: https://github.com/zazuko/trifid/blob/main/packages/graph-explorer/README.md Installs the trifid-plugin-graph-explorer using npm. This is the initial step to integrate the Graph Explorer functionality into a Trifid project. ```sh npm install trifid-plugin-graph-explorer ``` -------------------------------- ### Install Trifid SPARQL Proxy Plugin Source: https://github.com/zazuko/trifid/blob/main/packages/sparql-proxy/README.md Installs the Trifid SPARQL proxy plugin using npm. This is the first step to integrate the plugin into your Trifid project. ```sh npm install @zazuko/trifid-plugin-sparql-proxy ``` -------------------------------- ### Start Trifid with SPARQL Endpoint Source: https://github.com/zazuko/trifid/blob/main/README.md Starts the Trifid server and configures it to use a specified SPARQL endpoint URL. This allows Trifid to serve data directly from a SPARQL store. ```sh trifid --sparql-endpoint-url=http://localhost:3030/sparql ``` -------------------------------- ### Extend Configurations in YAML and JSON Source: https://github.com/zazuko/trifid/wiki/Configuration Demonstrates how to inherit settings from multiple configuration files using the 'extends' property in both YAML and JSON formats. This allows for modular configuration management. ```yaml extends: - ./config-sparql.yaml - ./config-sparql-addons.yaml ``` ```json { "extends": [ "./config-sparql.json", "./config-sparql-addons.json" ] } ``` -------------------------------- ### Install trifid-plugin-i18n Source: https://github.com/zazuko/trifid/blob/main/packages/i18n/README.md This command installs the trifid-plugin-i18n package using npm. It's the first step to integrate i18n support into your Trifid project. ```sh npm install trifid-plugin-i18n ``` -------------------------------- ### Install Trifid Entity Renderer Plugin Source: https://github.com/zazuko/trifid/blob/main/packages/entity-renderer/README.md Installs the Trifid entity renderer plugin using npm. This is the first step to integrate the plugin into your Trifid project. ```sh npm install @zazuko/trifid-entity-renderer ``` -------------------------------- ### Trifid Template Engine Configuration Source: https://github.com/zazuko/trifid/wiki/Configuration YAML configuration for the Trifid template engine, specifying layout files, partials, default title, and additional scripts/styles. ```yaml template: files: main: path/to/another/default/layout.hbs header: path/to/another/header.hbs footer: path/to/another/footer.hbs partials: partialName1: path/to/a/partial.hbs partialName2: path/to/another/partial.hbs title: "Default Trifid instance title" scripts: - path/to/additional/script1.js - path/to/additional/script2.js styles: - path/to/additional/style1.css - path/to/additional/style2.css disableHeader: false disableFooter: false ``` -------------------------------- ### Advanced Trifid Configuration with Markdown Content Options Source: https://github.com/zazuko/trifid/blob/main/packages/markdown-content/README.md Provides a comprehensive example of configuring the Trifid markdown-content plugin. It demonstrates setting default options like `idPrefix`, `classes`, `autoLink`, and `template`, and defines multiple namespaces with specific configurations, including overriding default settings. ```yaml plugins: # […] your other plugins markdown-content: module: "@zazuko/trifid-markdown-content" order: 80 config: defaults: idPrefix: content- classes: h1: custom-h1 h2: custom-h2 h3: custom-h3 h4: custom-h4 h5: custom-h5 h6: custom-h6 autoLink: true template: file:views/content.hbs entries: root-content: directory: file:content/root mountPath: / about-content: directory: file:content/about mountPath: /about/ autoLink: false # override the default value ``` -------------------------------- ### Trifid Middleware Render Function Example Source: https://github.com/zazuko/trifid/wiki/Customize-the-templates This JavaScript snippet demonstrates how to use the `render` function provided by Trifid within a middleware. It shows how to asynchronously render a view template with a given context and layout options. ```js import { dirname } from "path"; import { fileURLToPath } from "url"; const currentDir = dirname(fileURLToPath(import.meta.url)); const factory = (trifid) => { const { render } = trifid; return { defaultConfiguration: async () => { return { paths: ["/plugin/path"], methods: ["GET"], }; }, routeHandler: async () => { const handler = async (_request, reply) => { return reply.type("text/plain").send( await render( `${currentDir}/../views/your-view.hbs`, { name: "John Doe", }, { title: "My custom page" } ) ); }; return handler; }, }; }; export default factory; ``` -------------------------------- ### Install CKAN Plugin via npm Source: https://github.com/zazuko/trifid/blob/main/packages/ckan/README.md This command installs the '@zazuko/trifid-plugin-ckan' package as a Node dependency for your project, enabling its use within Trifid. ```sh npm install @zazuko/trifid-plugin-ckan ``` -------------------------------- ### Update Global Configuration for Endpoints in Trifid Source: https://github.com/zazuko/trifid/wiki/Migration This example demonstrates the updated global configuration in Trifid v5.x for managing SPARQL endpoints. It replaces the deprecated `sparqlEndpoint` field with a new `endpoints` field, allowing for multiple endpoints, with 'default' being a required entry. ```yaml globals: datasetBaseUrl: https://ld.zazuko.com/ endpoints: default: url: /query ``` -------------------------------- ### Configure SPARQL Proxy Plugin in Trifid Source: https://github.com/zazuko/trifid/wiki/Migration This configuration snippet shows how to set up the `@zazuko/trifid-plugin-sparql-proxy` to expose a SPARQL endpoint at the `/query` path. It includes settings for the endpoint URL, username, and password, which can be sourced from environment variables. ```yaml plugins: sparql-proxy: module: "@zazuko/trifid-plugin-sparql-proxy" config: endpointUrl: env:SPARQL_ENDPOINT_URL username: env:SPARQL_ENDPOINT_USER password: env:SPARQL_ENDPOINT_PASSWORD ``` -------------------------------- ### Run Trifid with Docker Source: https://github.com/zazuko/trifid/blob/main/README.md This command runs the Trifid Docker image, exposing port 8080 for access. It's a straightforward way to deploy Trifid for testing or production environments. ```sh docker run --rm -it -p 8080:8080 ghcr.io/zazuko/trifid ``` -------------------------------- ### Configure Trifid SPARQL Proxy Plugin Source: https://github.com/zazuko/trifid/blob/main/packages/sparql-proxy/README.md Provides a sample YAML configuration for the SPARQL proxy plugin in Trifid. It demonstrates how to set the endpoint URL, authentication credentials, and various rewriting and format options. ```yaml plugins: # […] your other plugins sparql-proxy: module: "@zazuko/trifid-plugin-sparql-proxy" paths: /query config: # The endpoint URL is the only required field endpointUrl: https://example.com/query # In case your endpoint requires authentication: username: admin password: secret # headers: # Optional headers to be sent with each request # X-Custom-Header: "CustomValue" # # In case you want to add support for multiple endpoints # # Define the endpoints in the following way (the "default" endpoint is required) # # The default endpoint value will override the endpointUrl, username, password and headers values # endpoints: # default: # endpointUrl: https://example.com/query # username: admin1 # password: secret1 # headers: # X-Custom-Header: "CustomValueDefault" # other: # endpointUrl: https://example.com/other-query # username: admin2 # password: secret2 # headers: # X-Custom-Header: "CustomValueOther" # Rewriting configuration allowRewriteToggle: true # Allow the user to toggle the rewrite configuration using the `rewrite` query parameter, even if `rewrite` is set to false rewrite: false # Rewrite by default rewriteQuery: true # Allow rewriting the query (in case of rewriting) rewriteResults: true # Allow rewriting the results (in case of rewriting) # Configure formats, that can be used as `format` query parameter formats: ttl: "text/turtle" jsonld: "application/ld+json" xml: "application/rdf+xml" nt: "application/n-triples" trig: "application/trig" csv: "text/csv" # Configure the log level for the queries queryLogLevel: debug # Log level for the queries ``` -------------------------------- ### Basic Trifid Configuration for Markdown Content Source: https://github.com/zazuko/trifid/blob/main/packages/markdown-content/README.md Configures the Trifid application to use the markdown-content plugin. It specifies the module to load and sets up a default namespace for serving custom Markdown content from a specified directory. ```yaml plugins: # […] your other plugins markdown-content: module: "@zazuko/trifid-markdown-content" order: 80 config: defaults: autoLink: true entries: custom-content: directory: file:content/custom mountPath: /content/ ``` -------------------------------- ### Configure trifid-handler-fetch in Trifid Source: https://github.com/zazuko/trifid/blob/main/packages/handler-fetch/README.md This YAML configuration snippet shows how to integrate the trifid-handler-fetch plugin into your Trifid server. It specifies the module, the exposed path, and configuration options for the dataset URL, content type, base IRI, and graph name. ```yaml plugins: # … handler-fetch: module: "trifid-handler-fetch" paths: /query config: url: https://raw.githubusercontent.com/zazuko/tbbt-ld/master/dist/tbbt.nt contentType: application/n-triples baseIRI: http://example.com graphName: http://example.com/graph ``` -------------------------------- ### Advanced Configuration Options for Graph Explorer Source: https://github.com/zazuko/trifid/blob/main/packages/graph-explorer/README.md Provides advanced configuration options for the Graph Explorer plugin in Trifid. This includes settings for accepting blank nodes, defining schema label properties, and specifying language configurations. ```yaml config: acceptBlankNodes: false dataLabelProperty: rdfs:label | schemaLabelProperty: rdfs:label | language: en languages: - code: en label: English - code: de label: German - code: fr label: French - code: it label: Italian ``` -------------------------------- ### Configure trifid-plugin-yasgui in config.yaml Source: https://github.com/zazuko/trifid/blob/main/packages/yasgui/README.md Configures the YASGUI plugin within the Trifid `config.yaml` file. This includes setting the SPARQL endpoint URL, an optional URL shortener, and a default SPARQL query. ```yaml plugins: # […] your other plugins yasgui: module: trifid-plugin-yasgui paths: # by default - /sparql - /sparql/ config: endpointUrl: https://example.com/query urlShortener: https://example.com/api/v1/shorten defaultQuery: | PREFIX rdf: PREFIX rdfs: SELECT * WHERE { ?sub ?pred ?obj . } LIMIT 10 # …other configuration fields ``` -------------------------------- ### Configure Trifid Markdown Content Plugin Source: https://github.com/zazuko/trifid/blob/main/packages/markdown-content/README.md This YAML configuration snippet shows how to enable and configure the markdown-content plugin in Trifid. It specifies the module to use and the directory where Markdown content is stored, mapping it to the root path of the Trifid instance. ```yaml plugins: # […] your other plugins markdown-content: module: "@zazuko/trifid-markdown-content" order: 80 config: entries: root-content: directory: file:content mountPath: / ``` -------------------------------- ### Update Trifid Plugin Factory (JavaScript) Source: https://github.com/zazuko/trifid/wiki/Migration Compares the old and new factory function signatures for Trifid plugins. The new version is asynchronous, accepts an async defaultConfiguration, and returns an async routeHandler, supporting Fastify route handlers instead of Express middleware. ```javascript const factory = (trifid) => { const { config, logger } = trifid; // access a configuration property: const { particularField } = config; // …do things return (req, res, next) => { // …so some things // use the logger for example logger.debug("the middleware was called!"); }; }; ``` ```javascript const factory = async (trifid) => { const { config, logger } = trifid; // access a configuration property: const { particularField } = config; // …do things return { // Register default paths and methods, in case none was provided in the configuration file defaultConfiguration: async () => { return { paths: ["/plugin/path"], methods: ["GET"], }; }, routeHandler: async () => { // …do some things const handler = async (_request, reply) => { logger.debug("reached my custom plugin"); // …do some things return reply.type("text/plain").send("Hello, world!\n"); }; return handler; }, }; }; ``` -------------------------------- ### Configure Fetch Handler for File/URL Data in Trifid Source: https://github.com/zazuko/trifid/wiki/Migration This configuration shows how to use the rewritten `trifid-handler-fetch` plugin to expose data from a file or URL as a SPARQL endpoint. It includes settings for the data source URL, content type, base IRI, and graph name. ```yaml plugins: # … handler-fetch: module: "trifid-handler-fetch" paths: /query config: url: https://raw.githubusercontent.com/zazuko/tbbt-ld/master/dist/tbbt.nt contentType: application/n-triples baseIRI: http://example.com graphName: http://example.com/graph ``` -------------------------------- ### Configure trifid-plugin-spex in config.yaml Source: https://github.com/zazuko/trifid/blob/main/packages/spex/README.md Configures the trifid-plugin-spex in the `config.yaml` file. This includes setting the module path, default paths, and optional configuration parameters like prefixes for SPARQL endpoints. ```yaml plugins: # […] your other plugins spex: module: trifid-plugin-spex paths: # by default - /spex - /spex/ config: prefixes: - prefix: ex namespace: http://example.org/ ``` -------------------------------- ### Configure Entity Renderer Plugin in config.yaml Source: https://github.com/zazuko/trifid/blob/main/packages/entity-renderer/README.md Configures the entity-renderer plugin in the Trifid `config.yaml` file. This includes specifying the module and optionally ignoring certain paths like '/query'. ```yaml plugins: # … entity-renderer: module: "@zazuko/trifid-entity-renderer" config: # ignore some specific paths ignorePaths: - /query ``` -------------------------------- ### Handlebars Body Rendering Source: https://github.com/zazuko/trifid/wiki/Customize-the-templates This snippet demonstrates how to render the main content of a view within the `` tag using Handlebars. The `{{{body}}}` helper inserts the rendered view content. ```hbs {{{body}}} ``` -------------------------------- ### Configure Trifid IIIF Plugin Source: https://github.com/zazuko/trifid/blob/main/packages/iiif/README.md Configures the IIIF plugin within the Trifid configuration file. It specifies the plugin module, the paths it should handle, and connection details for a SPARQL endpoint. ```yaml plugins: # […] your other plugins iiif: module: "@zazuko/trifid-plugin-iiif" paths: - /iiif/ config: uriPrefix: https://website endpointUrl: https://website/query endpointUser: optional endpointPassword: optional ``` -------------------------------- ### Configure Redirect Following Source: https://github.com/zazuko/trifid/blob/main/packages/entity-renderer/README.md Enables the plugin to follow redirects for resources by setting `followRedirects` to `true`. It also allows specifying a custom `redirectQuery` to fetch redirect targets. ```yaml plugins: # … entity-renderer: module: "@zazuko/trifid-entity-renderer" config: followRedirects: true redirectQuery: "…" # Select query used to get the redirect target ; needs to return a row with `?responseCode` and `?location` bindings. ``` -------------------------------- ### Configure Trifid CKAN Plugin Source: https://github.com/zazuko/trifid/blob/main/packages/ckan/README.md This YAML configuration demonstrates how to integrate the '@zazuko/trifid-plugin-ckan' into a Trifid project. It specifies the plugin module, the path for the service, and configuration options for connecting to a SPARQL endpoint, including optional user and password credentials. ```yaml plugins: # …other plugins ckan: module: "@zazuko/trifid-plugin-ckan" paths: /ckan config: endpointUrl: https://some-custom-endpoint/ # user: # password: # super-secret ``` -------------------------------- ### Migrate Trifid Entity Renderer Module Name (Diff) Source: https://github.com/zazuko/trifid/wiki/Migration Shows the configuration change required when migrating from older versions of Trifid, specifically updating the module path for the entity renderer plugin from '@zazuko/trifid-renderer-entity' to '@zazuko/trifid-entity-renderer'. ```diff middlewares: # … entity-renderer: - module: "@zazuko/trifid-renderer-entity" + module: "@zazuko/trifid-entity-renderer" ``` -------------------------------- ### Configure trifid-plugin-graph-explorer in config.yaml Source: https://github.com/zazuko/trifid/blob/main/packages/graph-explorer/README.md Configures the trifid-plugin-graph-explorer within the Trifid `config.yaml` file. This includes specifying the module, paths, and the SPARQL endpoint URL for the Graph Explorer. ```yaml plugins: # […] your other plugins yasgui: module: trifid-plugin-graph-explorer paths: # by default - /graph-explorer - /graph-explorer/ config: endpointUrl: https://example.com/query # …other configuration fields ``` -------------------------------- ### Configure trifid-plugin-i18n in Trifid Source: https://github.com/zazuko/trifid/blob/main/packages/i18n/README.md This YAML configuration snippet shows how to add the trifid-plugin-i18n to your Trifid application's configuration. It specifies the plugin module, its execution order, and configuration options for the i18n package, such as the directory for locale files and the list of supported locales. ```yaml plugins: # […] your other plugins i18n: module: "trifid-plugin-i18n" order: 5 config: directory: file:locales locales: - en - de # …other configuration fields ``` -------------------------------- ### Configure Rendering Options Source: https://github.com/zazuko/trifid/blob/main/packages/entity-renderer/README.md Sets various rendering options for the entity-renderer plugin, such as `compactMode`, `technicalCues`, and `embedNamedNodes`. These options control how entities are displayed. ```yaml plugins: # … entity-renderer: module: "@zazuko/trifid-entity-renderer" config: compactMode: false technicalCues: true embedNamedNodes: false ``` -------------------------------- ### Specify Custom Template Path Source: https://github.com/zazuko/trifid/blob/main/packages/entity-renderer/README.md Defines a custom path for the Handlebars template used by the entity-renderer plugin. This allows for custom entity rendering. ```yaml plugins: # … entity-renderer: module: "@zazuko/trifid-entity-renderer" config: path: file:./some-path/your-template.hbs ``` -------------------------------- ### Handlebars Title Tag Configuration Source: https://github.com/zazuko/trifid/wiki/Customize-the-templates This snippet shows how to configure the page title within the `` tag using Handlebars. It includes a basic usage and a conditional fallback to 'Trifid' if the title is not provided. ```hbs {{title}} ``` ```hbs {{#if title}}{{title}}{{else}}Trifid{{/if}} ```