render
render
#
Render — the context a page renders in: where its files go and where its links point.
- Files.
stagecopies a file-valued prop under the page'sfiles/andlibcopies a shipped browser library underlib/; both return the relative href a component writes. - Links. A link is a
PageLinkor anofentry, nothing else. A value loaded from a target has a position — the base it was read from (position);hrefturns aPageLink's value, andentry_hrefanofconstructor's container entry, into the relative link from this page'satto that position's page, orNonewhen either side has no position.
Render
#
One page's render context, handed to every component's html.
at is the position of the value the page is the page of; every link is
relative to it, one ../ up for the ~/ segment the server mounts the
page under, then the on-disk path from at to the linked position.
Source code in capturegraph-lib/capturegraph/ui/render.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
__init__(page, at)
#
A render into page for the page of at (None for a page of nothing).
Source code in capturegraph-lib/capturegraph/ui/render.py
entry_href(container, key)
#
The relative link to the page of container's entry at key, or None.
key is a Map key or an Array index; the entry need not exist.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in capturegraph-lib/capturegraph/ui/render.py
href(value)
#
The relative link to value's page, or None when it or this page has no position.
Source code in capturegraph-lib/capturegraph/ui/render.py
identifier(prefix)
#
A fresh element id cg-<prefix>-<n>, unique within this render.
lib(name)
#
The relative href of the shipped library file name ("leaflet/leaflet.css").
The whole library folder is copied under lib/ the first time one of
its files is asked for.
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If no such library ships with the package. |
Source code in capturegraph-lib/capturegraph/ui/render.py
once(key, html)
#
html the first time key is seen in this render, "" after.
Source code in capturegraph-lib/capturegraph/ui/render.py
stage(file)
#
Copy file (or a directory) under files/ and return its relative href.
Files are numbered in the order they are first staged; the same source staged twice is copied once.
Source code in capturegraph-lib/capturegraph/ui/render.py
position(value)
#
The base value was loaded from in a target, or None when it has none.
A value built in memory, changed since it was loaded, or held by the recipe scratch (the result of a recipe call) has no position.
assert position(cg.load(root, Journal).sessions) == root / "sessions"
assert position(thumbnail(session.photo)) is None