Impertio v0.1.2
2024-06-09T02:59:08.300798870ZThis has been an eventful weekend - I added RSS, made the SSG modular so I can add more markup formats in the future, added a config file, and added category listings that make use of the Org Macro format.
As always, the source of this file is available [[https://kazani.dev/cs/impertio-v0-1-2.org][here]].
Feeds
I implemented RSS by extracting the metadata from the Org files (~TITLE~, ~AUTHOR~, ~DESC~) and feeding them to the wonderful crate that is [[https://crates.io/crates/rss][rss]].
My RSS feed is available [[https://kazani.dev/feed][here]], if you would like to view it. I don't know why it downloads it, sorry about that.
Config
I implemented config files using the [[https://crates.io/crates/serde][Serde crate]]. One of my favorite crates, other than [[https://crates.io/crates/anyhow][~anyhow~]].
Modularization
I got over my fear of Rust Traits and implemented a generic Trait interface for my file handlers.
pub trait FileHandler: DynClone {
fn new() -> Self where Self: Sized;
fn handle_file(&mut self, ctx: FileContext) -> anyhow::Result<()>;
fn extract_metadata(&mut self, ctx: FileContext) -> anyhow::Result;
}
clone_trait_object!(FileHandler);
As you may be able to tell, I had to fight a little with the Rust Trait system to get it to let me clone the implementations of the Trait. Stack Overflow led me to finding the tiny little crate, [[https://crates.io/crates/dyn-clone][~dyn-clone~]], which easily solved my problems.
Category Listings
{{{listing(/cs)}}}
That's it. That's all it takes to embed a listing into an Org file in Impertio. Currently I am messily pulling the metadata into the Org parser, which is not optimal. I'll /hopefully/ figure out how to do that differently in the future.
The Future
Currently I am not putting article content into the RSS feed Items, so I would like to do that in the future. My Org parser does not currently support inline styling (which was probably visible if you read this article before I implemented it... sorry about that), which I would like to fix. I'm currently doing syntax highlighting on the client side using [[https://highlightjs.org][Highlight.js]], which is extremely undesirable. I am planning on switching to doing the syntax highlighting at compile time using the [[https://crates.io/crate/syntect][Syntect crate]].
Commits
- [[https://github.com/R2Boyo25/impertio-rs/compare/095984e19655ece6322bb63873fd19729eacc156..110058e0d5e6ebf368f3337a378620b93bd667ba][v0.1.1]]
- [[https://github.com/R2Boyo25/impertio-rs/compare/110058e0d5e6ebf368f3337a378620b93bd667ba..d90cdf070f0bfdf03a2c0b30ef7bb4ae544618fc][v0.1.2]]