clew
  • Requirements
  • Flows
  • Tests
  • Change impact
  • Map
  • Architecture
  • Docs
  • SBOM

modal.py¶

clew/wiki/modal.py

The wiki's one modal component, from the Python side (round 3, P1b).

modal

str clew.wiki.modal.modal(str key, str label, str title, str body, str cls="")

A trigger and the template it opens.

clew/wiki/modal.py:33

Show on the map →

Called by write_quick_views

Tested by

1 teststest_a_modal_trigger_carries_its_content_inert_and_escaped

Calls modal_template

Source · 9 lines
def modal(key: str, label: str, title: str, body: str, cls: str = "") -> str:
    """@brief Write a trigger + template. @return HTML."""
    classes = f"modal-link {cls}".strip()
    return (
        f'<a class="{classes}" href="#m={key}" data-modal="{key}">{escape(label)}</a>'
        + modal_template(key, title, body)
    )

Activity · 2 steps
lines 35–35classes = f"modal-link {cls}".strip()lines 36–39return ( f'<a class="{classes}" href="#m={key}" data-modal="{key}">{escape(label)}</a>' + modal_template(key, title, body) )

Requirements

REQ-DDB-WIKI-020

Flows

  • Build this wiki from the index

modal_template

str clew.wiki.modal.modal_template(str key, str title, str body)

The template alone, for a trigger drawn elsewhere (an SVG box carrying data-modal ).

clew/wiki/modal.py:49

Show on the map →

Called by modal

Calls none

Source · 10 lines
def modal_template(key: str, title: str, body: str) -> str:
    """REFUSES a key the hash reader would not accept, rather than writing a template whose deep
    link silently opens nothing.

    @brief Write a template.
    @return HTML.
    """
    if not _KEY.match(key):
        raise ValueError(f"modal key {key!r} must match {_KEY.pattern}")
    return f'<template id="modal-{key}" data-title="{escape(title)}">{body}</template>'

1 more lines, not shown

Activity · 3 steps
lines 56–56◇ if not _KEY.match(key)lines 57–57raise ValueError(f"modal key {key!r} must match {_KEY.pattern}")lines 58–58return f'<template id="modal-{key}" data-title="{escape(title)}">{body}</template>'

Requirements

REQ-DDB-WIKI-020

Flows

  • Build this wiki from the index
clew Generated by clew wiki from the repository's index