rendering
PageType
¶
RenderFormat
¶
RenderRequest
dataclass
¶
Parameters for a single render operation.
Attributes:
| Name | Type | Description |
|---|---|---|
entity_iri |
str
|
IRI of the entity or topic to render. |
page_type |
PageType
|
Kind of page to produce. |
fmt |
RenderFormat
|
Output format. |
named_graph |
str
|
Source named graph for fact retrieval. |
output_path |
str | None
|
Where to write the rendered file (None = return as string). |
Source code in src/riverbank/rendering/__init__.py
RenderedPage
dataclass
¶
A rendered page artifact.
Attributes:
| Name | Type | Description |
|---|---|---|
page_iri |
str
|
IRI of the |
entity_iri |
str
|
IRI of the entity or topic this page describes. |
fmt |
RenderFormat
|
Output format. |
content |
str
|
Rendered content string. |
source_facts |
list[str]
|
IRIs of the facts this page depends on. |
stale |
bool
|
Whether the page needs regeneration. |
Source code in src/riverbank/rendering/__init__.py
mark_pages_stale(conn, fact_iri)
¶
Mark all rendered pages that depend on fact_iri as stale.
Updates pgc:pageStale to "true" for all pages that list
fact_iri as a pgc:sourceFact.
Returns the number of pages marked stale (0 when pg_ripple is unavailable).
Source code in src/riverbank/rendering/__init__.py
persist_rendered_page(conn, page)
¶
Persist a pgc:RenderedPage artifact with dependency edges.
Writes four triples per page:
1. <page_iri> rdf:type pgc:RenderedPage
2. <page_iri> pgc:pageFormat "<fmt>"
3. <page_iri> pgc:pageContent "<content>"
4. <page_iri> pgc:pageStale "false"
Plus one pgc:sourceFact triple per source fact.
Falls back gracefully when pg_ripple is unavailable.
Source code in src/riverbank/rendering/__init__.py
render_entity_html(entity_iri, facts)
¶
Render an entity page as minimal HTML.
Source code in src/riverbank/rendering/__init__.py
render_entity_jsonld(entity_iri, facts)
¶
Render an entity page as JSON-LD.
Source code in src/riverbank/rendering/__init__.py
render_entity_markdown(entity_iri, facts)
¶
Render an entity page in Markdown format.
Produces a simple MkDocs/Obsidian-compatible Markdown document with:
- H1 title from dct:title or the entity IRI.
- A properties table listing all (predicate, object) pairs.
- Citation back-links as footnotes.
Source code in src/riverbank/rendering/__init__.py
render_page(conn, request)
¶
Render a single entity page.
Fetches facts from the compiled graph and renders them in the requested
format. Writes the result to output_path if specified.
Returns a :class:RenderedPage instance.
Source code in src/riverbank/rendering/__init__.py
sse_event(event_type, data)
¶
streaming_render_generator(conn, entity_iris, named_graph='http://riverbank.example/graph/trusted', fmt=RenderFormat.MARKDOWN, poll_interval_seconds=5.0, max_iterations=0)
¶
Generate SSE events for live page updates.
Polls the graph for stale ``pgc:RenderedPage`` artifacts and re-renders
them, emitting one SSE event per updated page.
This is a generator that yields SSE-formatted strings. Mount it behind
a web framework (FastAPI, Starlette, Flask-SSE, etc.) to serve a
``text/event-stream`` endpoint.
Args:
conn: Database connection.
entity_iris: IRIs to monitor and render.
named_graph: Source named graph.
fmt: Render format for emitted pages.
poll_interval_seconds: Seconds between poll cycles.
max_iterations: Stop after this many cycles (0 = infinite).
Useful for testing.
Yields:
SSE-formatted strings (``event: ...
data: ...
``).