MaCH repo
9
00_hello_text/main.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <mach.h>
|
||||
|
||||
void mach(){
|
||||
resource("home", "/", .mime = m_txt,
|
||||
.get = {
|
||||
mustache(.body = "hello")
|
||||
}
|
||||
);
|
||||
}
|
||||
155
01-multi-reactor-architecture.svg
Normal file
@@ -0,0 +1,155 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 920 580" font-family="system-ui, -apple-system, sans-serif">
|
||||
<defs>
|
||||
<marker id="arrow" markerWidth="8" markerHeight="6" refX="8" refY="3" orient="auto">
|
||||
<path d="M0,0 L8,3 L0,6" fill="#64748b"/>
|
||||
</marker>
|
||||
<marker id="arrow-amber" markerWidth="8" markerHeight="6" refX="8" refY="3" orient="auto">
|
||||
<path d="M0,0 L8,3 L0,6" fill="#f59e0b"/>
|
||||
</marker>
|
||||
<marker id="arrow-emerald" markerWidth="8" markerHeight="6" refX="8" refY="3" orient="auto">
|
||||
<path d="M0,0 L8,3 L0,6" fill="#10b981"/>
|
||||
</marker>
|
||||
</defs>
|
||||
|
||||
<!-- Background -->
|
||||
<rect width="920" height="580" rx="12" fill="#0f172a"/>
|
||||
|
||||
<!-- Title -->
|
||||
<text x="460" y="38" text-anchor="middle" fill="#f8fafc" font-size="18" font-weight="600">Multi-Reactor Architecture</text>
|
||||
|
||||
<!-- Subtitle -->
|
||||
<text x="460" y="58" text-anchor="middle" fill="#475569" font-size="10">request/task/cpu ratio configurable in compose.yml</text>
|
||||
|
||||
<!-- HTTP Clients -->
|
||||
<rect x="20" y="105" width="110" height="44" rx="8" fill="#1e293b" stroke="#334155" stroke-width="1.5"/>
|
||||
<text x="75" y="132" text-anchor="middle" fill="#94a3b8" font-size="13" font-weight="500">HTTP Clients</text>
|
||||
|
||||
<!-- Arrows from clients to request reactors -->
|
||||
<line x1="130" y1="117" x2="178" y2="117" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrow)"/>
|
||||
<line x1="130" y1="127" x2="178" y2="185" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrow)"/>
|
||||
<line x1="130" y1="137" x2="178" y2="255" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrow)"/>
|
||||
|
||||
<!-- ==================== REQUEST REACTORS ==================== -->
|
||||
<rect x="173" y="76" width="270" height="228" rx="10" fill="none" stroke="#334155" stroke-width="1" stroke-dasharray="6,4"/>
|
||||
<text x="308" y="96" text-anchor="middle" fill="#60a5fa" font-size="12" font-weight="600" letter-spacing="0.5">REQUEST REACTORS</text>
|
||||
|
||||
<!-- Request Reactor 0 -->
|
||||
<rect x="188" y="106" width="240" height="40" rx="8" fill="#1e3a5f" stroke="#3b82f6" stroke-width="1.5"/>
|
||||
<text x="203" y="131" fill="#93c5fd" font-size="11" font-weight="600">Core 0</text>
|
||||
<text x="260" y="131" fill="#cbd5e1" font-size="11">event loop</text>
|
||||
<rect x="348" y="114" width="72" height="24" rx="5" fill="#1e293b" stroke="#475569" stroke-width="1"/>
|
||||
<text x="384" y="131" text-anchor="middle" fill="#94a3b8" font-size="10">pipeline</text>
|
||||
|
||||
<!-- Request Reactor 1 -->
|
||||
<rect x="188" y="158" width="240" height="40" rx="8" fill="#1e3a5f" stroke="#3b82f6" stroke-width="1.5"/>
|
||||
<text x="203" y="183" fill="#93c5fd" font-size="11" font-weight="600">Core 1</text>
|
||||
<text x="260" y="183" fill="#cbd5e1" font-size="11">event loop</text>
|
||||
<rect x="348" y="166" width="72" height="24" rx="5" fill="#1e293b" stroke="#475569" stroke-width="1"/>
|
||||
<text x="384" y="183" text-anchor="middle" fill="#94a3b8" font-size="10">pipeline</text>
|
||||
|
||||
<!-- Ellipsis -->
|
||||
<circle cx="308" cy="212" r="2" fill="#475569"/>
|
||||
<circle cx="308" cy="222" r="2" fill="#475569"/>
|
||||
|
||||
<!-- Request Reactor N -->
|
||||
<rect x="188" y="240" width="240" height="40" rx="8" fill="#1e3a5f" stroke="#3b82f6" stroke-width="1.5"/>
|
||||
<text x="203" y="265" fill="#93c5fd" font-size="11" font-weight="600">Core N</text>
|
||||
<text x="260" y="265" fill="#cbd5e1" font-size="11">event loop</text>
|
||||
<rect x="348" y="248" width="72" height="24" rx="5" fill="#1e293b" stroke="#475569" stroke-width="1"/>
|
||||
<text x="384" y="265" text-anchor="middle" fill="#94a3b8" font-size="10">pipeline</text>
|
||||
|
||||
<!-- ==================== TASK REACTORS ==================== -->
|
||||
<rect x="173" y="330" width="270" height="228" rx="10" fill="none" stroke="#334155" stroke-width="1" stroke-dasharray="6,4"/>
|
||||
<text x="308" y="350" text-anchor="middle" fill="#fbbf24" font-size="12" font-weight="600" letter-spacing="0.5">TASK REACTORS</text>
|
||||
|
||||
<!-- Task Reactor 0 -->
|
||||
<rect x="188" y="360" width="240" height="40" rx="8" fill="#422006" stroke="#f59e0b" stroke-width="1.5"/>
|
||||
<text x="203" y="385" fill="#fcd34d" font-size="11" font-weight="600">Core</text>
|
||||
<text x="236" y="385" fill="#cbd5e1" font-size="11">event loop</text>
|
||||
<rect x="348" y="368" width="72" height="24" rx="5" fill="#1e293b" stroke="#475569" stroke-width="1"/>
|
||||
<text x="384" y="385" text-anchor="middle" fill="#94a3b8" font-size="10">cron / jobs</text>
|
||||
|
||||
<!-- Task Reactor 1 -->
|
||||
<rect x="188" y="412" width="240" height="40" rx="8" fill="#422006" stroke="#f59e0b" stroke-width="1.5"/>
|
||||
<text x="203" y="437" fill="#fcd34d" font-size="11" font-weight="600">Core</text>
|
||||
<text x="236" y="437" fill="#cbd5e1" font-size="11">event loop</text>
|
||||
<rect x="348" y="420" width="72" height="24" rx="5" fill="#1e293b" stroke="#475569" stroke-width="1"/>
|
||||
<text x="384" y="437" text-anchor="middle" fill="#94a3b8" font-size="10">cron / jobs</text>
|
||||
|
||||
<!-- Ellipsis -->
|
||||
<circle cx="308" cy="466" r="2" fill="#475569"/>
|
||||
<circle cx="308" cy="476" r="2" fill="#475569"/>
|
||||
|
||||
<!-- Task Reactor N -->
|
||||
<rect x="188" y="494" width="240" height="40" rx="8" fill="#422006" stroke="#f59e0b" stroke-width="1.5"/>
|
||||
<text x="203" y="519" fill="#fcd34d" font-size="11" font-weight="600">Core</text>
|
||||
<text x="236" y="519" fill="#cbd5e1" font-size="11">event loop</text>
|
||||
<rect x="348" y="502" width="72" height="24" rx="5" fill="#1e293b" stroke="#475569" stroke-width="1"/>
|
||||
<text x="384" y="519" text-anchor="middle" fill="#94a3b8" font-size="10">cron / jobs</text>
|
||||
|
||||
<!-- Task DB -->
|
||||
<rect x="20" y="410" width="110" height="44" rx="8" fill="#1e293b" stroke="#f59e0b" stroke-width="1.5"/>
|
||||
<text x="75" y="429" text-anchor="middle" fill="#fcd34d" font-size="11" font-weight="600">mach_tasks</text>
|
||||
<text x="75" y="444" text-anchor="middle" fill="#94a3b8" font-size="10">database</text>
|
||||
|
||||
<!-- Arrows: task DB to/from task reactors -->
|
||||
<line x1="130" y1="425" x2="183" y2="425" stroke="#f59e0b" stroke-width="1.5" marker-end="url(#arrow-amber)"/>
|
||||
<line x1="183" y1="437" x2="130" y2="437" stroke="#f59e0b" stroke-width="1.5" marker-end="url(#arrow-amber)"/>
|
||||
|
||||
<!-- ==================== SHARED THREAD POOL ==================== -->
|
||||
<rect x="540" y="76" width="350" height="270" rx="10" fill="none" stroke="#334155" stroke-width="1" stroke-dasharray="6,4"/>
|
||||
<text x="715" y="100" text-anchor="middle" fill="#34d399" font-size="12" font-weight="600" letter-spacing="0.5">SHARED THREAD POOL</text>
|
||||
<text x="715" y="116" text-anchor="middle" fill="#6b7280" font-size="10">remaining cores</text>
|
||||
|
||||
<!-- Work queue label -->
|
||||
<text x="715" y="140" text-anchor="middle" fill="#94a3b8" font-size="10">work queue</text>
|
||||
|
||||
<!-- Queue visualization -->
|
||||
<rect x="568" y="148" width="294" height="36" rx="6" fill="#1e293b" stroke="#475569" stroke-width="1"/>
|
||||
<rect x="576" y="154" width="24" height="24" rx="4" fill="#064e3b" stroke="#10b981" stroke-width="1"/>
|
||||
<rect x="606" y="154" width="24" height="24" rx="4" fill="#064e3b" stroke="#10b981" stroke-width="1"/>
|
||||
<rect x="636" y="154" width="24" height="24" rx="4" fill="#064e3b" stroke="#10b981" stroke-width="1"/>
|
||||
<rect x="666" y="154" width="24" height="24" rx="4" fill="#064e3b" stroke="#10b981" stroke-width="1"/>
|
||||
<rect x="696" y="154" width="24" height="24" rx="4" fill="#0f172a" stroke="#334155" stroke-width="1" stroke-dasharray="3,2"/>
|
||||
<rect x="726" y="154" width="24" height="24" rx="4" fill="#0f172a" stroke="#334155" stroke-width="1" stroke-dasharray="3,2"/>
|
||||
<rect x="756" y="154" width="24" height="24" rx="4" fill="#0f172a" stroke="#334155" stroke-width="1" stroke-dasharray="3,2"/>
|
||||
<rect x="786" y="154" width="24" height="24" rx="4" fill="#0f172a" stroke="#334155" stroke-width="1" stroke-dasharray="3,2"/>
|
||||
<rect x="816" y="154" width="24" height="24" rx="4" fill="#0f172a" stroke="#334155" stroke-width="1" stroke-dasharray="3,2"/>
|
||||
|
||||
<!-- Arrows from queue down to threads -->
|
||||
<line x1="630" y1="184" x2="630" y2="214" stroke="#475569" stroke-width="1" marker-end="url(#arrow)"/>
|
||||
<line x1="720" y1="184" x2="720" y2="214" stroke="#475569" stroke-width="1" marker-end="url(#arrow)"/>
|
||||
<line x1="810" y1="184" x2="810" y2="214" stroke="#475569" stroke-width="1" marker-end="url(#arrow)"/>
|
||||
|
||||
<!-- Thread boxes -->
|
||||
<rect x="570" y="218" width="110" height="48" rx="6" fill="#064e3b" stroke="#10b981" stroke-width="1.5"/>
|
||||
<text x="625" y="247" text-anchor="middle" fill="#6ee7b7" font-size="11" font-weight="500">Thread 1</text>
|
||||
|
||||
<rect x="690" y="218" width="60" height="48" rx="6" fill="#064e3b" stroke="#10b981" stroke-width="1.5"/>
|
||||
<text x="720" y="247" text-anchor="middle" fill="#6ee7b7" font-size="11" font-weight="500">...</text>
|
||||
|
||||
<rect x="760" y="218" width="110" height="48" rx="6" fill="#064e3b" stroke="#10b981" stroke-width="1.5"/>
|
||||
<text x="815" y="247" text-anchor="middle" fill="#6ee7b7" font-size="11" font-weight="500">Thread N</text>
|
||||
|
||||
<!-- Result return -->
|
||||
<text x="715" y="298" text-anchor="middle" fill="#6b7280" font-size="10">on complete, resumes pipeline on reactor</text>
|
||||
|
||||
<!-- ==================== INVOKE ARROWS ==================== -->
|
||||
<!-- Arrow from request reactors to pool -->
|
||||
<path d="M 443,185 L 535,168" fill="none" stroke="#10b981" stroke-width="1.5" marker-end="url(#arrow-emerald)" stroke-dasharray="5,3"/>
|
||||
<text x="476" y="164" fill="#34d399" font-size="10" font-weight="500">invoke()</text>
|
||||
|
||||
<!-- Arrow from task reactors to pool -->
|
||||
<path d="M 443,430 Q 510,390 535,310" fill="none" stroke="#10b981" stroke-width="1.5" marker-end="url(#arrow-emerald)" stroke-dasharray="5,3"/>
|
||||
<text x="518" y="390" fill="#34d399" font-size="10" font-weight="500">invoke()</text>
|
||||
|
||||
<!-- ==================== TASK ARROWS ==================== -->
|
||||
<!-- task() from request reactors to task DB -->
|
||||
<path d="M 188,286 Q 110,320 85,405" fill="none" stroke="#f59e0b" stroke-width="1.5" marker-end="url(#arrow-amber)" stroke-dasharray="5,3"/>
|
||||
<text x="108" y="330" fill="#fbbf24" font-size="10" font-weight="500">task()</text>
|
||||
|
||||
<!-- task() from task reactors to task DB (self-enqueue) -->
|
||||
<path d="M 188,540 Q 130,556 85,458" fill="none" stroke="#f59e0b" stroke-width="1.5" marker-end="url(#arrow-amber)" stroke-dasharray="5,3"/>
|
||||
<text x="120" y="540" fill="#fbbf24" font-size="10" font-weight="500">task()</text>
|
||||
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 10 KiB |
10
01_hello_world_text/main.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <mach.h>
|
||||
|
||||
void mach(){
|
||||
resource("home", "/", .mime = m_txt,
|
||||
.get = {
|
||||
input({"name", m_not_empty, .fallback = "world"}),
|
||||
mustache(.body = "Hello {{name}}")
|
||||
}
|
||||
);
|
||||
}
|
||||
95
02-request-pipeline-flow.svg
Normal file
@@ -0,0 +1,95 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 300" width="760" height="300">
|
||||
<rect width="760" height="300" fill="#09080f"/>
|
||||
<defs>
|
||||
<linearGradient id="sg1" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0%" stop-color="#3b82f6"/>
|
||||
<stop offset="100%" stop-color="#2563eb"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="sg2" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0%" stop-color="#8b5cf6"/>
|
||||
<stop offset="100%" stop-color="#7c3aed"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="sg3" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0%" stop-color="#f59e0b"/>
|
||||
<stop offset="100%" stop-color="#d97706"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="sg4" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0%" stop-color="#10b981"/>
|
||||
<stop offset="100%" stop-color="#059669"/>
|
||||
</linearGradient>
|
||||
<style>text{font-family:'JetBrains Mono','Fira Code',monospace}</style>
|
||||
</defs>
|
||||
|
||||
<!-- Outer container -->
|
||||
<rect x="20" y="16" width="720" height="268" rx="14" fill="#0f0d1a" stroke="#1e1b2e" stroke-width="1.5"/>
|
||||
|
||||
<!-- Route label -->
|
||||
<text x="44" y="46" fill="#94a3b8" font-size="12" font-weight="600">POST /todos</text>
|
||||
|
||||
<!-- .before label -->
|
||||
<text x="44" y="72" fill="#475569" font-size="9">.before</text>
|
||||
|
||||
<!-- session() box: x=44 w=108 → right edge 152 -->
|
||||
<rect x="44" y="80" width="108" height="40" rx="8" fill="#1e293b" stroke="#3b82f6" stroke-width="1"/>
|
||||
<text x="98" y="105" text-anchor="middle" fill="#93c5fd" font-size="11" font-weight="600">session()</text>
|
||||
|
||||
<!-- Arrow 1: line 152→170, triangle tip at 180 -->
|
||||
<line x1="152" y1="100" x2="170" y2="100" stroke="#64748b" stroke-width="1.5"/>
|
||||
<polygon points="180,100 170,95 170,105" fill="#64748b"/>
|
||||
|
||||
<!-- .post pipeline label -->
|
||||
<text x="188" y="72" fill="#475569" font-size="9">.post pipeline</text>
|
||||
|
||||
<!-- param() box: x=188 w=108 → right edge 296 -->
|
||||
<rect x="188" y="80" width="108" height="40" rx="8" fill="url(#sg1)"/>
|
||||
<text x="242" y="98" text-anchor="middle" fill="#fff" font-size="11" font-weight="700">param()</text>
|
||||
<text x="242" y="113" text-anchor="middle" fill="rgba(255,255,255,0.65)" font-size="8">validate title</text>
|
||||
|
||||
<!-- Arrow 2: line 296→314, triangle tip at 324 -->
|
||||
<line x1="296" y1="100" x2="314" y2="100" stroke="#64748b" stroke-width="1.5"/>
|
||||
<polygon points="324,100 314,95 314,105" fill="#64748b"/>
|
||||
|
||||
<!-- db() box: x=324 w=108 → right edge 432 -->
|
||||
<rect x="324" y="80" width="108" height="40" rx="8" fill="url(#sg2)"/>
|
||||
<text x="378" y="98" text-anchor="middle" fill="#fff" font-size="11" font-weight="700">db()</text>
|
||||
<text x="378" y="113" text-anchor="middle" fill="rgba(255,255,255,0.65)" font-size="8">INSERT todo</text>
|
||||
|
||||
<!-- Arrow 3: line 432→450, triangle tip at 460 -->
|
||||
<line x1="432" y1="100" x2="450" y2="100" stroke="#64748b" stroke-width="1.5"/>
|
||||
<polygon points="460,100 450,95 450,105" fill="#64748b"/>
|
||||
|
||||
<!-- emit() box: x=460 w=108 → right edge 568 -->
|
||||
<rect x="460" y="80" width="108" height="40" rx="8" fill="url(#sg3)"/>
|
||||
<text x="514" y="98" text-anchor="middle" fill="#fff" font-size="11" font-weight="700">emit()</text>
|
||||
<text x="514" y="113" text-anchor="middle" fill="rgba(255,255,255,0.65)" font-size="8">todo_created</text>
|
||||
|
||||
<!-- Arrow 4: line 568→586, triangle tip at 596 -->
|
||||
<line x1="568" y1="100" x2="586" y2="100" stroke="#64748b" stroke-width="1.5"/>
|
||||
<polygon points="596,100 586,95 586,105" fill="#64748b"/>
|
||||
|
||||
<!-- redirect() box: x=596 w=108 → right edge 704 -->
|
||||
<rect x="596" y="80" width="108" height="40" rx="8" fill="url(#sg4)"/>
|
||||
<text x="650" y="98" text-anchor="middle" fill="#fff" font-size="11" font-weight="700">redirect()</text>
|
||||
<text x="650" y="113" text-anchor="middle" fill="rgba(255,255,255,0.65)" font-size="8">302 → /todos</text>
|
||||
|
||||
<!-- ===== Pipeline Context ===== -->
|
||||
<rect x="44" y="146" width="672" height="120" rx="10" fill="#111827" stroke="#1f2937" stroke-width="1"/>
|
||||
<text x="64" y="170" fill="#6b7280" font-size="10" font-weight="600">PIPELINE CONTEXT</text>
|
||||
|
||||
<!-- Context cards: each 148w x 52h, gap 12 -->
|
||||
<rect x="60" y="182" width="148" height="52" rx="6" fill="#1e1b2e" stroke="#3b82f6" stroke-width="0.75"/>
|
||||
<text x="134" y="206" text-anchor="middle" fill="#e2e8f0" font-size="11" font-weight="600">user_id</text>
|
||||
<text x="134" y="222" text-anchor="middle" fill="#6b7280" font-size="9">← session</text>
|
||||
|
||||
<rect x="220" y="182" width="148" height="52" rx="6" fill="#1e1b2e" stroke="#3b82f6" stroke-width="0.75"/>
|
||||
<text x="294" y="206" text-anchor="middle" fill="#e2e8f0" font-size="11" font-weight="600">title</text>
|
||||
<text x="294" y="222" text-anchor="middle" fill="#6b7280" font-size="9">← param</text>
|
||||
|
||||
<rect x="380" y="182" width="148" height="52" rx="6" fill="#1e1b2e" stroke="#8b5cf6" stroke-width="0.75"/>
|
||||
<text x="454" y="206" text-anchor="middle" fill="#e2e8f0" font-size="11" font-weight="600">todo</text>
|
||||
<text x="454" y="222" text-anchor="middle" fill="#6b7280" font-size="9">← db .set</text>
|
||||
|
||||
<rect x="540" y="182" width="148" height="52" rx="6" fill="#1e1b2e" stroke="#374151" stroke-width="0.75"/>
|
||||
<text x="614" y="206" text-anchor="middle" fill="#e2e8f0" font-size="11" font-weight="600">base_layout</text>
|
||||
<text x="614" y="222" text-anchor="middle" fill="#6b7280" font-size="9">← .context</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.2 KiB |
17
02_hello_world_html/main.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <mach.h>
|
||||
|
||||
void mach(){
|
||||
resource("home", "/",
|
||||
.get = {
|
||||
input({"name", m_not_empty, .fallback = "world"}),
|
||||
mustache(.body =
|
||||
"<html>"
|
||||
"<head></head>"
|
||||
"<body>"
|
||||
"<p>Hello {{name}}</p>"
|
||||
"</body>"
|
||||
"</html>"
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
66
03-event-pub-sub.svg
Normal file
@@ -0,0 +1,66 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 300" width="900" height="300">
|
||||
<rect width="900" height="300" fill="#09080f"/>
|
||||
<defs>
|
||||
<linearGradient id="pubG" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color="#f59e0b"/>
|
||||
<stop offset="100%" stop-color="#d97706"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="subG" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color="#06b6d4"/>
|
||||
<stop offset="100%" stop-color="#0891b2"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="busG" x1="0" y1="0" x2="1" y2="0">
|
||||
<stop offset="0%" stop-color="#7c3aed"/>
|
||||
<stop offset="50%" stop-color="#a855f7"/>
|
||||
<stop offset="100%" stop-color="#7c3aed"/>
|
||||
</linearGradient>
|
||||
<style>text{font-family:'JetBrains Mono','Fira Code',monospace}</style>
|
||||
</defs>
|
||||
|
||||
<!-- ===== Publisher: todos module ===== -->
|
||||
<rect x="30" y="30" width="220" height="130" rx="12" fill="#1e1b2e" stroke="#f59e0b" stroke-width="1.5"/>
|
||||
<rect x="30" y="30" width="220" height="36" rx="12" fill="url(#pubG)"/>
|
||||
<text x="140" y="53" text-anchor="middle" fill="#fff" font-size="12" font-weight="700">todos module</text>
|
||||
<text x="50" y="86" fill="#fcd34d" font-size="10">.post pipeline:</text>
|
||||
<text x="58" y="102" fill="#e2e8f0" font-size="10">param() → db()</text>
|
||||
<text x="58" y="118" fill="#e2e8f0" font-size="10">→ emit("todo_created")</text>
|
||||
<text x="58" y="134" fill="#e2e8f0" font-size="10">→ redirect("/todos")</text>
|
||||
|
||||
<!-- .publishes contract -->
|
||||
<text x="140" y="175" text-anchor="middle" fill="#92400e" font-size="9" font-weight="600">.publishes</text>
|
||||
<rect x="40" y="182" width="200" height="28" rx="6" fill="#451a03" stroke="#f59e0b" stroke-width="0.75"/>
|
||||
<text x="140" y="201" text-anchor="middle" fill="#fcd34d" font-size="9">todo_created → user_id, title</text>
|
||||
|
||||
<!-- ===== Event Bus pill ===== -->
|
||||
<rect x="330" y="118" width="140" height="44" rx="22" fill="url(#busG)"/>
|
||||
<text x="400" y="145" text-anchor="middle" fill="#fff" font-size="11" font-weight="700">Event Bus</text>
|
||||
|
||||
<!-- Arrow: publisher → bus -->
|
||||
<line x1="250" y1="140" x2="320" y2="140" stroke="#f59e0b" stroke-width="2"/>
|
||||
<polygon points="330,140 320,135 320,145" fill="#f59e0b"/>
|
||||
|
||||
<!-- ===== Subscriber 1: activity module ===== -->
|
||||
<rect x="570" y="20" width="300" height="100" rx="12" fill="#1e1b2e" stroke="#06b6d4" stroke-width="1.5"/>
|
||||
<rect x="570" y="20" width="300" height="36" rx="12" fill="url(#subG)"/>
|
||||
<text x="720" y="43" text-anchor="middle" fill="#fff" font-size="12" font-weight="700">activity module</text>
|
||||
<text x="595" y="74" fill="#67e8f9" font-size="10">.events:</text>
|
||||
<text x="603" y="92" fill="#e2e8f0" font-size="9">"todo_created" → db(log.sql)</text>
|
||||
|
||||
<!-- Elbow: bus right → subscriber 1 -->
|
||||
<path d="M470,140 L525,140 L525,70 L560,70" stroke="#06b6d4" stroke-width="1.5" fill="none"/>
|
||||
<polygon points="570,70 560,65 560,75" fill="#06b6d4"/>
|
||||
|
||||
<!-- ===== Subscriber 2: notifications module ===== -->
|
||||
<rect x="570" y="160" width="300" height="100" rx="12" fill="#1e1b2e" stroke="#06b6d4" stroke-width="1.5"/>
|
||||
<rect x="570" y="160" width="300" height="36" rx="12" fill="url(#subG)"/>
|
||||
<text x="720" y="183" text-anchor="middle" fill="#fff" font-size="12" font-weight="700">notifications module</text>
|
||||
<text x="595" y="214" fill="#67e8f9" font-size="10">.events:</text>
|
||||
<text x="603" y="232" fill="#e2e8f0" font-size="9">"todo_created" → call(notify)</text>
|
||||
|
||||
<!-- Elbow: bus right → subscriber 2 -->
|
||||
<path d="M470,140 L525,140 L525,210 L560,210" stroke="#06b6d4" stroke-width="1.5" fill="none"/>
|
||||
<polygon points="570,210 560,205 560,215" fill="#06b6d4"/>
|
||||
|
||||
<!-- Footer -->
|
||||
<text x="450" y="290" text-anchor="middle" fill="#64748b" font-size="10">Modules are decoupled — publishers don't know about subscribers</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.8 KiB |
4
03_hello_world_html_db/create_hello_world_table.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
CREATE TABLE greetings (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL
|
||||
);
|
||||
3
03_hello_world_html_db/get_hello_world.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
select name
|
||||
from greetings
|
||||
limit 1;
|
||||
7
03_hello_world_html_db/hello_world.mustache.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<body>
|
||||
{{#hello_world_data}}
|
||||
<p>Hello {{name}}</p>
|
||||
{{/hello_world_data}}
|
||||
</body>
|
||||
</html>
|
||||
18
03_hello_world_html_db/main.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <mach.h>
|
||||
#include <sqlite.h>
|
||||
|
||||
void mach(){
|
||||
resource("home", "/",
|
||||
.get = {
|
||||
sqlite_query({"hello_db", "get_hello_world", "hello_world_data"}),
|
||||
mustache("hello_world")
|
||||
}
|
||||
);
|
||||
|
||||
sqlite_database(
|
||||
.name = "hello_db",
|
||||
.connect = "file:hello.db?mode=rwc",
|
||||
.migrations = {"create_hello_world_table"},
|
||||
.seeds = {"seed_hello_world"}
|
||||
);
|
||||
}
|
||||
2
03_hello_world_html_db/seed_hello_world.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
INSERT INTO greetings(name)
|
||||
VALUES('World');
|
||||
46
04-error-resolution.svg
Normal file
@@ -0,0 +1,46 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 320" width="760" height="320">
|
||||
<rect width="760" height="320" fill="#09080f"/>
|
||||
<defs>
|
||||
<style>text{font-family:'JetBrains Mono','Fira Code',monospace}</style>
|
||||
</defs>
|
||||
|
||||
<!-- Level 1: Root Config — y=24 h=60 → bottom 84 -->
|
||||
<rect x="40" y="24" width="680" height="60" rx="10" fill="#2d2640" stroke="#7c3aed" stroke-width="1.5"/>
|
||||
<text x="380" y="50" text-anchor="middle" fill="#c084fc" font-size="12" font-weight="700">Root Config</text>
|
||||
<text x="380" y="70" text-anchor="middle" fill="#94a3b8" font-size="10">.errors = { 404 → render 404.html }</text>
|
||||
|
||||
<!-- Gap: 84 → 118 (34px gap) -->
|
||||
|
||||
<!-- Level 2: Module Config — y=118 h=60 → bottom 178 -->
|
||||
<rect x="120" y="118" width="520" height="60" rx="10" fill="#1e293b" stroke="#3b82f6" stroke-width="1.5" stroke-dasharray="5,3"/>
|
||||
<text x="380" y="144" text-anchor="middle" fill="#60a5fa" font-size="12" font-weight="700">Module Config</text>
|
||||
<text x="380" y="164" text-anchor="middle" fill="#94a3b8" font-size="10">.errors = { ... }</text>
|
||||
|
||||
<!-- Gap: 178 → 212 (34px gap) -->
|
||||
|
||||
<!-- Level 3: Route — y=212 h=60 → bottom 272 -->
|
||||
<rect x="200" y="212" width="360" height="60" rx="10" fill="#0c2d3e" stroke="#06b6d4" stroke-width="1.5" stroke-dasharray="5,3"/>
|
||||
<text x="380" y="238" text-anchor="middle" fill="#22d3ee" font-size="12" font-weight="700">Route /todos/:id</text>
|
||||
<text x="380" y="258" text-anchor="middle" fill="#94a3b8" font-size="10">.errors = { ... }</text>
|
||||
|
||||
<!-- Error origin dot: y=296 -->
|
||||
<circle cx="380" cy="296" r="10" fill="#ef4444" opacity="0.85"/>
|
||||
<text x="380" y="300" text-anchor="middle" fill="#fff" font-size="10" font-weight="700">!</text>
|
||||
<text x="400" y="300" fill="#fca5a5" font-size="10"> 404 raised in pipeline step</text>
|
||||
|
||||
<!-- Arrow 1: error dot (286) → route bottom (272). Line + up triangle -->
|
||||
<line x1="380" y1="286" x2="380" y2="275" stroke="#ef4444" stroke-width="2"/>
|
||||
<polygon points="380,272 375,279 385,279" fill="#ef4444"/>
|
||||
|
||||
<!-- Arrow 2: route top (212) → module bottom (178). Line in gap + up triangle -->
|
||||
<line x1="380" y1="212" x2="380" y2="181" stroke="#ef4444" stroke-width="2"/>
|
||||
<polygon points="380,178 375,185 385,185" fill="#ef4444"/>
|
||||
<!-- Label -->
|
||||
<text x="400" y="200" fill="#6b7280" font-size="9">no 404 handler → bubble up</text>
|
||||
|
||||
<!-- Arrow 3: module top (118) → root bottom (84). Line in gap + up triangle -->
|
||||
<line x1="380" y1="118" x2="380" y2="87" stroke="#ef4444" stroke-width="2"/>
|
||||
<polygon points="380,84 375,91 385,91" fill="#ef4444"/>
|
||||
<!-- Label -->
|
||||
<text x="400" y="106" fill="#22c55e" font-size="9" font-weight="600">✓ matched → render 404.html</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
5
04_todo/404.mustache.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{{< layout}}
|
||||
{{$body}}
|
||||
<p>not found</p>
|
||||
{{/body}}
|
||||
{{/layout}}
|
||||
5
04_todo/5xx.mustache.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{{< layout}}
|
||||
{{$body}}
|
||||
<p>error</p>
|
||||
{{/body}}
|
||||
{{/layout}}
|
||||
5
04_todo/about.mustache.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{{< layout}}
|
||||
{{$body}}
|
||||
<p>about us</p>
|
||||
{{/body}}
|
||||
{{/layout}}
|
||||
5
04_todo/contact.mustache.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{{< layout}}
|
||||
{{$body}}
|
||||
<p>contact us</p>
|
||||
{{/body}}
|
||||
{{/layout}}
|
||||
2
04_todo/create_todo.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
insert into todos(user_id, title)
|
||||
values({{user_id}}, {{title}});
|
||||
7
04_todo/create_todos_table.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE IF NOT EXISTS todos (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
finished INTEGER CHECK(finished IN (1))
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_todos_user_id ON todos(user_id);
|
||||
3
04_todo/delete_todo.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
delete from todos
|
||||
where user_id = {{user_id}}
|
||||
and id = {{id}};
|
||||
3
04_todo/get_todos.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
select id, title, finished
|
||||
from todos
|
||||
where user_id = {{user_id}};
|
||||
5
04_todo/home.mustache.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{{< layout}}
|
||||
{{$body}}
|
||||
<p>home</p>
|
||||
{{/body}}
|
||||
{{/layout}}
|
||||
23
04_todo/layout.mustache.html
Normal file
@@ -0,0 +1,23 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel='icon' href='{{asset:favicon.png}}'>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
{{^user}}
|
||||
<a href='{{url:login}}'>sign in</a>
|
||||
{{/user}}
|
||||
{{#user}}
|
||||
welcome, {{short_name}}
|
||||
{{/user}}
|
||||
</p>
|
||||
<nav>
|
||||
<a href='{{url:home}}'>home</a>
|
||||
<a href='{{url:about}}'>about us</a>
|
||||
<a href='{{url:contact}}'>contact us</a>
|
||||
<a href='{{url:todos}}'>todos</a>
|
||||
</nav>
|
||||
{{$body}}
|
||||
{{/body}}
|
||||
</body>
|
||||
</html>
|
||||
59
04_todo/main.c
Normal file
@@ -0,0 +1,59 @@
|
||||
#include <mach.h>
|
||||
#include <sqlite.h>
|
||||
#include <session_auth.h>
|
||||
|
||||
void mach(){
|
||||
middleware(session());
|
||||
|
||||
resource("home", "/",
|
||||
.get = {mustache("home")}
|
||||
);
|
||||
|
||||
resource("about", "/about",
|
||||
.get = {mustache("about")}
|
||||
);
|
||||
|
||||
resource("contact", "/contact",
|
||||
.get = {mustache("contact")}
|
||||
);
|
||||
|
||||
resource("todos", "/todos",
|
||||
.all = {logged_in()},
|
||||
.get = {
|
||||
sqlite_query({"todos_db", "get_todos", "todos_data"}),
|
||||
mustache("todos")
|
||||
},
|
||||
.post = {
|
||||
input({"title", m_not_empty}),
|
||||
sqlite_query({"todos_db", "create_todo"}),
|
||||
redirect("todos")
|
||||
}
|
||||
);
|
||||
|
||||
resource("todo", "/todos/:id",
|
||||
.all = {
|
||||
logged_in(),
|
||||
input({"id", m_positive})
|
||||
},
|
||||
.patch = {
|
||||
input({"finished", "1", "must be 1", .optional = true,}),
|
||||
sqlite_query({"todos_db", "update_todo"}),
|
||||
redirect("todos")
|
||||
},
|
||||
.delete = {
|
||||
sqlite_query({"todos_db", "delete_todo"}),
|
||||
redirect("todos")
|
||||
}
|
||||
);
|
||||
|
||||
sqlite_database(
|
||||
.name ="todos_db",
|
||||
.connect = "file:{{user_id}}_todo.db?mode=rwc",
|
||||
.migrations = {"create_todos_table"}
|
||||
);
|
||||
|
||||
error(m_error, {mustache("5xx")});
|
||||
error(m_not_found, {mustache("404")});
|
||||
|
||||
session_auth();
|
||||
}
|
||||
0
04_todo/public/favicon.png
Normal file
30
04_todo/todos.mustache.html
Normal file
@@ -0,0 +1,30 @@
|
||||
{{< layout}}
|
||||
{{$body}}
|
||||
<form action="{{url:todos}}" method="post">
|
||||
<input type="text" name="title" placeholder="new todo" required>
|
||||
<button type="submit">add</button>
|
||||
</form>
|
||||
{{^todos_data}}
|
||||
<p>no todos</p>
|
||||
{{/todos_data}}
|
||||
{{#todos_data}}
|
||||
<div>
|
||||
<form action="{{url:todo}}" method="post" style="display:inline">
|
||||
<input type="hidden" name="http_method" value="patch">
|
||||
{{^finished}}
|
||||
<input type="checkbox" name="finished" value="1">
|
||||
{{/finished}}
|
||||
{{#finished}}
|
||||
<input type="checkbox" name="finished" value="1" checked>
|
||||
{{/finished}}
|
||||
{{title}}
|
||||
<button type="submit">save</button>
|
||||
</form>
|
||||
<form action="{{url:todo}}" method="post" style="display:inline">
|
||||
<input type="hidden" name="http_method" value="delete">
|
||||
<button type="submit">delete</button>
|
||||
</form>
|
||||
</div>
|
||||
{{/todos_data}}
|
||||
{{/body}}
|
||||
{{/layout}}
|
||||
4
04_todo/update_todo.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
update todos
|
||||
set finished = {{finished}}
|
||||
where user_id = {{user_id}}
|
||||
and id = {{id}};
|
||||
58
05-app-composition-tree.svg
Normal file
@@ -0,0 +1,58 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 270" width="760" height="270">
|
||||
<rect width="760" height="270" fill="#09080f"/>
|
||||
<defs>
|
||||
<linearGradient id="rG" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color="#a855f7"/>
|
||||
<stop offset="100%" stop-color="#7c3aed"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="mG" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color="#3b82f6"/>
|
||||
<stop offset="100%" stop-color="#2563eb"/>
|
||||
</linearGradient>
|
||||
<style>text{font-family:'JetBrains Mono','Fira Code',monospace}</style>
|
||||
</defs>
|
||||
|
||||
<!-- Root node: x=290 y=20 w=180 h=44 → center 380, bottom 64 -->
|
||||
<rect x="290" y="20" width="180" height="44" rx="10" fill="url(#rG)"/>
|
||||
<text x="380" y="47" text-anchor="middle" fill="#fff" font-size="12" font-weight="700">mach() — root</text>
|
||||
|
||||
<!-- Elbow connectors: root bottom center → down to 82 → horizontal → down to child tops at 108 -->
|
||||
<!-- Vertical trunk from root -->
|
||||
<line x1="380" y1="64" x2="380" y2="82" stroke="#64748b" stroke-width="1.5"/>
|
||||
<!-- Horizontal bar -->
|
||||
<line x1="130" y1="82" x2="630" y2="82" stroke="#64748b" stroke-width="1.5"/>
|
||||
<!-- Vertical drops to each child -->
|
||||
<line x1="130" y1="82" x2="130" y2="108" stroke="#64748b" stroke-width="1.5"/>
|
||||
<line x1="380" y1="82" x2="380" y2="108" stroke="#64748b" stroke-width="1.5"/>
|
||||
<line x1="630" y1="82" x2="630" y2="108" stroke="#64748b" stroke-width="1.5"/>
|
||||
|
||||
<!-- Level 1: each w=170 h=40, top at y=108 → bottom at 148 -->
|
||||
<rect x="45" y="108" width="170" height="40" rx="8" fill="url(#mG)"/>
|
||||
<text x="130" y="133" text-anchor="middle" fill="#fff" font-size="11" font-weight="600">sqlite_config()</text>
|
||||
|
||||
<rect x="295" y="108" width="170" height="40" rx="8" fill="url(#mG)"/>
|
||||
<text x="380" y="133" text-anchor="middle" fill="#fff" font-size="11" font-weight="600">todos_config()</text>
|
||||
|
||||
<rect x="545" y="108" width="170" height="40" rx="8" fill="url(#mG)"/>
|
||||
<text x="630" y="133" text-anchor="middle" fill="#fff" font-size="11" font-weight="600">auth_config()</text>
|
||||
|
||||
<!-- Elbow connectors: todos bottom center → down to 162 → horizontal → down to leaf tops at 178 -->
|
||||
<line x1="380" y1="148" x2="380" y2="162" stroke="#64748b" stroke-width="1"/>
|
||||
<line x1="260" y1="162" x2="500" y2="162" stroke="#64748b" stroke-width="1"/>
|
||||
<line x1="260" y1="162" x2="260" y2="178" stroke="#64748b" stroke-width="1"/>
|
||||
<line x1="500" y1="162" x2="500" y2="178" stroke="#64748b" stroke-width="1"/>
|
||||
|
||||
<!-- Level 2 leaf nodes: w=170 h=64, top at y=178 -->
|
||||
<rect x="175" y="178" width="170" height="64" rx="8" fill="#0f0d1a" stroke="#10b981" stroke-width="1"/>
|
||||
<text x="260" y="200" text-anchor="middle" fill="#6ee7b7" font-size="10">.databases</text>
|
||||
<text x="260" y="216" text-anchor="middle" fill="#6ee7b7" font-size="10">.resources</text>
|
||||
<text x="260" y="232" text-anchor="middle" fill="#6ee7b7" font-size="10">.events</text>
|
||||
|
||||
<rect x="415" y="178" width="170" height="64" rx="8" fill="#0f0d1a" stroke="#10b981" stroke-width="1"/>
|
||||
<text x="500" y="200" text-anchor="middle" fill="#6ee7b7" font-size="10">.publishes</text>
|
||||
<text x="500" y="216" text-anchor="middle" fill="#6ee7b7" font-size="10">.context</text>
|
||||
<text x="500" y="232" text-anchor="middle" fill="#6ee7b7" font-size="10">.errors</text>
|
||||
|
||||
<!-- Footer -->
|
||||
<text x="380" y="262" text-anchor="middle" fill="#64748b" font-size="10">First registration wins — root can override module defaults</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.4 KiB |
5
05_todo_sse_datastar/404.mustache.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{{< layout}}
|
||||
{{$body}}
|
||||
<p>not found</p>
|
||||
{{/body}}
|
||||
{{/layout}}
|
||||
5
05_todo_sse_datastar/5xx.mustache.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{{< layout}}
|
||||
{{$body}}
|
||||
<p>error</p>
|
||||
{{/body}}
|
||||
{{/layout}}
|
||||
5
05_todo_sse_datastar/about.mustache.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{{< layout}}
|
||||
{{$body}}
|
||||
<p>about us</p>
|
||||
{{/body}}
|
||||
{{/layout}}
|
||||
5
05_todo_sse_datastar/contact.mustache.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{{< layout}}
|
||||
{{$body}}
|
||||
<p>contact us</p>
|
||||
{{/body}}
|
||||
{{/layout}}
|
||||
3
05_todo_sse_datastar/create_todo.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
insert into todos(user_id, title)
|
||||
values({{user_id}}, {{title}})
|
||||
returning id, title, finished;
|
||||
7
05_todo_sse_datastar/create_todos_table.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE IF NOT EXISTS todos (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
finished INTEGER CHECK(finished IN (1))
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_todos_user_id ON todos(user_id);
|
||||
4
05_todo_sse_datastar/delete_todo.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
delete from todos
|
||||
where user_id = {{user_id}}
|
||||
and id = {{id}}
|
||||
returning id;
|
||||
3
05_todo_sse_datastar/get_todos.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
select id, title, finished
|
||||
from todos
|
||||
where user_id = {{user_id}};
|
||||
5
05_todo_sse_datastar/home.mustache.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{{< layout}}
|
||||
{{$body}}
|
||||
<p>home</p>
|
||||
{{/body}}
|
||||
{{/layout}}
|
||||
25
05_todo_sse_datastar/layout.mustache.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel='icon' href='{{asset:favicon.png}}'>
|
||||
{{$head}}
|
||||
{{/head}}
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
{{^user}}
|
||||
<a href='{{url:login}}'>sign in</a>
|
||||
{{/user}}
|
||||
{{#user}}
|
||||
welcome, {{short_name}}
|
||||
{{/user}}
|
||||
</p>
|
||||
<nav>
|
||||
<a href='{{url:home}}'>home</a>
|
||||
<a href='{{url:about}}'>about us</a>
|
||||
<a href='{{url:contact}}'>contact us</a>
|
||||
<a href='{{url:todos}}'>todos</a>
|
||||
</nav>
|
||||
{{$body}}
|
||||
{{/body}}
|
||||
</body>
|
||||
</html>
|
||||
62
05_todo_sse_datastar/main.c
Normal file
@@ -0,0 +1,62 @@
|
||||
#include <mach.h>
|
||||
#include <sqlite.h>
|
||||
#include <datastar.h>
|
||||
#include <session_auth.h>
|
||||
|
||||
void mach(){
|
||||
middleware(session());
|
||||
|
||||
resource("home", "/",
|
||||
.get = {mustache("home")}
|
||||
);
|
||||
|
||||
resource("about", "/about",
|
||||
.get = {mustache("about")}
|
||||
);
|
||||
|
||||
resource("contact", "/contact",
|
||||
.get = {mustache("contact")}
|
||||
);
|
||||
|
||||
resource("todos", "/todos",
|
||||
.all = {logged_in()},
|
||||
.sse = {"todos:{{user_id}}"},
|
||||
.get = {
|
||||
sqlite_query({"todos_db", "get_todos", "todos_data"}),
|
||||
mustache("todos")
|
||||
},
|
||||
.post = {
|
||||
input({"title", m_not_empty}),
|
||||
sqlite_query({"todos_db", "create_todo", "todo_data", .must_exist = true}),
|
||||
datastar_sse("todos:{{user_id}}", .target = "todos", .mode = mode_prepend, .elements = {"todo"})
|
||||
}
|
||||
);
|
||||
|
||||
resource("todo", "/todos/:id",
|
||||
.all = {
|
||||
logged_in(),
|
||||
input({"id", m_positive})
|
||||
},
|
||||
.patch = {
|
||||
input({"finished", "1", "must be 1", .optional = true}),
|
||||
sqlite_query({"todos_db", "update_todo", "todo_data", .must_exist = true}),
|
||||
datastar_sse("todos:{{user_id}}", .target = "todo_{{id}}", .mode = mode_replace, .elements = {"todo"})
|
||||
},
|
||||
.delete = {
|
||||
sqlite_query({"todos_db", "delete_todo", .must_exist = true}),
|
||||
datastar_sse("todos:{{user_id}}", .target = "todo_{{id}}", .mode = mode_remove)
|
||||
}
|
||||
);
|
||||
|
||||
sqlite_database(
|
||||
.name = "todos_db",
|
||||
.connect = "file:todo.db?mode=rwc",
|
||||
.migrations = {"create_todos_table"}
|
||||
);
|
||||
|
||||
error(m_error, {mustache("5xx")});
|
||||
error(m_not_found, {mustache("404")});
|
||||
|
||||
datastar();
|
||||
session_auth();
|
||||
}
|
||||
0
05_todo_sse_datastar/public/favicon.png
Normal file
3
05_todo_sse_datastar/todo.mustache.html
Normal file
@@ -0,0 +1,3 @@
|
||||
{{#todo_data}}
|
||||
{{> todo_item}}
|
||||
{{/todo_data}}
|
||||
10
05_todo_sse_datastar/todo_item.mustache.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<div id="todo_{{id}}">
|
||||
{{^finished}}
|
||||
<input type="checkbox" data-on:click__prevent="@patch('{{url:todo}}?finished=1')">
|
||||
{{/finished}}
|
||||
{{#finished}}
|
||||
<input type="checkbox" checked data-on:click__prevent="@patch('{{url:todo}}')">
|
||||
{{/finished}}
|
||||
{{title}}
|
||||
<button data-on:click="@delete('{{url:todo}}')">delete</button>
|
||||
</div>
|
||||
19
05_todo_sse_datastar/todos.mustache.html
Normal file
@@ -0,0 +1,19 @@
|
||||
{{< layout}}
|
||||
{{$head}}
|
||||
{{> datastar }}
|
||||
{{/head}}
|
||||
{{$body}}
|
||||
<input type="text" placeholder="new todo" data-bind:title
|
||||
data-on:keydown="evt.key === 'Enter' && @post('{{url:todos}}') && ($title = '');"
|
||||
>
|
||||
<button data-on:click="@post('{{url:todos}}') && ($title = '')">add</button>
|
||||
<div id="todos" data-init="@get('{{url:todos}}?http_method=sse')">
|
||||
{{^todos_data}}
|
||||
<p>no todos</p>
|
||||
{{/todos_data}}
|
||||
{{#todos_data}}
|
||||
{{> todo_item}}
|
||||
{{/todos_data}}
|
||||
</div>
|
||||
{{/body}}
|
||||
{{/layout}}
|
||||
5
05_todo_sse_datastar/update_todo.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
update todos
|
||||
set finished = {{finished}}
|
||||
where user_id = {{user_id}}
|
||||
and id = {{id}}
|
||||
returning id, title, finished;
|
||||
52
06-middleware-scoping.svg
Normal file
@@ -0,0 +1,52 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 360" width="760" height="360">
|
||||
<rect width="760" height="360" fill="#09080f"/>
|
||||
<defs>
|
||||
<style>text{font-family:'JetBrains Mono','Fira Code',monospace}</style>
|
||||
</defs>
|
||||
|
||||
<!-- Outermost: Global .before / .after -->
|
||||
<rect x="30" y="20" width="700" height="310" rx="14" fill="#1a1328" stroke="#7c3aed" stroke-width="1.5"/>
|
||||
<text x="50" y="46" fill="#c084fc" font-size="11" font-weight="700">Global .before</text>
|
||||
<text x="50" y="62" fill="#9580b8" font-size="9">session()</text>
|
||||
<text x="610" y="46" fill="#c084fc" font-size="11" font-weight="700">Global .after</text>
|
||||
<text x="610" y="62" fill="#9580b8" font-size="9">call(log_request)</text>
|
||||
|
||||
<!-- Middle: Resource .before / .after -->
|
||||
<rect x="60" y="78" width="640" height="230" rx="12" fill="#111827" stroke="#3b82f6" stroke-width="1.5"/>
|
||||
<text x="80" y="102" fill="#60a5fa" font-size="11" font-weight="700">Resource .before</text>
|
||||
<text x="80" y="118" fill="#7b9ec9" font-size="9">logged_in()</text>
|
||||
<text x="570" y="102" fill="#60a5fa" font-size="11" font-weight="700">Resource .after</text>
|
||||
|
||||
<!-- Inner: Route pipeline -->
|
||||
<rect x="90" y="134" width="580" height="152" rx="10" fill="#0f0d1a" stroke="#06b6d4" stroke-width="1.5"/>
|
||||
<text x="110" y="158" fill="#22d3ee" font-size="11" font-weight="700">Route Pipeline — POST /todos</text>
|
||||
|
||||
<!-- Steps inside route -->
|
||||
<rect x="110" y="172" width="100" height="36" rx="6" fill="#1e293b" stroke="#3b82f6" stroke-width="0.75"/>
|
||||
<text x="160" y="194" text-anchor="middle" fill="#93c5fd" font-size="10" font-weight="600">param()</text>
|
||||
|
||||
<line x1="210" y1="190" x2="228" y2="190" stroke="#64748b" stroke-width="1.5"/>
|
||||
<polygon points="238,190 228,185 228,195" fill="#64748b"/>
|
||||
|
||||
<rect x="238" y="172" width="100" height="36" rx="6" fill="#1e293b" stroke="#8b5cf6" stroke-width="0.75"/>
|
||||
<text x="288" y="194" text-anchor="middle" fill="#c4b5fd" font-size="10" font-weight="600">db()</text>
|
||||
|
||||
<line x1="338" y1="190" x2="356" y2="190" stroke="#64748b" stroke-width="1.5"/>
|
||||
<polygon points="366,190 356,185 356,195" fill="#64748b"/>
|
||||
|
||||
<rect x="366" y="172" width="100" height="36" rx="6" fill="#1e293b" stroke="#f59e0b" stroke-width="0.75"/>
|
||||
<text x="416" y="194" text-anchor="middle" fill="#fcd34d" font-size="10" font-weight="600">emit()</text>
|
||||
|
||||
<line x1="466" y1="190" x2="484" y2="190" stroke="#64748b" stroke-width="1.5"/>
|
||||
<polygon points="494,190 484,185 484,195" fill="#64748b"/>
|
||||
|
||||
<rect x="494" y="172" width="100" height="36" rx="6" fill="#1e293b" stroke="#10b981" stroke-width="0.75"/>
|
||||
<text x="544" y="194" text-anchor="middle" fill="#6ee7b7" font-size="10" font-weight="600">redirect()</text>
|
||||
|
||||
<!-- Route .before / .after labels -->
|
||||
<text x="110" y="244" fill="#22d3ee" font-size="9">Route .before runs first inside this scope</text>
|
||||
<text x="110" y="260" fill="#22d3ee" font-size="9">Route .after runs last inside this scope</text>
|
||||
|
||||
<!-- Execution order arrows at bottom -->
|
||||
<text x="380" y="348" text-anchor="middle" fill="#64748b" font-size="10">Execution order: global .before → resource .before → route pipeline → resource .after → global .after</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
26
06_todo_events/activity/activity.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <mach.h>
|
||||
#include <sqlite.h>
|
||||
#include <pubsub.h>
|
||||
#include <session_auth.h>
|
||||
|
||||
void activity(){
|
||||
subscribe("todo_created", {
|
||||
sqlite_query({"activity_db", "insert_activity"})
|
||||
});
|
||||
|
||||
resource("activity", "/activity",
|
||||
.all = {logged_in()},
|
||||
.get = {
|
||||
sqlite_query({"activity_db", "get_activities", "activity"}),
|
||||
mustache("activity")
|
||||
}
|
||||
);
|
||||
|
||||
sqlite_database(
|
||||
.name = "activity_db",
|
||||
.connect = "file:activity.db?mode=rwc",
|
||||
.migrations = {"create_activity_table"}
|
||||
);
|
||||
|
||||
session_auth();
|
||||
}
|
||||
13
06_todo_events/activity/activity.mustache.html
Normal file
@@ -0,0 +1,13 @@
|
||||
{{< layout}}
|
||||
{{$body}}
|
||||
{{^activity}}
|
||||
<p>no activity</p>
|
||||
{{/activity}}
|
||||
{{#activity}}
|
||||
<p>activity</p>
|
||||
{{#.}}
|
||||
<p>{{action}}: {{title}} ({{created_at}})</p>
|
||||
{{/.}}
|
||||
{{/activity}}
|
||||
{{/body}}
|
||||
{{/layout}}
|
||||
8
06_todo_events/activity/create_activity_table.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
CREATE TABLE IF NOT EXISTS activity (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
action TEXT NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_activity_user_id ON activity(user_id);
|
||||
5
06_todo_events/activity/get_activities.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
select action, title, created_at
|
||||
from activity
|
||||
where user_id = {{user_id}}
|
||||
order by created_at desc
|
||||
limit 50;
|
||||
2
06_todo_events/activity/insert_activity.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
insert into activity(user_id, action, title)
|
||||
values({{user_id}}, 'created', {{title}});
|
||||
19
06_todo_events/main.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <mach.h>
|
||||
#include <session_auth.h>
|
||||
#include "todos/todos.c"
|
||||
#include "activity/activity.c"
|
||||
|
||||
void mach(){
|
||||
middleware(session());
|
||||
|
||||
resource("home", "/",
|
||||
.get = {mustache("home")}
|
||||
);
|
||||
|
||||
error(m_error, {mustache("5xx")});
|
||||
error(m_not_found, {mustache("404")});
|
||||
|
||||
todos();
|
||||
activity();
|
||||
session_auth();
|
||||
}
|
||||
0
06_todo_events/public/favicon.png
Normal file
5
06_todo_events/static/404.mustache.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{{< layout}}
|
||||
{{$body}}
|
||||
<p>not found</p>
|
||||
{{/body}}
|
||||
{{/layout}};
|
||||
5
06_todo_events/static/5xx.mustache.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{{< layout}}
|
||||
{{$body}}
|
||||
<p>error</p>
|
||||
{{/body}}
|
||||
{{/layout}};
|
||||
5
06_todo_events/static/home.mustache.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{{< layout}}
|
||||
{{$body}}
|
||||
<p>home</p>
|
||||
{{/body}}
|
||||
{{/layout}};
|
||||
20
06_todo_events/static/layout.mustache.html
Normal file
@@ -0,0 +1,20 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel='icon' href='{{asset:favicon.png}}'>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
{{^user}}
|
||||
<a href='{{url:login}}'>sign in</a>
|
||||
{{/user}}
|
||||
{{#user}}
|
||||
welcome, {{short_name}}
|
||||
{{/user}}
|
||||
</p>
|
||||
<nav>
|
||||
<a href='{{url:home}}'>home</a>
|
||||
</nav>
|
||||
{{$body}}
|
||||
{{/body}}
|
||||
</body>
|
||||
</html>
|
||||
2
06_todo_events/todos/create_todo.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
insert into todos(user_id, title)
|
||||
values({{user_id}}, {{title}});
|
||||
7
06_todo_events/todos/create_todos_table.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE IF NOT EXISTS todos (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
finished INTEGER CHECK(finished IN (1))
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_todos_user_id ON todos(user_id);
|
||||
3
06_todo_events/todos/delete_todo.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
delete from todos
|
||||
where user_id = {{user_id}}
|
||||
and id = {{id}};
|
||||
3
06_todo_events/todos/get_todos.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
select id, title, finished
|
||||
from todos
|
||||
where user_id = {{user_id}};
|
||||
50
06_todo_events/todos/todos.c
Normal file
@@ -0,0 +1,50 @@
|
||||
#include <mach.h>
|
||||
#include <sqlite.h>
|
||||
#include <pubsub.h>
|
||||
#include <session_auth.h>
|
||||
|
||||
void todos(){
|
||||
name("todos");
|
||||
|
||||
publish("todo_created",
|
||||
.with = {"user_id", "title"}
|
||||
);
|
||||
|
||||
resource("todos", "/todos",
|
||||
.all = {logged_in()},
|
||||
.get = {
|
||||
sqlite_query({"todos_db", "get_todos", "todos_data"}),
|
||||
mustache("todos")
|
||||
},
|
||||
.post = {
|
||||
input({"title", m_not_empty}),
|
||||
sqlite_query({"todos_db", "create_todo"}),
|
||||
emit("todo_created"),
|
||||
redirect("todos")
|
||||
}
|
||||
);
|
||||
|
||||
resource("todo", "/todos/:id",
|
||||
.all = {
|
||||
logged_in(),
|
||||
input({"id", m_positive})
|
||||
},
|
||||
.patch = {
|
||||
input({"finished", "1", "must be 1", .optional = true}),
|
||||
sqlite_query({"todos_db", "update_todo"}),
|
||||
redirect("todos")
|
||||
},
|
||||
.delete = {
|
||||
sqlite_query({"todos_db", "delete_todo"}),
|
||||
redirect("todos")
|
||||
}
|
||||
);
|
||||
|
||||
sqlite_database(
|
||||
.name = "todos_db",
|
||||
.connect = "file:todo.db?mode=rwc",
|
||||
.migrations = {"create_todos_table"}
|
||||
);
|
||||
|
||||
session_auth();
|
||||
}
|
||||
30
06_todo_events/todos/todos.mustache.html
Normal file
@@ -0,0 +1,30 @@
|
||||
{{< layout}}
|
||||
{{$body}}
|
||||
<form action="{{url:todos}}" method="post">
|
||||
<input type="text" name="title" placeholder="new todo" required>
|
||||
<button type="submit">add</button>
|
||||
</form>
|
||||
{{^todos_data}}
|
||||
<p>no todos</p>
|
||||
{{/todos_data}}
|
||||
{{#todos_data}}
|
||||
<div>
|
||||
<form action="{{url:todo}}" method="post" style="display:inline">
|
||||
<input type="hidden" name="http_method" value="patch">
|
||||
{{^finished}}
|
||||
<input type="checkbox" name="finished" value="1">
|
||||
{{/finished}}
|
||||
{{#finished}}
|
||||
<input type="checkbox" name="finished" value="1" checked>
|
||||
{{/finished}}
|
||||
{{title}}
|
||||
<button type="submit">save</button>
|
||||
</form>
|
||||
<form action="{{url:todo}}" method="post" style="display:inline">
|
||||
<input type="hidden" name="http_method" value="delete">
|
||||
<button type="submit">delete</button>
|
||||
</form>
|
||||
</div>
|
||||
{{/todos_data}}
|
||||
{{/body}}
|
||||
{{/layout}}
|
||||
4
06_todo_events/todos/update_todo.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
update todos
|
||||
set finished = {{finished}}
|
||||
where user_id = {{user_id}}
|
||||
and id = {{id}};
|
||||
50
07-context-scoping.svg
Normal file
@@ -0,0 +1,50 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 360" width="760" height="360">
|
||||
<rect width="760" height="360" fill="#09080f"/>
|
||||
<defs>
|
||||
<style>text{font-family:'JetBrains Mono','Fira Code',monospace}</style>
|
||||
</defs>
|
||||
|
||||
<!-- Outermost: Global .context -->
|
||||
<rect x="30" y="20" width="700" height="310" rx="14" fill="#1a1328" stroke="#7c3aed" stroke-width="1.5"/>
|
||||
<text x="50" y="46" fill="#c084fc" font-size="11" font-weight="700">Global .context</text>
|
||||
<text x="50" y="62" fill="#9580b8" font-size="9">base_layout, site_name</text>
|
||||
|
||||
<!-- Middle: Resource .context -->
|
||||
<rect x="60" y="78" width="640" height="230" rx="12" fill="#111827" stroke="#3b82f6" stroke-width="1.5"/>
|
||||
<text x="80" y="102" fill="#60a5fa" font-size="11" font-weight="700">Resource .context</text>
|
||||
<text x="80" y="118" fill="#7b9ec9" font-size="9">layout, sidebar</text>
|
||||
|
||||
<!-- Inner: Route pipeline -->
|
||||
<rect x="90" y="134" width="580" height="152" rx="10" fill="#0f0d1a" stroke="#06b6d4" stroke-width="1.5"/>
|
||||
<text x="110" y="158" fill="#22d3ee" font-size="11" font-weight="700">Route Pipeline — GET /todos</text>
|
||||
|
||||
<!-- Steps inside route -->
|
||||
<rect x="110" y="172" width="120" height="36" rx="6" fill="#1e293b" stroke="#8b5cf6" stroke-width="0.75"/>
|
||||
<text x="170" y="194" text-anchor="middle" fill="#c4b5fd" font-size="10" font-weight="600">db() → todos</text>
|
||||
|
||||
<line x1="230" y1="190" x2="258" y2="190" stroke="#64748b" stroke-width="1.5"/>
|
||||
<polygon points="268,190 258,185 258,195" fill="#64748b"/>
|
||||
|
||||
<rect x="268" y="172" width="120" height="36" rx="6" fill="#1e293b" stroke="#f59e0b" stroke-width="0.75"/>
|
||||
<text x="328" y="194" text-anchor="middle" fill="#fcd34d" font-size="10" font-weight="600">call() → count</text>
|
||||
|
||||
<line x1="388" y1="190" x2="416" y2="190" stroke="#64748b" stroke-width="1.5"/>
|
||||
<polygon points="426,190 416,185 416,195" fill="#64748b"/>
|
||||
|
||||
<rect x="426" y="172" width="120" height="36" rx="6" fill="#1e293b" stroke="#10b981" stroke-width="0.75"/>
|
||||
<text x="486" y="194" text-anchor="middle" fill="#6ee7b7" font-size="10" font-weight="600">render()</text>
|
||||
|
||||
<!-- Available context note -->
|
||||
<text x="110" y="237" fill="#22d3ee" font-size="9">render() sees: base_layout, site_name, layout, sidebar, todos, count</text>
|
||||
<text x="110" y="253" fill="#22d3ee" font-size="9">Context merges top-down; first named registration wins</text>
|
||||
|
||||
<!-- Cascade arrows on the left side -->
|
||||
<line x1="42" y1="68" x2="42" y2="78" stroke="#7c3aed" stroke-width="1.5" stroke-dasharray="3,2"/>
|
||||
<polygon points="42,84 38,76 46,76" fill="#7c3aed"/>
|
||||
|
||||
<line x1="72" y1="124" x2="72" y2="134" stroke="#3b82f6" stroke-width="1.5" stroke-dasharray="3,2"/>
|
||||
<polygon points="72,140 68,132 76,132" fill="#3b82f6"/>
|
||||
|
||||
<!-- Bottom summary -->
|
||||
<text x="380" y="348" text-anchor="middle" fill="#64748b" font-size="10">Context cascades: global .context → resource .context → pipeline steps add to context → render() merges all</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.9 KiB |
1
07_roundest_pokemon_htmx/README.md
Normal file
@@ -0,0 +1 @@
|
||||
compare to https://github.com/t3dotgg/1app5stacks
|
||||
7
07_roundest_pokemon_htmx/create_pokemons_table.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE IF NOT EXISTS pokemons (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
sprite TEXT NOT NULL,
|
||||
wins INTEGER NOT NULL DEFAULT 0,
|
||||
loses INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
4
07_roundest_pokemon_htmx/get_challengers.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
select id, name, sprite
|
||||
from pokemons
|
||||
order by random()
|
||||
limit 2;
|
||||
5
07_roundest_pokemon_htmx/get_results.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
select id, name, sprite, wins, loses,
|
||||
cast(wins as real) / nullif(loses, 0) as ratio_of_wins_to_loses,
|
||||
row_number() over (order by (cast(wins as real) / nullif(loses, 0)) desc) as rank
|
||||
from pokemons
|
||||
order by ratio_of_wins_to_loses desc;
|
||||
53
07_roundest_pokemon_htmx/home.mustache.html
Normal file
@@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Roundest (MaCH Version)</title>
|
||||
{{> htmx }}
|
||||
{{> tailwind }}
|
||||
</head>
|
||||
<body hx-boost='true'>
|
||||
<div class='bg-gray-950 text-white flex flex-col justify-between font-geist min-h-screen border-t-2 border-red-300'>
|
||||
<nav class='flex flex-row justify-between items-center py-4 px-8'>
|
||||
<div class='flex items-baseline'>
|
||||
<a href='{{url:home}}' class='font-bold text-3xl'>
|
||||
Round<span class='text-red-300'>est</span>
|
||||
</a>
|
||||
<p class='text-gray-400 font-extralight pl-2 text-2xl'>
|
||||
(MaCH Version)
|
||||
</p>
|
||||
</div>
|
||||
<div class='flex flex-row items-center gap-8'>
|
||||
<a href='{{url:results}}' class='hover:underline text-lg'>Results</a>
|
||||
</div>
|
||||
</nav>
|
||||
<main>
|
||||
{{$body}}
|
||||
<div class='container mx-auto px-4'>
|
||||
<h1 class='text-3xl font-bold text-center mb-8'>Vote for which is roundest</h1>
|
||||
<div class='flex justify-center gap-16 items-center min-h-[80vh]'>
|
||||
{{#challengers}}
|
||||
<form action='{{url:home}}' method='post'>
|
||||
<div class='flex flex-col items-center gap-4'>
|
||||
<img src='{{sprite}}' alt='{{name}}' class='w-64 h-64 sprite'>
|
||||
<div class='text-center'>
|
||||
<span class='text-gray-500 text-lg'>#{{id}}</span>
|
||||
<h2 class='text-2xl font-bold capitalize'>{{name}}</h2>
|
||||
<input type='hidden' name='winner' value='{{id}}'>
|
||||
<input type='hidden' name='loser' value='{{opponent_id}}'>
|
||||
<button class='mt-4 px-8 py-3 bg-blue-500 text-white rounded-lg text-lg font-semibold hover:bg-blue-600 transition-colors'>
|
||||
Vote
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{{/challengers}}
|
||||
</div>
|
||||
</div>
|
||||
{{/body}}
|
||||
</main>
|
||||
<footer class='font-light text-center py-3 text-gray-500'>
|
||||
<a href='https://code.nightshadecoder.dev/nightshade/mach_examples' target='_blank'>GitHub</a>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
45
07_roundest_pokemon_htmx/main.c
Normal file
@@ -0,0 +1,45 @@
|
||||
#include <mach.h>
|
||||
#include <htmx.h>
|
||||
#include <sqlite.h>
|
||||
#include <tailwind.h>
|
||||
|
||||
void mach(){
|
||||
resource("home", "/",
|
||||
.get = {
|
||||
sqlite_query({"pokemon_db", "get_challengers", "challengers"}),
|
||||
exec(^(){
|
||||
auto const t = get("challengers");
|
||||
auto const p0 = table_get(t, 0);
|
||||
auto const p1 = table_get(t, 1);
|
||||
record_set(p0, "opponent_id", record_get(p1, "id"));
|
||||
record_set(p1, "opponent_id", record_get(p0, "id"));
|
||||
}),
|
||||
mustache("home")
|
||||
},
|
||||
|
||||
.post = {
|
||||
input(
|
||||
{"winner", m_positive},
|
||||
{"loser", m_positive}
|
||||
),
|
||||
sqlite_query({"pokemon_db", "vote"}),
|
||||
reroute("home")
|
||||
}
|
||||
);
|
||||
|
||||
resource("result", "/results",
|
||||
.get = {
|
||||
sqlite_query({"pokemon_db", "get_results", "results"}),
|
||||
mustache("results")
|
||||
}
|
||||
);
|
||||
|
||||
sqlite_database(
|
||||
.name = "pokemon_db",
|
||||
.connect = "file::memory:?cache=shared",
|
||||
.migrations = {"create_pokemons_table.sql"}
|
||||
);
|
||||
|
||||
htmx();
|
||||
tailwind();
|
||||
}
|
||||
28
07_roundest_pokemon_htmx/results.mustache.html
Normal file
@@ -0,0 +1,28 @@
|
||||
{{< home}}
|
||||
{{$body}}
|
||||
<div class='container mx-auto px-4 py-8 text-white'>
|
||||
<div class='grid gap-4'>
|
||||
{{#results}}
|
||||
<div class='flex items-center gap-6 p-6 bg-gray-800/40 rounded-lg shadow hover:shadow-md transition-shadow'>
|
||||
<div class='text-2xl font-bold text-gray-400 w-8'>
|
||||
{{rank}}
|
||||
</div>
|
||||
<img src='{{sprite}}' alt='{{name}}' loading='lazy' class='w-20 h-20'>
|
||||
<div class='flex-grow'>
|
||||
<div class='text-gray-400 text-sm'>#{{id}}</div>
|
||||
<h2 class='text-xl font-semibold capitalize'>{{name}}</h2>
|
||||
</div>
|
||||
<div class='text-right'>
|
||||
<div class='text-2xl font-bold text-blue-400'>
|
||||
{{ratio_of_wins_to_loses}}
|
||||
</div>
|
||||
<div class='text-sm text-gray-400'>
|
||||
{{wins}}W - {{loses}}L
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/results}}
|
||||
</div>
|
||||
</div>
|
||||
{{/body}}
|
||||
{{/home}}
|
||||
8
07_roundest_pokemon_htmx/vote.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
begin transaction;
|
||||
update pokemons
|
||||
set wins = wins + 1
|
||||
where id = {{winner}};
|
||||
update pokemons
|
||||
set loses = loses + 1
|
||||
where id = {{loser}};
|
||||
commit;
|
||||
96
08-sse-datastar-flow.svg
Normal file
@@ -0,0 +1,96 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 400" width="760" height="400">
|
||||
<rect width="760" height="400" fill="#09080f"/>
|
||||
<defs>
|
||||
<linearGradient id="clientG" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color="#06b6d4"/>
|
||||
<stop offset="100%" stop-color="#0891b2"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="serverG" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color="#8b5cf6"/>
|
||||
<stop offset="100%" stop-color="#7c3aed"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="chanG" x1="0" y1="0" x2="1" y2="0">
|
||||
<stop offset="0%" stop-color="#f59e0b"/>
|
||||
<stop offset="50%" stop-color="#fbbf24"/>
|
||||
<stop offset="100%" stop-color="#f59e0b"/>
|
||||
</linearGradient>
|
||||
<style>text{font-family:'JetBrains Mono','Fira Code',monospace}</style>
|
||||
</defs>
|
||||
|
||||
<text x="380" y="28" text-anchor="middle" fill="#e2e8f0" font-size="13" font-weight="700">SSE / Datastar — Real-Time Push</text>
|
||||
|
||||
<!-- ===== Left: Client A (subscriber) ===== -->
|
||||
<rect x="30" y="50" width="180" height="80" rx="10" fill="#1e1b2e" stroke="#06b6d4" stroke-width="1.5"/>
|
||||
<rect x="30" y="50" width="180" height="32" rx="10" fill="url(#clientG)"/>
|
||||
<text x="120" y="71" text-anchor="middle" fill="#fff" font-size="11" font-weight="700">Client A</text>
|
||||
<text x="50" y="100" fill="#67e8f9" font-size="9">GET /todos</text>
|
||||
<text x="50" y="114" fill="#67e8f9" font-size="9">.sse channel connected</text>
|
||||
|
||||
<!-- ===== Left: Client B (subscriber) ===== -->
|
||||
<rect x="30" y="150" width="180" height="80" rx="10" fill="#1e1b2e" stroke="#06b6d4" stroke-width="1.5"/>
|
||||
<rect x="30" y="150" width="180" height="32" rx="10" fill="url(#clientG)"/>
|
||||
<text x="120" y="171" text-anchor="middle" fill="#fff" font-size="11" font-weight="700">Client B</text>
|
||||
<text x="50" y="200" fill="#67e8f9" font-size="9">GET /todos</text>
|
||||
<text x="50" y="214" fill="#67e8f9" font-size="9">.sse channel connected</text>
|
||||
|
||||
<!-- ===== Channel pill ===== -->
|
||||
<rect x="280" y="110" width="200" height="44" rx="22" fill="url(#chanG)"/>
|
||||
<text x="380" y="128" text-anchor="middle" fill="#1e1b2e" font-size="10" font-weight="700">Channel</text>
|
||||
<text x="380" y="143" text-anchor="middle" fill="#78350f" font-size="9">todos/{{user_id}}</text>
|
||||
|
||||
<!-- Arrows: clients → channel (subscribe) -->
|
||||
<line x1="210" y1="90" x2="270" y2="132" stroke="#06b6d4" stroke-width="1.5"/>
|
||||
<polygon points="280,132 270,127 268,137" fill="#06b6d4"/>
|
||||
<line x1="210" y1="190" x2="270" y2="132" stroke="#06b6d4" stroke-width="1.5"/>
|
||||
<polygon points="280,132 270,127 268,137" fill="#06b6d4"/>
|
||||
|
||||
<text x="220" y="86" fill="#475569" font-size="8">subscribe</text>
|
||||
<text x="220" y="198" fill="#475569" font-size="8">subscribe</text>
|
||||
|
||||
<!-- ===== Right: Server pipeline (POST) ===== -->
|
||||
<rect x="30" y="270" width="700" height="110" rx="12" fill="#0f0d1a" stroke="#7c3aed" stroke-width="1.5"/>
|
||||
<text x="50" y="296" fill="#c084fc" font-size="11" font-weight="700">POST /todos — another client submits a form</text>
|
||||
|
||||
<!-- Pipeline steps -->
|
||||
<rect x="50" y="310" width="90" height="32" rx="6" fill="#1e293b" stroke="#3b82f6" stroke-width="0.75"/>
|
||||
<text x="95" y="330" text-anchor="middle" fill="#93c5fd" font-size="9">param()</text>
|
||||
|
||||
<line x1="140" y1="326" x2="155" y2="326" stroke="#64748b" stroke-width="1"/>
|
||||
<polygon points="163,326 155,322 155,330" fill="#64748b"/>
|
||||
|
||||
<rect x="163" y="310" width="90" height="32" rx="6" fill="#1e293b" stroke="#8b5cf6" stroke-width="0.75"/>
|
||||
<text x="208" y="330" text-anchor="middle" fill="#c4b5fd" font-size="9">db()</text>
|
||||
|
||||
<line x1="253" y1="326" x2="268" y2="326" stroke="#64748b" stroke-width="1"/>
|
||||
<polygon points="276,326 268,322 268,330" fill="#64748b"/>
|
||||
|
||||
<!-- datastar / sse step highlighted -->
|
||||
<rect x="276" y="306" width="180" height="40" rx="6" fill="#451a03" stroke="#f59e0b" stroke-width="1.5"/>
|
||||
<text x="366" y="324" text-anchor="middle" fill="#fcd34d" font-size="10" font-weight="700">datastar() / sse()</text>
|
||||
<text x="366" y="339" text-anchor="middle" fill="#fbbf24" font-size="8">.channel = "todos/{{user_id}}"</text>
|
||||
|
||||
<!-- Arrow from datastar step up to channel -->
|
||||
<path d="M366,306 L366,280 L380,280 L380,162" stroke="#f59e0b" stroke-width="2" fill="none"/>
|
||||
<polygon points="380,154 375,162 385,162" fill="#f59e0b"/>
|
||||
|
||||
<text x="394" y="230" fill="#f59e0b" font-size="9" font-weight="600">push to channel</text>
|
||||
|
||||
<!-- Arrows: channel → clients (broadcast) -->
|
||||
<line x1="280" y1="125" x2="218" y2="94" stroke="#f59e0b" stroke-width="1.5" stroke-dasharray="4,3"/>
|
||||
<polygon points="210,90 218,89 216,99" fill="#f59e0b"/>
|
||||
|
||||
<line x1="280" y1="140" x2="218" y2="186" stroke="#f59e0b" stroke-width="1.5" stroke-dasharray="4,3"/>
|
||||
<polygon points="210,190 218,181 216,191" fill="#f59e0b"/>
|
||||
|
||||
<text x="222" y="110" fill="#92400e" font-size="8">broadcast</text>
|
||||
<text x="222" y="180" fill="#92400e" font-size="8">broadcast</text>
|
||||
|
||||
<!-- Datastar DOM update note -->
|
||||
<rect x="530" y="100" width="200" height="64" rx="8" fill="#111827" stroke="#1f2937" stroke-width="1"/>
|
||||
<text x="550" y="120" fill="#6b7280" font-size="9" font-weight="600">DATASTAR MODE</text>
|
||||
<text x="550" y="136" fill="#94a3b8" font-size="9">.target = "todos"</text>
|
||||
<text x="550" y="152" fill="#94a3b8" font-size="9">.mode = mode_prepend</text>
|
||||
|
||||
<!-- Footer -->
|
||||
<text x="380" y="396" text-anchor="middle" fill="#64748b" font-size="10">Without .channel, events push directly to the requesting client</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.4 KiB |
89
09-database-multi-tenancy.svg
Normal file
@@ -0,0 +1,89 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 340" width="760" height="340">
|
||||
<rect width="760" height="340" fill="#09080f"/>
|
||||
<defs>
|
||||
<linearGradient id="dbG" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color="#8b5cf6"/>
|
||||
<stop offset="100%" stop-color="#7c3aed"/>
|
||||
</linearGradient>
|
||||
<style>text{font-family:'JetBrains Mono','Fira Code',monospace}</style>
|
||||
</defs>
|
||||
|
||||
<text x="380" y="28" text-anchor="middle" fill="#e2e8f0" font-size="13" font-weight="700">Database Multi-Tenancy</text>
|
||||
|
||||
<!-- Config block -->
|
||||
<rect x="40" y="50" width="320" height="86" rx="10" fill="#111827" stroke="#1f2937" stroke-width="1"/>
|
||||
<text x="60" y="74" fill="#6b7280" font-size="9" font-weight="600">.databases config</text>
|
||||
<text x="60" y="96" fill="#c4b5fd" font-size="10">.connect =</text>
|
||||
<text x="60" y="114" fill="#fcd34d" font-size="10">"file:<tspan fill="#f59e0b" font-weight="700">{{user_id}}</tspan>_todo.db?mode=rwc"</text>
|
||||
|
||||
<!-- Arrow right -->
|
||||
<line x1="360" y1="93" x2="398" y2="93" stroke="#64748b" stroke-width="1.5"/>
|
||||
<polygon points="408,93 398,88 398,98" fill="#64748b"/>
|
||||
|
||||
<!-- Resolution box -->
|
||||
<rect x="408" y="50" width="180" height="86" rx="10" fill="#111827" stroke="#f59e0b" stroke-width="1"/>
|
||||
<text x="428" y="74" fill="#f59e0b" font-size="9" font-weight="600">RUNTIME RESOLUTION</text>
|
||||
<text x="428" y="96" fill="#94a3b8" font-size="10">user_id from</text>
|
||||
<text x="428" y="114" fill="#94a3b8" font-size="10">pipeline context</text>
|
||||
|
||||
<!-- Three request arrows going down -->
|
||||
<!-- User alice -->
|
||||
<rect x="40" y="170" width="180" height="36" rx="8" fill="#1e293b" stroke="#3b82f6" stroke-width="1"/>
|
||||
<text x="130" y="192" text-anchor="middle" fill="#93c5fd" font-size="10">Request: user_id = alice</text>
|
||||
|
||||
<!-- User bob -->
|
||||
<rect x="40" y="224" width="180" height="36" rx="8" fill="#1e293b" stroke="#3b82f6" stroke-width="1"/>
|
||||
<text x="130" y="246" text-anchor="middle" fill="#93c5fd" font-size="10">Request: user_id = bob</text>
|
||||
|
||||
<!-- User carol -->
|
||||
<rect x="40" y="278" width="180" height="36" rx="8" fill="#1e293b" stroke="#3b82f6" stroke-width="1"/>
|
||||
<text x="130" y="300" text-anchor="middle" fill="#93c5fd" font-size="10">Request: user_id = carol</text>
|
||||
|
||||
<!-- Arrows to databases -->
|
||||
<line x1="220" y1="188" x2="398" y2="188" stroke="#64748b" stroke-width="1"/>
|
||||
<polygon points="408,188 398,183 398,193" fill="#64748b"/>
|
||||
|
||||
<line x1="220" y1="242" x2="398" y2="242" stroke="#64748b" stroke-width="1"/>
|
||||
<polygon points="408,242 398,237 398,247" fill="#64748b"/>
|
||||
|
||||
<line x1="220" y1="296" x2="398" y2="296" stroke="#64748b" stroke-width="1"/>
|
||||
<polygon points="408,296 398,291 398,301" fill="#64748b"/>
|
||||
|
||||
<!-- Database: alice -->
|
||||
<rect x="408" y="170" width="220" height="36" rx="8" fill="#2d2640" stroke="#8b5cf6" stroke-width="1.5"/>
|
||||
<text x="440" y="192" fill="#c4b5fd" font-size="10">file:</text>
|
||||
<text x="472" y="192" fill="#fcd34d" font-size="10" font-weight="700">alice</text>
|
||||
<text x="505" y="192" fill="#c4b5fd" font-size="10">_todo.db</text>
|
||||
|
||||
<!-- Database: bob -->
|
||||
<rect x="408" y="224" width="220" height="36" rx="8" fill="#2d2640" stroke="#8b5cf6" stroke-width="1.5"/>
|
||||
<text x="440" y="246" fill="#c4b5fd" font-size="10">file:</text>
|
||||
<text x="472" y="246" fill="#fcd34d" font-size="10" font-weight="700">bob</text>
|
||||
<text x="495" y="246" fill="#c4b5fd" font-size="10">_todo.db</text>
|
||||
|
||||
<!-- Database: carol -->
|
||||
<rect x="408" y="278" width="220" height="36" rx="8" fill="#2d2640" stroke="#8b5cf6" stroke-width="1.5"/>
|
||||
<text x="440" y="300" fill="#c4b5fd" font-size="10">file:</text>
|
||||
<text x="472" y="300" fill="#fcd34d" font-size="10" font-weight="700">carol</text>
|
||||
<text x="505" y="300" fill="#c4b5fd" font-size="10">_todo.db</text>
|
||||
|
||||
<!-- DB icons (simple cylinder shapes) -->
|
||||
<g transform="translate(648, 170)">
|
||||
<ellipse cx="18" cy="6" rx="18" ry="6" fill="#7c3aed" opacity="0.5"/>
|
||||
<rect x="0" y="6" width="36" height="24" fill="#7c3aed" opacity="0.3"/>
|
||||
<ellipse cx="18" cy="30" rx="18" ry="6" fill="#7c3aed" opacity="0.5"/>
|
||||
</g>
|
||||
<g transform="translate(648, 224)">
|
||||
<ellipse cx="18" cy="6" rx="18" ry="6" fill="#7c3aed" opacity="0.5"/>
|
||||
<rect x="0" y="6" width="36" height="24" fill="#7c3aed" opacity="0.3"/>
|
||||
<ellipse cx="18" cy="30" rx="18" ry="6" fill="#7c3aed" opacity="0.5"/>
|
||||
</g>
|
||||
<g transform="translate(648, 278)">
|
||||
<ellipse cx="18" cy="6" rx="18" ry="6" fill="#7c3aed" opacity="0.5"/>
|
||||
<rect x="0" y="6" width="36" height="24" fill="#7c3aed" opacity="0.3"/>
|
||||
<ellipse cx="18" cy="30" rx="18" ry="6" fill="#7c3aed" opacity="0.5"/>
|
||||
</g>
|
||||
|
||||
<!-- Footer -->
|
||||
<text x="380" y="336" text-anchor="middle" fill="#64748b" font-size="10">One config, per-user databases — Mustache interpolation in .connect at runtime</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.7 KiB |
82
10-boot-time-compilation.svg
Normal file
@@ -0,0 +1,82 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 300" width="760" height="300">
|
||||
<rect width="760" height="300" fill="#09080f"/>
|
||||
<defs>
|
||||
<linearGradient id="bootG" x1="0" y1="0" x2="1" y2="0">
|
||||
<stop offset="0%" stop-color="#7c3aed"/>
|
||||
<stop offset="100%" stop-color="#a855f7"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="warmG" x1="0" y1="0" x2="1" y2="0">
|
||||
<stop offset="0%" stop-color="#f59e0b"/>
|
||||
<stop offset="100%" stop-color="#fbbf24"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="runG" x1="0" y1="0" x2="1" y2="0">
|
||||
<stop offset="0%" stop-color="#10b981"/>
|
||||
<stop offset="100%" stop-color="#34d399"/>
|
||||
</linearGradient>
|
||||
<style>text{font-family:'JetBrains Mono','Fira Code',monospace}</style>
|
||||
</defs>
|
||||
|
||||
<text x="380" y="28" text-anchor="middle" fill="#e2e8f0" font-size="13" font-weight="700">Boot-Time Compilation</text>
|
||||
|
||||
<!-- Phase 1: config() -->
|
||||
<rect x="30" y="50" width="200" height="110" rx="10" fill="#1e1b2e" stroke="#7c3aed" stroke-width="1.5"/>
|
||||
<rect x="30" y="50" width="200" height="32" rx="10" fill="url(#bootG)"/>
|
||||
<text x="130" y="71" text-anchor="middle" fill="#fff" font-size="11" font-weight="700">config mach()</text>
|
||||
<text x="50" y="96" fill="#c4b5fd" font-size="9">.includes</text>
|
||||
<text x="50" y="112" fill="#c4b5fd" font-size="9">.databases</text>
|
||||
<text x="50" y="128" fill="#c4b5fd" font-size="9">.resources</text>
|
||||
<text x="50" y="144" fill="#c4b5fd" font-size="9">.events / .errors</text>
|
||||
|
||||
<!-- Arrow 1 -->
|
||||
<line x1="230" y1="105" x2="268" y2="105" stroke="#64748b" stroke-width="1.5"/>
|
||||
<polygon points="278,105 268,100 268,110" fill="#64748b"/>
|
||||
|
||||
<!-- Phase 2: Precompile -->
|
||||
<rect x="278" y="50" width="200" height="110" rx="10" fill="#1e1b2e" stroke="#f59e0b" stroke-width="1.5"/>
|
||||
<rect x="278" y="50" width="200" height="32" rx="10" fill="url(#warmG)"/>
|
||||
<text x="378" y="71" text-anchor="middle" fill="#1e1b2e" font-size="11" font-weight="700">Precompile</text>
|
||||
<text x="298" y="96" fill="#fcd34d" font-size="9">Compile pipelines</text>
|
||||
<text x="298" y="112" fill="#fcd34d" font-size="9">Compile templates</text>
|
||||
<text x="298" y="128" fill="#fcd34d" font-size="9">Prepare SQL statements</text>
|
||||
<text x="298" y="144" fill="#fcd34d" font-size="9">Build route table</text>
|
||||
|
||||
<!-- Arrow 2 -->
|
||||
<line x1="478" y1="105" x2="516" y2="105" stroke="#64748b" stroke-width="1.5"/>
|
||||
<polygon points="526,105 516,100 516,110" fill="#64748b"/>
|
||||
|
||||
<!-- Phase 3: Execution Graph -->
|
||||
<rect x="526" y="50" width="200" height="110" rx="10" fill="#1e1b2e" stroke="#10b981" stroke-width="1.5"/>
|
||||
<rect x="526" y="50" width="200" height="32" rx="10" fill="url(#runG)"/>
|
||||
<text x="626" y="71" text-anchor="middle" fill="#fff" font-size="11" font-weight="700">Execution Graph</text>
|
||||
<text x="546" y="96" fill="#6ee7b7" font-size="9">Pre-warmed pipelines</text>
|
||||
<text x="546" y="112" fill="#6ee7b7" font-size="9">Optimized query plans</text>
|
||||
<text x="546" y="128" fill="#6ee7b7" font-size="9">Compiled templates</text>
|
||||
<text x="546" y="144" fill="#6ee7b7" font-size="9">Ready to serve</text>
|
||||
|
||||
<!-- Phase labels -->
|
||||
<text x="130" y="180" text-anchor="middle" fill="#7c3aed" font-size="9" font-weight="600">RUNS ONCE AT BOOT</text>
|
||||
<text x="378" y="180" text-anchor="middle" fill="#f59e0b" font-size="9" font-weight="600">RUNS ONCE AT BOOT</text>
|
||||
<text x="626" y="180" text-anchor="middle" fill="#10b981" font-size="9" font-weight="600">SERVES ALL REQUESTS</text>
|
||||
|
||||
<!-- Runtime section -->
|
||||
<rect x="30" y="200" width="696" height="76" rx="10" fill="#0f0d1a" stroke="#10b981" stroke-width="1" stroke-dasharray="5,3"/>
|
||||
<text x="50" y="224" fill="#6ee7b7" font-size="10" font-weight="600">Runtime: each request executes a pre-warmed pipeline</text>
|
||||
|
||||
<!-- Request arrows -->
|
||||
<text x="50" y="248" fill="#475569" font-size="9">req →</text>
|
||||
<rect x="90" y="236" width="80" height="24" rx="4" fill="#1e293b" stroke="#10b981" stroke-width="0.75"/>
|
||||
<text x="130" y="252" text-anchor="middle" fill="#6ee7b7" font-size="9">pipeline</text>
|
||||
<line x1="170" y1="248" x2="184" y2="248" stroke="#10b981" stroke-width="1"/>
|
||||
<polygon points="192,248 184,244 184,252" fill="#10b981"/>
|
||||
<text x="200" y="252" fill="#475569" font-size="9">→ response</text>
|
||||
|
||||
<text x="320" y="248" fill="#475569" font-size="9">req →</text>
|
||||
<rect x="360" y="236" width="80" height="24" rx="4" fill="#1e293b" stroke="#10b981" stroke-width="0.75"/>
|
||||
<text x="400" y="252" text-anchor="middle" fill="#6ee7b7" font-size="9">pipeline</text>
|
||||
<line x1="440" y1="248" x2="454" y2="248" stroke="#10b981" stroke-width="1"/>
|
||||
<polygon points="462,248 454,244 454,252" fill="#10b981"/>
|
||||
<text x="470" y="252" fill="#475569" font-size="9">→ response</text>
|
||||
|
||||
<!-- Footer -->
|
||||
<text x="380" y="296" text-anchor="middle" fill="#64748b" font-size="10">Zero per-request compilation — config builds the graph, requests just execute it</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
674
COPYING
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
165
COPYING.LESSER
Normal file
@@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
165
LICENSE
Normal file
@@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||