1//! Prints the link preview's card as an SVG, 1200 by 630: what Discord or Twitter shows when the 2//! site's address is pasted. `tools/build-web.sh` turns it into the PNG the page's tags point at. 3//! 4//! The look is the Jev sites' own (`jev_ui::card`): the dot field, the pink band with the site's 5//! name, and a window. What is inside the window is this site's. 6 7use jev_ui::card::{Chrome, INK, text}; 8use jevhooks_web::content::{CARD_HEIGHT, CARD_WIDTH, NAME}; 9 10/// What the window says, a line each, in the card's pixel type. 11const LINES: [&str; 3] = ["JEV JUDGES WHAT", "CLAUDE CODE IS", "ABOUT TO DO"]; 12 13fn main() { 14 let chrome = Chrome::new(2); 15 assert_eq!((chrome.width(), chrome.height()), (CARD_WIDTH, CARD_HEIGHT), "the card is the size the page's tags declare"); 16 let content = chrome.content(); 17 let scale = 4 * chrome.unit(); 18 // A glyph is eight units tall; a line and a half between baselines. 19 let step = 12 * scale; 20 let mut svg = chrome.background_svg("hooks.lmjtfy.fun"); 21 let end = svg.rfind("</svg>").expect("a whole SVG document"); 22 let mut inside = chrome.window_svg(NAME); 23 for (line, words) in LINES.iter().enumerate() { 24 inside.push_str(&text(content.x, content.y + line as u32 * step, scale, INK, words)); 25 } 26 svg.insert_str(end, &inside); 27 println!("{svg}"); 28}