Skip to content

Site

nodekit.build_site

build_site(
    graph: Graph,
    savedir: PathLike | str,
    slug: str | None = None,
) -> BuildSiteResult

Build a static website for a Graph and save it to disk.

Parameters:

  • graph (Graph) –

    Graph to serialize and render into a site.

  • savedir (PathLike | str) –

    Directory to write the site into.

  • slug (str | None, default: None ) –

    Optional human-readable URL slug for the entrypoint HTML file.

Returns:

  • BuildSiteResult

    BuildSiteResult with the site root, entrypoint, and dependency list.

Raises:

  • ValueError

    If savedir is not a directory.

  • ValueError

    If slug is invalid or collides with a different built Graph.

Site layout
assets/
    {mime-type-1}/{mime-type-2}/{sha256}.{ext}
runtime/
    nodekit.{js-digest}.js
    nodekit.{css-digest}.css
graphs/
    {graph_digest}.html (if slug is None)
    {slug}.html (if slug is provided)

nodekit.prepare_site_url

prepare_site_url(
    site_url: str,
    platform: Platform = "none",
    nodekit_submit_to: str | None = None,
    prolific_completion_code: str | None = None,
) -> str

Prepare a Site URL for NodeKit submission behavior.

Parameters:

  • site_url (str) –

    The participant-facing Site URL to prepare.

  • platform (Platform, default: 'none' ) –

    The recruitment platform that will open the Site URL. Use "none" for ordinary web links, "prolific" for Prolific Studies, and "mturk" for Mechanical Turk ExternalQuestion HITs.

  • nodekit_submit_to (str | None, default: None ) –

    An optional side-channel URL where NodeKit should POST the completed SiteSubmission. If omitted, an existing nodekitSubmitTo query parameter on site_url is preserved.

  • prolific_completion_code (str | None, default: None ) –

    The Prolific completion code to include when platform is "prolific".

Returns:

  • str

    The prepared Site URL.

Raises:

  • ValueError

    If platform is unsupported, if Prolific is selected without a completion code or submission URL, or if a Prolific completion code is supplied for another platform.

nodekit.SiteSubmission pydantic-model

Fields:

platform property

platform: Platform

Return the recruiter platform for this submission.

platform_context pydantic-field

platform_context: PlatformContext

Information about the platform (if any) that the Graph site was hosted on.

trace cached property

trace: Trace

Decompresses and decodes the gzipped base64 Trace.

Returns:

  • Trace

    Decompressed Trace object.

trace_gzipped_base64 pydantic-field

trace_gzipped_base64: str

The submitted Trace as base64-encoded gzipped JSON bytes.