code wiki / _hdl_build / nx_site_import_gate.nx
nx_site_import_gate.nx source
↩ module page · 61 lines · 3943 B
1// nx_site_import_gate.nx -- import a foreign (lock-in-platform) page: content captured, third-party tracking STRIPPED,
2// portable sovereign blueprint emitted. The exceed is a CAPABILITY (migrate TO us from anywhere) incumbents lack.
3// 100% sovereign. expect_exit: 0
4import "nx_syscalls.nx"
5import "nx_sitegate_emit_lib.nx"
6import "nx_site_import.nx"
7import "nx_exceed_standard.nx"
8import "nx_brand_tokens.nx"
9
10// gw/gn/t_row shared via nx_sitegate_emit_lib.nx (rule-15 extraction, 2nd consumer)
11func has(s: *u8, n: i64, lit: *u8) -> i64 { if bt_find(s, n, lit, bt_len(lit)) >= 0 { return 1 } return 0 }
12func slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
13
14func main() -> i64 {
15 let tot: *i64 = sys_mmap(32) as *i64
16 tot[0]=0; tot[1]=0
17 // a foreign export: tracking scripts + inline divs + headings/paragraphs/link
18 let foreign: *u8 = "<!doctype html><html><head><title>Acme Plumbing</title><script>track(7)</script></head><body><div><h1>Acme Plumbing</h1><p>We fix leaks fast in your area.</p><h2>Services</h2><p>Drains and water heaters.</p><a href=/contact>Contact us</a></div><script>more(9)</script></body></html>" as *u8
19 let fn: i64 = slen(foreign)
20 gw("=== nx_site_import_gate -- migrate a foreign (lock-in) site -> portable sovereign blueprint ===\n" as *u8)
21
22 // I1: content extracted, tracking stripped
23 let txt: *u8 = sys_mmap(65536)
24 let tn: i64 = mi_strip_tags(foreign, fn, txt, 65536)
25 var i1: i64 = 0
26 if has(txt, tn, "We fix leaks fast" as *u8) == 1 { if has(txt, tn, "Drains and water heaters" as *u8) == 1 { if has(txt, tn, "track" as *u8) == 0 { if has(txt, tn, "more(9)" as *u8) == 0 { i1 = 1 } } } }
27 t_row("I1 content captured (headings+paragraphs), tracking scripts STRIPPED" as *u8, i1, tot)
28
29 // I2: structure identified
30 let nh: i64 = mi_count(foreign, fn, "<h1" as *u8) + mi_count(foreign, fn, "<h2" as *u8) + mi_count(foreign, fn, "<h3" as *u8)
31 let np: i64 = mi_count(foreign, fn, "<p" as *u8)
32 let na: i64 = mi_count(foreign, fn, "<a " as *u8)
33 gw(" structure: headings=" as *u8); gn(nh); gw(" paragraphs=" as *u8); gn(np); gw(" links=" as *u8); gn(na); gw("\n" as *u8)
34 var i2: i64 = 0; if nh == 2 { if np == 2 { if na == 1 { i2 = 1 } } }
35 t_row("I2 structure identified (2 headings, 2 paragraphs, 1 link)" as *u8, i2, tot)
36
37 // I3: portable sovereign blueprint emitted (title + content, 0 script/tracking)
38 let fd: i64 = sys_openat_wr("/tmp/nx_import.site" as *u8, 0x1a4)
39 mi_to_blueprint(foreign, fn, fd); sys_close(fd)
40 let lp: *i64 = sys_mmap(16) as *i64
41 let bp: *u8 = sys_read_file("/tmp/nx_import.site" as *u8, lp)
42 let bn: i64 = lp[0]
43 var i3: i64 = 0
44 if has(bp, bn, "site|title|Acme Plumbing" as *u8) == 1 { if has(bp, bn, "block|content|" as *u8) == 1 { if has(bp, bn, "<script" as *u8) == 0 { if has(bp, bn, "track" as *u8) == 0 { i3 = 1 } } } }
45 t_row("I3 portable blueprint emitted: title+content, 0 <script, 0 tracking (sovereign)" as *u8, i3, tot)
46
47 // I4: the CAPABILITY exceed -- we IMPORT a competitor's site; lock-in platforms can't export/import one
48 var ours: i64 = 0; if i1 == 1 { if i3 == 1 { ours = 1 } }
49 let cx: i64 = es_is_sclass_exceed(ES_CAPABILITY, ES_CUSTOMER, ours, 0, 1)
50 t_row("I4 CAPABILITY exceed: migrate-TO-us from any platform (vs Wix no-export / lock-in)" as *u8, cx, tot)
51
52 // self-test: the stripper really removes script bodies (discriminates)
53 var st: i64 = 0
54 if has(txt, tn, "track" as *u8) == 0 { st = 1 }
55 t_row("S1 self-test: script body 'track(7)' absent from extracted content" as *u8, st, tot)
56
57 gw("\nrows pass=" as *u8); gn(tot[0]); gw(" fail=" as *u8); gn(tot[1]); gw("\n" as *u8)
58 if tot[1] == 0 { gw("VERDICT=GREEN -- migration importer: ingest a foreign site -> portable sovereign blueprint. A no-lock-in CAPABILITY, not architecture.\n" as *u8); return 0 }
59 gw("VERDICT=RED\n" as *u8)
60 return 1
61}