This is getting out of hand.
The Pig Web App is a web GUI to manage a list of pig names. Keeping them in a yml file on a server that is never online is no longer feasible, and even if it were, the plugin is not built to manage such a large list efficiently.
I'm mainly going this far to write the entire app from the ground up to make sure search queries are handled server-side, as Pocketbase doesn't support serverside functions.
This is also my entryway into Rust, and as such have documented much of what everything does and what I've learned throughout the process. If there's some horrible mistake I've made, any tips I could use, or any questions you have, please feel free to let me know.
For more screenshots, see the folder.
- Client and Server modules written in Rust. - Complete 2024-12-29 - Shared code and data structures should be in a Common module.
- CRUD pig names. - Complete 2025-02-15
- RBAC to allow different levels of access. - Complete 2025-04-11 - You should also be able to configure groups for assigning these roles to users.
- OIDC authentication, the app should not manage authentication. - Complete 2025-03-30 - It should, however, be able to read user groups from OIDC user info and manage users' groups through it.
- Fully declarative configuration. - Complete 2025-01-31 - Ideally, this is possible through NixOS modules that you can also use to deploy it. The config file itself can be TOML as I don't care about reading it, just processing. It should also be able to take config from environment variables (takes precedent over config) and possibly CLI options (takes precedent over env).
- Audit log showing a history of changes. Should show timestamp, pig name/id, who made the change, and what the change was.
- MiniMessage formatting previews. This will likely require a custom interpreter, unfortunately.
- Mass Add wizard to import en masse. - Complete 2025-05-03 - This should hold your hand through the entire import process, cleaning up formatting, automatic duplicates, manual duplication checks, etc. There should be a way to save your progress.
- OAuth2 authentication for API endpoints. This should be used to integrate with the plugin itself.
Additional guides are available in the /docs folder.
To simplify workspace setup and installing dependencies, most of it is managed for you with Nix and direnv.
-
If you're not using NixOS, install the Nix package manager for your system using the Determinate Nix Installer.
-
Install direnv for your system.
- For NixOS, a better implementation is provided by nix-community/nix-direnv.
-
Add direnv integration to your IDE. For RustRover, I recommend Direnv Integration. It doesn't work perfectly, but it still works. Be sure to follow the setup instructions for it.
-
cd
into the project dir and rundirenv allow
. If you need to manually enter the dev shell, usenix develop
.
Important
Assume ALL commands hereafter are in the Nix shell unless otherwise stated.
Run cargo make serve
to open a development server on localhost:8000, allowing you to preview changes in (almost) real time.
Since the web server blocks the thread and as such cargo-make can't stop the server when it's time to build new changes, the server itself is run in a tmux session. To view it's output, run tmux attach-session -t pigweb
in a separate shell to attach to the session.
When you're done, stop the server with cargo make stop
.
Builds are configured using cargo-make to avoid ugly wrapper scripts.
For a production build, run cargo make -p production
. You can build the client and server separately with Nix using nix build ./#pigweb_[client/server]
.
- "How to Write a Web App in Rust" by Garrett Udstrand, see parts 1 2 3 4 5 6
- "A Rust web server / frontend setup like it's 2022 (with axum and yew)" by Robert Krahn
- "A web application completely in Rust" by Sascha Grunert
- "Rust fullstack web app! WASM + YEW + ROCKET" by Francesco Ciulla
- "Full-stack Rust: A complete tutorial with examples" by Mario Zupan
- "Building cross-platform GUI apps in Rust using egui" by Mario Zupan
- "Part 1: Building a WebSite in Rust Using Rocket and Yew"