Replies: 3 comments 4 replies
-
Wrote a rough-and-tumble little parser for the I'll be refactoring it into a more useful library, adding features as needed for my project - namely identifying Spells in text files, building Scrolls, and writing out CSS. Hope you're well. |
Beta Was this translation helpful? Give feedback.
-
Hi @hollyburn, First of all, thank you so much for your kind words about Grimoire CSS! I’m thrilled that you find the tool useful and the codebase approachable. Regarding your suggestion, I believe that instead of exposing internal structures and functions, a better approach would be to implement this as an optional module within Grimoire CSS itself. This would maintain the current level of safety while providing the flexibility you’re looking for. By designing it as a feature (e.g., database or alternative storage support), we could keep the core library focused and stable while allowing users to opt-in to this functionality when needed. I’d love to collaborate and help bring this idea to life! To ensure we address all use cases and design it effectively, I’d like to propose the following steps:
Let me know your thoughts and if there are any specific ideas or requirements you already have in mind. I’m excited about the possibilities and am more than happy to actively develop this alongside you to ensure it aligns with your needs. Looking forward to hearing from you! |
Beta Was this translation helpful? Give feedback.
-
Hi! I briefly mentioned it in my first post, but I think the way to go if you're willing to change large parts of the code would be structuring Grimoire to use traits for input and output. This way, the existing filesystem code could pub trait GrimoireIO<'a> {
/// an iterator over critical-path Spells specified as strings
fn critical_spells() -> impl Iterator<Item = &'a str>;
/// an iterator over readers representing critical-path input css files to be fed to the css minifier
fn critical_css() -> impl Iterator<Item = impl Read>;
/// an iterator over shared Spells specified as strings
fn shared_spells() -> impl Iterator<Item = &'a str>;
/// an iterator over readers representing shared input css files to be fed to the css minifier
fn shared_css() -> impl Iterator<Item = impl Read>;
/// an iterator over readers which might contain spells, and a key so they can be associated to an output
fn input_files() -> impl Iterator<Item = (impl Hash, impl Read)>;
// and so on and so forth... :)
} This is hard to specify without a full |
Beta Was this translation helpful? Give feedback.
-
First off, congrats on writing a useful and powerful tool with a super readable codebase!
Problem
I'd like to use Grimoire as part of a web framework, preferably keeping my config and CSS in a database. It'd be convenient if I could implement a trait (or a few) for this, so I could e.g. deploy my application to a serverless provider or as a single-file container and rebuild my CSS when an admin user modifies the theme.
Solution
Essentially, I'd like a few currently private structs and functions which accept a directory to 1) be pub and 2) instead take perhaps a vector/map filled with reader/writers, or a single reader/writer in the case where they only use the directory to construct one file's path. Having access to say,
ConfigJSON
would be useful. It'd be nice to ultimately build shared and critical CSS to a string or writer for storage somewhere other than the filesystem, like in a db or hashmap.Options
Honestly, the language is so well-specified I would be comfortable implementing this in a new crate if it's not something you're interested in for this project. Or with your architectural blessing, I could take a crack at rewriting the relevant parts of this crate to be less tied to the filesystem - without removing any existing fs-based functionality, of course.
Beta Was this translation helpful? Give feedback.
All reactions