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/sovereign-intelligence/blob/main/docs/archive/drakestapleton.com-old/crates/site-builder/src/main.rs # sovereign-intelligence Front door to Drake Stapleton's sovereign stack. 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 `sovereign-intelligence / docs / archive / drakestapleton.com-old / crates / site-builder / src / main.rs` 181 lines ยท 6528 bytes Raw Blame History 1 use std::collections::HashMap; 2 use std::fs; 3 use std::path::Path; 4 use std::time::Instant; 5 6 #[derive(serde::Deserialize)] 7 struct PageMeta { 8 title: String, 9 #[allow(dead_code)] 10 description: String, 11 } 12 13 fn generate_sitemap_and_robots(dist: &Path, public_routes: &[(&str, &str)]) { 14 let mut sitemap = String::from("\n\n"); 15 for (route, priority) in public_routes { 16 sitemap.push_str(&format!( 17 " https://www.drakestapleton.com{}{}\n", 18 route, priority 19 )); 20 } 21 sitemap.push_str("\n"); 22 23 let sitemap_path = dist.join("sitemap.xml"); 24 fs::write(&sitemap_path, sitemap).expect("Failed to write sitemap.xml"); 25 26 let robots = "User-agent: *\nAllow: /\nSitemap: https://www.drakestapleton.com/sitemap.xml\nLLMs: https://www.drakestapleton.com/llms.txt\n"; 27 let robots_path = dist.join("robots.txt"); 28 fs::write(&robots_path, robots).expect("Failed to write robots.txt"); 29 30 println!(" [GEN] Emitted native sitemap.xml and robots.txt in: {}", dist.display()); 31 } 32 33 fn main() { 34 let start = Instant::now(); 35 let first_arg = std::env::args().nth(1).unwrap_or_else(|| "verify".to_string()); 36 let (mode, target_dir) = if first_arg == "build" || first_arg == "verify" { 37 (first_arg, std::env::args().nth(2).unwrap_or_else(|| "dist".to_string())) 38 } else { 39 ("verify".to_string(), first_arg) 40 }; 41 42 let dist = Path::new(&target_dir); 43 44 println!("============================================================"); 45 println!(" AIEN Native Static Site Builder & Integrity Verifier "); 46 println!(" Mode: {} | Target: {}", mode, dist.display()); 47 println!("============================================================"); 48 49 if !dist.exists() { 50 eprintln!("Error: Target directory '{}' does not exist.", dist.display()); 51 std::process::exit(1); 52 } 53 54 let public_routes = vec![ 55 ("/", "1.0"), 56 ("/interest", "0.9"), 57 ("/software", "0.9"), 58 ("/path", "0.7"), 59 ("/evidence", "0.7"), 60 ("/atlas", "0.7"), 61 ("/aegis", "0.7"), 62 ("/aien", "0.7"), 63 ("/research", "0.7"), 64 ("/what-i-learned", "0.7"), 65 ("/dad", "0.7"), 66 ("/symphony", "0.7"), 67 ("/symphony/first", "0.7"), 68 ("/symphony/workflow", "0.7"), 69 ("/symphony/map", "0.7"), 70 ]; 71 72 if mode == "build" { 73 generate_sitemap_and_robots(dist, &public_routes); 74 } 75 76 let metadata_str = fs::read_to_string("site-metadata.json") 77 .expect("Failed to read site-metadata.json"); 78 let metadata: HashMap = serde_json::from_str(&metadata_str) 79 .expect("Failed to parse site-metadata.json"); 80 81 let required_routes = vec![ 82 ("index.html", "/"), 83 ("aien/index.html", "/aien"), 84 ("research/index.html", "/research"), 85 ("atlas/index.html", "/atlas"), 86 ("aegis/index.html", "/aegis"), 87 ("software/index.html", "/software"), 88 ("path/index.html", "/path"), 89 ("evidence/index.html", "/evidence"), 90 ("what-i-learned/index.html", "/what-i-learned"), 91 ("dad/index.html", "/dad"), 92 ("interest/index.html", "/interest"), 93 ("symphony/index.html", "/symphony"), 94 ("symphony/first/index.html", "/symphony/first"), 95 ("symphony/workflow/index.html", "/symphony/workflow"), 96 ("symphony/map/index.html", "/symphony/map"), 97 ("404.html", "/404"), 98 ]; 99 100 let mut total_bytes = 0usize; 101 let mut verified_pages = 0; 102 103 for (rel_path, route) in &required_routes { 104 let file_path = dist.join(rel_path); 105 assert!( 106 file_path.exists(), 107 "Required static route missing: {}", 108 file_path.display() 109 ); 110 111 let content = fs::read_to_string(&file_path) 112 .unwrap_or_else(|_| panic!("Failed to read {}", file_path.display())); 113 114 total_bytes += content.len(); 115 116 // Check for pre-rendered root content (eliminates SPA clunkiness) 117 assert!( 118 content.contains("
") && content.contains("
"), 119 "Route {} missing pre-rendered HTML DOM in #root", 120 route 121 ); 122 123 // Check metadata matches site-metadata.json 124 if let Some(meta) = metadata.get(*route) { 125 let escaped_title = meta.title.replace('&', "&"); 126 assert!( 127 content.contains(&escaped_title), 128 "Route {} missing required title: {}", 129 route, 130 escaped_title 131 ); 132 } 133 134 // Verify unslop standards: zero em dashes and zero en dashes 135 assert!( 136 !content.contains('\u{2014}'), 137 "Forbidden em dash detected in {}", 138 rel_path 139 ); 140 assert!( 141 !content.contains('\u{2013}'), 142 "Forbidden en dash detected in {}", 143 rel_path 144 ); 145 146 verified_pages += 1; 147 println!(" [OK] {} ({} bytes) -> {}", rel_path, content.len(), route); 148 } 149 150 // Verify sitemap and robots 151 let sitemap = dist.join("sitemap.xml"); 152 assert!(sitemap.exists(), "Missing sitemap.xml"); 153 let robots = dist.join("robots.txt"); 154 assert!(robots.exists(), "Missing robots.txt"); 155 156 let elapsed = start.elapsed(); 157 println!("------------------------------------------------------------"); 158 println!(" Verified {} pre-rendered static routes ({} KB total)", verified_pages, total_bytes / 1024); 159 println!(" Integrity & Unslop Invariants: PASS"); 160 println!(" Completed in: {:.2?}", elapsed); 161 println!("============================================================"); 162 } 163 164 #[cfg(test)] 165 mod tests { 166 use super::*; 167 168 #[test] 169 fn test_unslop_punctuation_invariants() { 170 let sample = "AIEN: Sovereign Cognitive Architecture on dedicated hardware."; 171 assert!(!sample.contains('\u{2014}'), "Must not contain em dash"); 172 assert!(!sample.contains('\u{2013}'), "Must not contain en dash"); 173 } 174 175 #[test] 176 fn test_metadata_deserialization() { 177 let sample_json = r#"{"/aien":{"title":"AIEN Sovereign","description":"Sovereign cognitive runtime."}}"#; 178 let map: HashMap = serde_json::from_str(sample_json).unwrap(); 179 assert_eq!(map.get("/aien").unwrap().title, "AIEN Sovereign"); 180 } 181 }