Skip to main content

Module mashlib

Module mashlib 

Source
Expand description

Mashlib / SolidOS data-browser integration.

When a browser navigates to an RDF resource on a Solid server, the Accept: text/html header signals that the user wants a rendered view, not raw triples. This module generates a thin HTML wrapper that loads the SolidOS mashlib bundle (from a CDN, a local path, or an ES module URL) and lets it fetch + render the underlying data.

The approach is called the “databrowser hack” in the SolidOS community: the server never renders RDF itself — it delegates to the client-side pane system inside mashlib.

§Data-island optimisation

When the resource is small enough (≤ DATA_ISLAND_MAX_BYTES), its JSON-LD representation is embedded inline as a <script type="application/ld+json"> block. A companion reader script patches $rdf.fetcher.load() to resolve from that island first, eliminating one HTTP round-trip on every page load.

§Modes

ModeHTML templateUse case
MashlibMode::Cdn<script src="unpkg.com/mashlib@{version}/…">Zero-config default
MashlibMode::Local<script defer src="/mashlib.min.js">Operator bundles assets with actix-files
MashlibMode::Module<script type="module" src="{url}">LOSOS / custom shell

Structs§

MashlibConfig
Mashlib integration configuration.

Enums§

MashlibMode
How to load the mashlib bundle.

Constants§

DATA_ISLAND_MAX_BYTES
Cap on how much JSON-LD we inline as a data island. 256 KiB covers any realistic profile, type index, or container listing.

Functions§

escape_for_script_block
Escape a JSON-LD string for embedding inside <script type="application/ld+json">.
generate_html
Generate the mashlib HTML wrapper page.
should_serve
Determine whether the server should return the mashlib HTML wrapper instead of the raw resource body.