code wiki / _hdl_build / nx_ad_offering.nx
nx_ad_offering.nx source
↩ module page · 72 lines · 4514 B
1// nx_ad_offering.nx -- LIB: the public, pre-login OFFERING SHEET / sell page for the performance
2// ad engine (ADS-017, CALLOUT-004) -- "the artifact we hand a prospect to start selling." Emits
3// the sell copy (spec sec12) as a clean, first-party page whose PRICING IS PULLED FROM THE
4// SOVEREIGN STORE (adgoal:/adpricing:), never hardcoded marketing copy with stale numbers (rule 11,
5// spec sec12). Re-seed the figures -> the page updates, no edit.
6//
7// Composes the foundations: nx_ad_serve (clean emit, HTML-escape, zero-third-party-JS) + the store
8// figure readers (am_target_of / ab_perform_fee_of / ab_exceed_bonus_of). license_tier: ORIGINAL
9import "nx_ad_meter.nx"
10import "nx_ad_bill.nx"
11import "nx_ad_serve.nx"
12import "nx_ad_store.nx"
13import "nx_syscalls.nx"
14
15// append a non-negative int's decimal text; returns new offset.
16func on_num(dst: *u8, off: i64, v: i64) -> i64 {
17 if v == 0 { dst[off] = 48 as u8; return off + 1 }
18 var m: i64 = v
19 let t: *u8 = sys_mmap(28)
20 var k: i64 = 0
21 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
22 var o: i64 = off
23 var i: i64 = 0
24 while i < k { dst[o] = t[k - 1 - i]; o = o + 1; i = i + 1 }
25 return o
26}
27
28// "$N", or "(pending)" for an unset (-1) figure -- the page is honest about staging gaps.
29func on_money(dst: *u8, off: i64, v: i64) -> i64 {
30 if v < 0 { return as_append(dst, off, "(pending)" as *u8) }
31 let o: i64 = as_append(dst, off, "$" as *u8)
32 return on_num(dst, o, v)
33}
34
35// one pricing row, every figure read LIVE from the store (rule 11).
36func on_goal_row(dst: *u8, off: i64, label: *u8, goal_key: *u8, price_key: *u8) -> i64 {
37 let target: i64 = am_target_of(goal_key)
38 let fee: i64 = ab_perform_fee_of(price_key)
39 let bonus: i64 = ab_exceed_bonus_of(price_key)
40 var o: i64 = off
41 o = as_append(dst, o, "<tr><td>" as *u8)
42 o = as_append(dst, o, label)
43 o = as_append(dst, o, "</td><td>" as *u8)
44 if target < 0 { o = as_append(dst, o, "(pending census)" as *u8) } else { o = on_num(dst, o, target) }
45 o = as_append(dst, o, "</td><td>" as *u8)
46 o = on_money(dst, o, fee)
47 o = as_append(dst, o, "</td><td>+" as *u8)
48 o = on_money(dst, o, bonus)
49 o = as_append(dst, o, "</td><td>" as *u8)
50 if fee < 0 { o = as_append(dst, o, "(pending)" as *u8) } else {
51 if bonus < 0 { o = as_append(dst, o, "(pending)" as *u8) } else { o = on_money(dst, o, fee + bonus) }
52 }
53 o = as_append(dst, o, "</td></tr>" as *u8)
54 return o
55}
56
57// emit the full pre-login offering sheet; returns byte length (NUL-terminated). Clean first-party
58// HTML, zero third-party JS. Figures come from the store.
59func on_emit(out: *u8) -> i64 {
60 var o: i64 = 0
61 o = as_append(out, o, "<main class='nishi-offering'><h1>Brought to you by you.</h1><p class='lede'>Sponsor the web people actually love — and only pay when it works.</p>" as *u8)
62 o = as_append(out, o, "<section class='promise'><ul><li>Miss the goal you picked — you pay <strong>$0</strong>.</li><li>Hit it — one <strong>flat fee</strong>.</li><li>Beat it — add one <strong>flat, capped bonus</strong>; you always know your ceiling.</li></ul></section>" as *u8)
63 o = as_append(out, o, "<section class='pricing'><h2>Pick a goal</h2><table><thead><tr><th>Goal</th><th>Target / period</th><th>Perform fee</th><th>Exceed bonus</th><th>Your ceiling</th></tr></thead><tbody>" as *u8)
64 o = on_goal_row(out, o, "Reach (impressions)" as *u8, "adgoal:reach" as *u8, "adpricing:reach" as *u8)
65 o = on_goal_row(out, o, "Leads (conversions)" as *u8, "adgoal:leads" as *u8, "adpricing:leads" as *u8)
66 o = on_goal_row(out, o, "Sales (conversions)" as *u8, "adgoal:sales" as *u8, "adpricing:sales" as *u8)
67 o = as_append(out, o, "</tbody></table><p class='note'>Prices are staging defaults — your sponsorship is co-spec'd before launch.</p></section>" as *u8)
68 o = as_append(out, o, "<section class='why'><h2>Why it's different</h2><p>No ad-tech middlemen, no auctions, no third-party JavaScript, no cross-site profiles, no data hostages. We measure results in aggregate and never track your customers as individuals. Your bill is capped — a viral month never becomes a surprise invoice.</p></section>" as *u8)
69 o = as_append(out, o, "<section class='start'><h2>How to start</h2><p>Pick a goal → set your flat fee → go live on staging → we measure → you pay only on results.</p></section></main>" as *u8)
70 out[o] = 0 as u8
71 return o
72}