Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienos.com/blob/main/crates/site-builder/src/components/engineer.rs # aienos.com Source of www.aienos.com, served from my own hardware Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienos.com / crates / site-builder / src / components / engineer.rs` 215 lines ยท 9013 bytes Raw Blame History 1 //! About the engineer (/engineer/): who builds AienOS. drakestapleton.com was 2 //! merged into this section on 2026-10-26; its old addresses redirect here. 3 //! 4 //! The pages live in `public/data/engineer.json` (published as 5 //! /data/engineer.json): each page has its path, the drakestapleton.com 6 //! paths that now point at it, a title, a description and its body. Two 7 //! placeholders in a body are filled from facts.json at build time: 8 //! `` (the AIEN-today block) and `` 9 //! (the Spark judge's verdict card). Styles are in /assets/engineer.css. 10 11 use std::fs; 12 use std::path::Path; 13 14 use maud::{html, Markup, PreEscaped}; 15 use serde::Deserialize; 16 17 use crate::facts::Facts; 18 use crate::layouts::base::render_page_layout; 19 20 pub const RAW: &str = include_str!("../../../../public/data/engineer.json"); 21 const FACTS_URL: &str = "https://www.aienos.com/facts.json"; 22 const LIVE: &str = ""; 23 const VERDICT: &str = ""; 24 25 #[derive(Deserialize)] 26 pub struct Page { 27 pub path: String, 28 pub name: String, 29 pub old: Vec, 30 pub title: String, 31 pub description: String, 32 pub kind: String, 33 pub body_html: String, 34 } 35 36 #[derive(Deserialize)] 37 struct Data { 38 pages: Vec, 39 } 40 41 pub fn pages() -> Vec { 42 serde_json::from_str::(RAW).expect("public/data/engineer.json").pages 43 } 44 45 /// Subpages carry one quiet way back; there is no section bar. 46 fn back_link() -> Markup { 47 html! { 48 p class="engineer-back" { a href="/engineer/" { "About the engineer" } } 49 } 50 } 51 52 /// The foot of /engineer/: every page of the section, from the data file. 53 fn index(all: &[Page]) -> Markup { 54 html! { 55 section class="engineer-index" id="index" aria-labelledby="engineer-index-title" { 56 h2 id="engineer-index-title" { "Everything in this section" } 57 ul { 58 @for p in all.iter().filter(|p| p.kind != "home") { 59 li { a href=(p.path) { (p.name) } " " span { (p.description) } } 60 } 61 } 62 } 63 } 64 } 65 66 fn verdict_word(state: &str, description: &str) -> &'static str { 67 match state { 68 "success" => "PASS", 69 "failure" if description.starts_with("BLOCKED") && description.contains("NOT_RUN") => "BLOCKED", 70 "failure" => "FAIL", 71 "pending" => "RUNNING", 72 _ => "NO VERDICT", 73 } 74 } 75 76 fn verdict_card(facts: &Facts) -> Markup { 77 let r = &facts.receipt; 78 html! { 79 div class="stat-card" { 80 p class={ "stat-value tabular-nums verdict-" (r.state) } { (verdict_word(&r.state, &r.description)) } 81 p class="stat-unit" { "Spark judge, sovereign core" } 82 p class="stat-label" { 83 "Verdict for commit " (&r.sha[..r.sha.len().min(7)]) " of the host runtime: " (r.description) ". " 84 @if !r.target_url.is_empty() { a href=(r.target_url) { "Receipt" } } 85 } 86 } 87 } 88 } 89 90 fn live_block(facts: &Facts) -> Markup { 91 html! { 92 section class="live-record" id="live" { 93 h2 { "Aien today" } 94 p { 95 "This block is not typed by hand. It is read from the record " 96 a href=(FACTS_URL) { "facts.json" } 97 ", gathered from GitHub and published with reviewed releases." 98 } 99 div class="grid stats-grid" { (verdict_card(facts)) } 100 @if !facts.components.is_empty() { 101 table class="live-table" { 102 thead { tr { th { "Component" } th { "Last merged change" } th { "Open proposals" } } } 103 tbody { 104 @for c in &facts.components { 105 tr { 106 td { 107 @if c.url.is_empty() { (c.name) } @else { a href=(c.url) { (c.name) } } 108 } 109 td { 110 @match &c.last_merge { 111 Some(m) if !m.url.is_empty() => { a href=(m.url) { (m.title) } (crate::forge::receipt_code(&m.url)) }, 112 Some(m) => (m.title), 113 None => "none recorded", 114 } 115 } 116 td class="tabular-nums" { (c.open_prs) } 117 } 118 } 119 } 120 } 121 } 122 p class="live-generated" { "Record generated " (facts.generated_at) "." } 123 } 124 } 125 } 126 127 pub fn render(page: &Page, all: &[Page], facts: &Facts) -> Markup { 128 let body = page 129 .body_html 130 .replace(LIVE, &live_block(facts).into_string()) 131 .replace(VERDICT, &verdict_card(facts).into_string()); 132 html! { 133 div class="engineer" { 134 @if page.kind != "home" { (back_link()) } 135 (PreEscaped(body)) 136 @if page.kind == "home" { (index(all)) } 137 } 138 } 139 } 140 141 /// Writes every page of the section into dist. 142 pub fn emit(dist: &Path, facts: &Facts) { 143 let all = pages(); 144 for page in &all { 145 let head = html! { 146 link rel="stylesheet" href="/assets/engineer.css"; 147 @if page.kind == "infographic" { link rel="stylesheet" href="/assets/engineer-infographic.css"; } 148 @if page.kind == "home" { script defer src="/js/engineer-universe.js" {} } 149 }; 150 let og_type = if page.kind == "work" { "article" } else { "website" }; 151 let doc = render_page_layout( 152 &page.title, 153 &page.description, 154 &format!("https://www.aienos.com{}", page.path), 155 og_type, 156 head, 157 render(page, &all, facts), 158 ); 159 let dir = dist.join(page.path.trim_start_matches('/')); 160 fs::create_dir_all(&dir).expect("create engineer page directory"); 161 fs::write(dir.join("index.html"), doc.into_string()).expect("write engineer page"); 162 } 163 println!(" [PAGE] Emitted /engineer/ ({} pages, merged from drakestapleton.com)", all.len()); 164 } 165 166 /// The section is whole: every page written, both placeholders filled, no 167 /// outside resource, every old drakestapleton.com path mapped exactly once, 168 /// and every internal link inside the section resolving to a written file. 169 pub fn verify(dist: &Path) { 170 let all = pages(); 171 let mut olds = std::collections::HashSet::new(); 172 for page in &all { 173 assert!(page.path.starts_with("/engineer/") && page.path.ends_with('/'), "engineer path {}", page.path); 174 assert!(!page.old.is_empty(), "{} lists no old drakestapleton.com path", page.path); 175 for o in &page.old { 176 assert!(olds.insert(o.clone()), "old path {o} maps to two engineer pages"); 177 } 178 let html = fs::read_to_string(dist.join(page.path.trim_start_matches('/')).join("index.html")) 179 .unwrap_or_else(|_| panic!("missing {}", page.path)); 180 for bad in [LIVE, VERDICT, "drakestapleton.com/", "i.ytimg.com", "formsubmit.co", "fonts.googleapis.com", "\u{2014}", "\u{2013}"] { 181 assert!(!html.contains(bad), "{} contains {bad:?}", page.path); 182 } 183 assert!(page.kind == "home" || html.contains("class=\"engineer-back\""), "{} lacks its way back to /engineer/", page.path); 184 for src in html.split("src=\"").skip(1).filter_map(|s| s.split('"').next()) { 185 assert!(src.starts_with('/') && !src.starts_with("//"), "{} loads an outside resource: {src}", page.path); 186 } 187 for href in html.split("href=\"").skip(1).filter_map(|s| s.split('"').next()) { 188 let target = href.split('#').next().unwrap_or(""); 189 if target.starts_with("/engineer/") { 190 let file = dist.join(target.trim_start_matches('/')); 191 let file = if target.ends_with('/') { file.join("index.html") } else { file }; 192 assert!(file.exists(), "{} links {href}, which was not written", page.path); 193 } 194 } 195 } 196 for must in ["/", "/glossary", "/works", "/path", "/symphony/map", "/works/aien", "/aien", "/infographics/chatgpt-vs-aien"] { 197 assert!(olds.contains(must), "no engineer page takes over drakestapleton.com{must}"); 198 } 199 let learn = fs::read_to_string(dist.join("learn/index.html")).expect("read learn page"); 200 assert!(learn.contains("href=\"/engineer/\""), "/learn/ must link About the engineer"); 201 println!(" About the engineer: {} pages, {} old drakestapleton.com paths mapped", all.len(), olds.len()); 202 } 203 204 #[cfg(test)] 205 mod tests { 206 use super::*; 207 208 #[test] 209 fn every_page_parses_and_the_home_carries_the_live_block() { 210 let all = pages(); 211 assert!(all.iter().any(|p| p.path == "/engineer/" && p.body_html.contains(LIVE))); 212 assert!(all.iter().any(|p| p.path == "/engineer/evidence/" && p.body_html.contains(VERDICT))); 213 assert!(all.iter().any(|p| p.path == "/engineer/glossary/")); 214 } 215 }