Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: plugin system #57

Open
1 task done
NTBBloodbath opened this issue Feb 11, 2025 · 1 comment
Open
1 task done

[Feature]: plugin system #57

NTBBloodbath opened this issue Feb 11, 2025 · 1 comment
Labels
enhancement New feature or request prio:low Low priority
Milestone

Comments

@NTBBloodbath
Copy link
Owner

NTBBloodbath commented Feb 11, 2025

Issues

  • I have checked existing issues and there no existing ones with the same request.

Feature description

It would be great to allow Rust developers to extend Norgolith’s core functionality through plugins (e.g., RSS generation, sitemaps).

The following would be a dummy example of a plugin function:

#[norgolith_plugin]
fn rss_feed_generator(content: &str) -> Result<()> {
    // Generate RSS from `site.content`
}

The plugins lifecycle would be the following:

  • Compilation: plugins are compiled as dynamic (or preferably static) libraries using cargo build --lib.
  • Discovery: plugins are loaded from ./plugins directory at runtime.
  • Execution: exposing hooks like pre_build or post_build could be ideal.

As for the plugins APIs:

  • Content manipulation: access parsed Norg content, metadata and site config.
  • HTTP server (maybe): extend the hyper server through tower (we are not using hyper v1 which natively supports middlewares).

There must be some security and stability concerns too:

  • Sandboxing: restrict filesystem access outside the project directory (I have no fricking clue how to achieve it yet).
  • Version pinning: ensure plugins declare compatible Norgolith versions to avoid crashes.
  • Error handling: isolate plugins in threads to prevent panics from crashing the main process.

As for the CLI tooling:

lith plugin new           # Scaffold plugins with example hooks.
lith plugin install rss   # Fetch from somewhere?
lith plugin update rss    # Update rss plugin.
lith plugin uninstall rss # Remove rss plugin.

I'm still unsure about the whole implementation, if the plugins should be uploaded to crates.io and how they will work in such case.

Help

Yes

Implementation help

No response

@NTBBloodbath NTBBloodbath added the enhancement New feature or request label Feb 11, 2025
@NTBBloodbath NTBBloodbath added this to the 0.2.0 milestone Feb 11, 2025
@NTBBloodbath NTBBloodbath added prio:low Low priority prio:high High priority and removed prio:low Low priority prio:high High priority labels Feb 14, 2025
@NTBBloodbath
Copy link
Owner Author

Changed priority to low, I'm planning to use WASM instead of plain Rust dynamic libraries so I gotta learn WASM before I get my hands on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request prio:low Low priority
Projects
None yet
Development

No branches or pull requests

1 participant