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/navbar.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 / navbar.rs` 231 lines ยท 11299 bytes Raw Blame History 1 use maud::{html, Markup, PreEscaped}; 2 3 /// The six destinations of the site, in reading order (the approved Omega 4 /// redesign, 2026-10-26): Sovereign Intelligence in its classic readable 5 /// form, then Omega, the Machine, Discoveries, Learn and Aien. The root is 6 /// Aien's native front door and the redesign has no top nav bar; every page 7 /// still links all six, in this order, somewhere a reader can reach (a quiet 8 /// index or footer). [`check_destinations`] holds every page in dist to that. 9 pub const NAV_PRIMARY: [(&str, &str); 6] = [ 10 ("SI", "/classic/"), 11 ("Omega", "/omega/"), 12 ("Machine", "/machine/"), 13 ("Discoveries", "/discoveries/"), 14 ("Learn", "/learn/"), 15 ("Aien", "/aien/"), 16 ]; 17 18 /// Secondary links: behind the "More" menu button at the end of the row. 19 /// Omega is one of the six destinations, so it is not repeated here. 20 pub const NAV_SECONDARY: [(&str, &str); 11] = [ 21 ("Sovereign Intelligence", "/alpha/"), 22 ("Lab", "/lab/"), 23 ("Start here", "/start/"), 24 ("Agora", "/agora/"), 25 ("Agents", "/agents/"), 26 ("CUDA++", "/cudaplusplus/"), 27 ("Now", "/now/"), 28 ("Progress", "/progress/"), 29 ("Blog", "/blog"), 30 ("Follow", "/#follow"), 31 ("Forge", "https://interplane.io/drakestapleton"), 32 ]; 33 34 /// Every page links the six [`NAV_PRIMARY`] dashboards, in order, each an 35 /// `` with exactly that href and that reader-visible label, among the 36 /// links a reader can reach (scripts, templates and `aria-hidden` content 37 /// do not count). Where they sit (a quiet index, a footer) and the markup 38 /// around them are free, and other links may come between them. 39 pub fn check_destinations(html: &str) -> Result<(), String> { 40 let links = crate::oracle::anchors(&crate::oracle::reachable(html)); 41 let mut next = 0usize; 42 for (label, href) in NAV_PRIMARY { 43 let at = links[next..] 44 .iter() 45 .position(|(h, t)| h == href && t == label) 46 .ok_or(format!("destination {label} ({href}) missing, hidden or out of order"))?; 47 next += at + 1; 48 } 49 Ok(()) 50 } 51 52 pub fn render_navbar() -> Markup { 53 html! { 54 header class="aien-header" { 55 div class="aien-header-inner" { 56 a class="aien-brand" href="/" aria-label="AienOS PERSISTENT MACHINE INTELLIGENCE: home" { 57 span class="aien-brand-mark" aria-hidden="true" { 58 (PreEscaped(r#""#)) 59 } 60 span class="aien-brand-copy" { 61 span class="aien-brand-name" { "AienOS" } 62 // The space keeps the rendered text "AienOS PERSISTENT ..." inside the 63 // aria-label; without it the text reads "AienOSPERSISTENT ..." (L501). 64 " " 65 span class="aien-brand-tag" { "PERSISTENT MACHINE INTELLIGENCE" } 66 } 67 } 68 nav class="aien-nav aien-nav-bar" aria-label="Primary navigation" { 69 ul class="aien-nav-primary" { 70 @for (label, href) in NAV_PRIMARY { 71 li { a class="aien-nav-link" href=(href) { (label) } } 72 } 73 } 74 // One button holds everything that used to wrap onto 75 // further rows. A native
: it opens and closes 76 // by click, Enter or Space and needs no script. Below 77 // the narrow breakpoint the six sections move in here 78 // too (aien-nav-sections), so the header stays one row. 79 details class="aien-nav-more" { 80 summary class="aien-nav-more-button" { 81 span class="aien-nav-more-wide" { "More" } 82 span class="aien-nav-more-narrow" { "Menu" } 83 } 84 div class="aien-nav-panel" { 85 ul class="aien-nav-sections" aria-label="Sections" { 86 @for (label, href) in NAV_PRIMARY { 87 li { a class="aien-nav-minor" href=(href) { (label) } } 88 } 89 } 90 ul class="aien-nav-secondary" aria-label="More" { 91 @for (label, href) in NAV_SECONDARY { 92 li { a class="aien-nav-minor" href=(href) { (label) } } 93 } 94 } 95 } 96 } 97 (crate::components::contact::nav_reach()) 98 } 99 } 100 } 101 } 102 } 103 104 #[cfg(test)] 105 mod tests { 106 use super::*; 107 108 /// Written out independently of NAV_PRIMARY so reordering or dropping 109 /// an entry in the const makes these tests fail. 110 const EXPECTED_PRIMARY: [(&str, &str); 6] = [ 111 ("SI", "/classic/"), 112 ("Omega", "/omega/"), 113 ("Machine", "/machine/"), 114 ("Discoveries", "/discoveries/"), 115 ("Learn", "/learn/"), 116 ("Aien", "/aien/"), 117 ]; 118 119 fn assert_six_in_order(haystack: &str, what: &str) { 120 let mut last = 0usize; 121 for (i, (label, href)) in EXPECTED_PRIMARY.iter().enumerate() { 122 let needle = format!("{label}"); 123 let pos = haystack[last..] 124 .find(&needle) 125 .unwrap_or_else(|| panic!("{what}: nav item {i} ({label}) missing or out of order")); 126 last += pos + needle.len(); 127 } 128 } 129 130 /// A page in the shape of the redesign: no top nav, the six 131 /// destinations in a quiet footer index, each a glyph marked 132 /// aria-hidden plus its label. 133 fn quiet(items: &[(&str, &str)]) -> String { 134 let mut s = String::from("SISovereign Intelligence
body
"); 139 s 140 } 141 142 #[test] 143 fn primary_nav_const_matches_the_six_dashboards() { 144 assert_eq!(NAV_PRIMARY, EXPECTED_PRIMARY, "NAV_PRIMARY differs from the approved six dashboards"); 145 } 146 147 #[test] 148 fn rendered_navbar_has_six_sections_in_order_before_secondary() { 149 let html = render_navbar().into_string(); 150 assert_six_in_order(&html, "generated navbar"); 151 check_destinations(&html).expect("the Rust navbar passes the dist check"); 152 let primary_end = html.find("").expect("primary list closes"); 153 let secondary = html.find("aien-nav-secondary").expect("secondary list present"); 154 assert!(secondary > primary_end, "secondary links must come after the six sections"); 155 for (label, _) in NAV_SECONDARY { 156 assert!(html[secondary..].contains(label), "secondary item {label} missing"); 157 assert!(!html[..primary_end].contains(&format!(">{label}<")), "{label} must not be a primary item"); 158 } 159 } 160 161 #[test] 162 fn quiet_index_passes_the_destination_check() { 163 check_destinations(&quiet(&EXPECTED_PRIMARY)).expect("six in order, glyphs hidden"); 164 let mut extra = EXPECTED_PRIMARY.to_vec(); 165 extra.insert(2, ("Now", "/now/")); 166 check_destinations(&quiet(&extra)).expect("other links between the six are allowed"); 167 } 168 169 #[test] 170 fn destination_check_negative_controls() { 171 let six = EXPECTED_PRIMARY; 172 let mut swapped = six.to_vec(); 173 swapped.swap(1, 2); 174 let mut relabelled = six.to_vec(); 175 relabelled[3] = ("Scientific Discovery", "/discoveries/"); 176 let mut rerouted = six.to_vec(); 177 rerouted[3] = ("Discoveries", "/discovery/"); 178 let good = quiet(&six); 179 let learn = "ΩLearn"; 180 let cases = [ 181 ("one item dropped", quiet(&six[..5])), 182 ("two items swapped", quiet(&swapped)), 183 ("label changed", quiet(&relabelled)), 184 ("href changed", quiet(&rerouted)), 185 ("label only in the hidden glyph", good.replace(learn, "Learn")), 186 ("link inside an aria-hidden index", good.replace("aria-label=\"Destinations\"", "aria-hidden=\"true\"")), 187 ("link only in a script", good.replace(learn, &format!(""))), 188 ("link only in a template", good.replace(learn, &format!(""))), 189 ("hidden element never closes", good.replace("
").unwrap(), "X button follows the More button"); 213 } 214 215 #[test] 216 fn navbar_has_no_em_or_en_dash() { 217 let html = render_navbar().into_string(); 218 assert!(!html.contains('\u{2014}') && !html.contains('\u{2013}')); 219 } 220 221 #[test] 222 fn header_has_no_language_list_and_more_ends_before_the_x_button() { 223 let html = render_navbar().into_string(); 224 assert!(!html.contains("hreflang"), "no language alternates in the header"); 225 assert!(!html.contains("aien-nav-lang"), "no language list in the header"); 226 assert!( 227 html.contains("