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/contact.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 / contact.rs` 313 lines · 16917 bytes Raw Blame History 1 //! Where Drake is and how to reach him: the /contact/ page, the X button in 2 //! every header, and the contact line in every footer. 3 //! 4 //! Generated pages get the header and footer pieces from the navbar and the 5 //! footer components. Hand-written pages under public/ carry 6 //! their own copy of the header, so [`enrich`] adds the same markup to them 7 //! in the shared document pass, and [`verify`] fails the build if any page 8 //! in dist lacks either piece. The X button is a plain link: no widget, no 9 //! script and nothing loaded from X. It is the header's only contact entry; 10 //! the email address lives in the footer line and on /contact/. 11 12 use std::fs; 13 use std::path::Path; 14 15 use maud::{html, Markup, PreEscaped}; 16 17 use crate::seo::{X_HANDLE, X_URL}; 18 19 pub const TITLE: &str = "Where I am and how to reach me | AienOS"; 20 pub const DESCRIPTION: &str = "How to reach Drake Stapleton: X @drakestapleton, email drake@aienos.com, Aien (who can pass a message to me or put you through when I'm online) and my repositories on the forge."; 21 pub const URL: &str = "https://www.aienos.com/contact/"; 22 pub const PATH: &str = "/contact/"; 23 pub const EMAIL: &str = "drake@aienos.com"; 24 pub const ALLEN: &str = "/aien/"; 25 pub const FORGE: &str = crate::forge::FORGE; 26 /// The front door: install command, releases and a hub of every part. 27 pub const SI: &str = "https://interplane.io/drakestapleton/sovereign-intelligence"; 28 29 /// The X mark (Simple Icons, CC0), drawn in the link's text colour. 30 const X_MARK: &str = r#""#; 31 32 fn x_link() -> Markup { 33 html! { 34 a class="aien-x-link" href=(X_URL) target="_blank" rel="me noopener noreferrer" { 35 (PreEscaped(X_MARK)) 36 span class="aien-x-label" { "Follow me on X" } 37 " " 38 span class="aien-x-handle" translate="no" { (X_HANDLE) } 39 } 40 } 41 } 42 43 /// The last group of the header nav: one pressable X button, the header's 44 /// contact entry. Its name is text a reader meets (visually hidden, so the 45 /// mark is the only thing drawn), which is what [`check_page`] counts. 46 pub fn nav_reach() -> Markup { 47 let name = format!("Contact me on X ({X_HANDLE})"); 48 html! { 49 ul class="aien-nav-secondary aien-nav-reach" aria-label="Reach me" { 50 li { 51 a class="aien-x-link aien-x-button" href=(X_URL) target="_blank" rel="me noopener noreferrer" aria-label=(name) title=(name) { 52 (PreEscaped(X_MARK)) 53 span class="aien-x-name" { (name) } 54 } 55 } 56 } 57 } 58 } 59 60 /// The contact line in the footer: the contact page, then every route. 61 pub fn footer_reach() -> Markup { 62 html! { 63 div class="aien-reach-foot" { 64 p class="aien-reach-title" { a href=(PATH) { "Where I am and how to reach me" } } 65 p class="aien-reach-routes" { 66 (x_link()) 67 " · " 68 "Email: " a href=(format!("mailto:{EMAIL}")) { (EMAIL) } 69 " · " 70 a href=(ALLEN) { "Talk to Aien" } 71 " · " 72 a href=(FORGE) target="_blank" rel="noopener noreferrer" { "Forge: drakestapleton" } 73 } 74 } 75 } 76 } 77 78 /// Adds the header and footer pieces to a page that does not carry them 79 /// yet (hand-written pages). Idempotent. Panics on a page 80 /// without the shared header nav: every page must show the X link. 81 pub fn enrich(mut page: String) -> String { 82 if !page.contains("aien-nav-reach") { 83 let nav = page.find("class=\"aien-nav").expect("page carries the shared header nav"); 84 let end = nav + page[nav..].find("").expect("shared header nav closes"); 85 page.insert_str(end, &nav_reach().into_string()); 86 } 87 if !page.contains("aien-reach-foot") { 88 let strip = html! { div class="aien-reach-strip" { (footer_reach()) } }.into_string(); 89 let end = if page.contains("class=\"aien-footer\"") { page.rfind("") } else { None } 90 .or_else(|| page.rfind("")) 91 .expect("page has a body"); 92 page.insert_str(end, &strip); 93 } 94 page 95 } 96 97 /// Fails the build unless every HTML page in dist reaches Drake: see 98 /// [`check_page`]. 99 pub fn verify(dist: &Path) { 100 fn walk(dir: &Path, dist: &Path, n: &mut usize) { 101 for entry in fs::read_dir(dir).expect("read dist directory") { 102 let path = entry.expect("dist entry").path(); 103 if path.is_dir() { 104 walk(&path, dist, n); 105 } else if path.extension().and_then(|e| e.to_str()) == Some("html") { 106 let html = fs::read_to_string(&path).expect("read page"); 107 let rel = path.strip_prefix(dist).expect("page under dist").to_string_lossy().replace('\\', "/"); 108 check_page(&rel, &html).unwrap_or_else(|e| panic!("{}: {e}", path.display())); 109 *n += 1; 110 } 111 } 112 } 113 let mut n = 0; 114 walk(dist, dist, &mut n); 115 println!(" Follow me on X, contact, email and the way home: {n} pages"); 116 } 117 118 /// The redesign has no header bar, so the rule is about what a reader can 119 /// reach, not where a bar sits. Every page (`rel` is its file under dist) 120 /// has exactly one visible `
` and carries, outside comments, scripts, 121 /// templates, `