feat: render fixed-width text for nex

This commit is contained in:
randogoth 2026-10-04 20:27:29 +03:00
parent 2f38b8b929
commit 9e1cfed284
19 changed files with 1160 additions and 44 deletions

View file

@ -12,12 +12,13 @@ name = "itsybitsy"
path = "src/main.rs"
[features]
default = ["http", "spartan", "nex", "gemtext", "wap"]
default = ["http", "spartan", "nex", "gemtext", "wap", "text"]
http = []
spartan = []
nex = []
gemtext = ["dep:itsybitsy-gemtext"]
wap = ["dep:itsybitsy-wap"]
text = ["dep:itsybitsy-text"]
[dependencies]
anyhow = "1"
@ -25,6 +26,7 @@ clap = { version = "4.6", features = ["derive"] }
env_logger = { version = "0.11", default-features = false, features = ["auto-color", "humantime"] }
itsybitsy-core = { path = "../core" }
itsybitsy-gemtext = { path = "../gemtext", optional = true }
itsybitsy-text = { path = "../text", optional = true }
itsybitsy-wap = { path = "../wap", optional = true }
log = "0.4"

View file

@ -129,7 +129,7 @@ pub fn serve(listener: &Listener, mut stream: TcpStream) -> Result<()> {
head_only,
);
};
let cache = page.settings.cache_control.map(|age| format!("max-age={age}"));
let cache = page.settings.max_age.map(|age| format!("max-age={age}"));
let mut headers: Vec<(&str, &str)> = Vec::new();
// The response body depends on Accept, so a shared cache must not
// serve one client's format to another.

View file

@ -14,6 +14,9 @@ pub fn build() -> Registry {
#[cfg(feature = "gemtext")]
registry.insert(Arc::new(itsybitsy_gemtext::Gemtext)).expect("duplicate renderer id");
#[cfg(feature = "text")]
registry.insert(Arc::new(itsybitsy_text::Text)).expect("duplicate renderer id");
#[cfg(feature = "wap")]
{
registry.insert(Arc::new(itsybitsy_wap::XhtmlMp)).expect("duplicate renderer id");

View file

@ -26,7 +26,7 @@ impl Server {
write(dir.path(), "one/index.md", "# One\n\nFirst site.\n");
write(dir.path(), "one/about.md", "# About\n\nAbout the first.\n");
write(dir.path(), "one/img.png", "not really a png");
write(dir.path(), "one/.itsybitsy.toml", "[defaults]\ncache_control = 120\n");
write(dir.path(), "one/.itsybitsy.toml", "[defaults]\nmax_age = 120\n");
write(dir.path(), "two/index.md", "# Two\n\nSecond site.\n");
let text = format!(