chore(04-01): add Phase 4 deps and create splash module
- Add notify = "6.1", ansi-to-tui = "8.0", walkdir = "2.5" to Cargo.toml - Create src/splash.rs with load_splash() using IntoText trait - Add mod splash to main.rs module declarations - Verified single ratatui-core v0.1.0 in dependency tree
This commit is contained in:
@@ -3,6 +3,7 @@ mod config;
|
||||
mod highlighter;
|
||||
mod renderer;
|
||||
mod signals;
|
||||
mod splash;
|
||||
mod terminal;
|
||||
mod vault;
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//! ANSI art splash screen loader for bbs-md.
|
||||
//!
|
||||
//! Reads `splash.txt` from the vault root and parses ANSI SGR escape codes
|
||||
//! into ratatui `Line` objects via the `ansi-to-tui` crate.
|
||||
//!
|
||||
//! # Graceful degradation
|
||||
//!
|
||||
//! If `splash.txt` is missing or cannot be parsed, `load_splash()` returns
|
||||
//! `None`. The caller (index.md navigation) renders normally without any
|
||||
//! splash header — no error is shown to the user.
|
||||
|
||||
use std::path::Path;
|
||||
use ansi_to_tui::IntoText;
|
||||
use ratatui::text::Line;
|
||||
|
||||
/// Load ANSI art from `splash.txt` in the vault root.
|
||||
///
|
||||
/// Returns `None` if the file doesn't exist or cannot be parsed.
|
||||
/// Returns `Some(lines)` where lines are ratatui `Line<'static>` objects
|
||||
/// ready to prepend to the index.md content.
|
||||
pub fn load_splash(vault_path: &Path) -> Option<Vec<Line<'static>>> {
|
||||
let bytes: Vec<u8> = std::fs::read(vault_path.join("splash.txt")).ok()?;
|
||||
let text = bytes.into_text().ok()?;
|
||||
Some(text.lines)
|
||||
}
|
||||
Reference in New Issue
Block a user