This commit is contained in:
2026-04-11 16:00:05 -06:00
parent 316de93781
commit d2d2bf1477
4 changed files with 329 additions and 66 deletions

View File

@@ -1,39 +1,47 @@
can we implement Full-text search across pages ?
/btwhow is the process to install this program as a command on linux
to type "$ docmost-rust" on the console and the program starts,
also how to add env variables for $baseurl $email to
automatically load this values on the login screen
Yes, totally doable. Here's the honest breakdown:
What the Docmost API offers
cargo build --release
sudo cp target/release/docmost-rust /usr/local/bin/docmost-rust
Looking at the sidebar-pages endpoint pattern, Docmost likely has a
search endpoint — probably something like POST /search with a {
query: string, spaceId?: string } body. This would be the right
approach rather than fetching all pages and filtering client-side.
That's it. Any user on the system can now run docmost-rust from any
directory.
TUI implementation
If you prefer a user-local install (no sudo):
cargo install --path .
This puts the binary in ~/.cargo/bin/, which is already in your
$PATH if you installed Rust via rustup.
A search screen would work like this:
---
Environment variables for pre-filling login
┌─ Search ─────────────────────────────────┐
│ query▌ │ ← type to search
├──────────────────────────────────────────┤
│ ▶ Result page title Space name │
│ Another matching page Other space │
│ ... │
└──────────────────────────────────────────┘
Enter: open · Esc: back
Add these to your ~/.bashrc, ~/.zshrc, or
~/.config/fish/config.fish:
- Trigger it with / or Ctrl+F from the main view
- Each keypress fires a debounced API call (e.g. wait 300ms after
last keystroke)
- Results show page title + space name
- Enter opens the selected result in the editor
- Esc goes back
bash/zsh:
export DOCMOST_URL="https://docmost.nakano47.com"
export DOCMOST_EMAIL="chamagua1@proton.me"
The debounce part is the only tricky bit in the async loop — you'd
track a last_typed: Instant and only fire the search if elapsed() >
300ms without new input.
fish:
set -x DOCMOST_URL "https://docmost.nakano47.com"
set -x DOCMOST_EMAIL "chamagua1@proton.me"
Caveat: if Docmost's API doesn't expose a search endpoint, you'd
have to fetch all pages across all spaces and do client-side string
matching, which is slow and not full-text. Worth checking the API
docs first to confirm the endpoint exists before building it.
Then in the Rust code, replace the hardcoded defaults in
LoginForm::new() inside src/app.rs:
impl LoginForm {
pub fn new() -> Self {
Self {
url: std::env::var("DOCMOST_URL")
.unwrap_or_else(|_|
"http://localhost:3000".to_string()),
email: std::env::var("DOCMOST_EMAIL")
.unwrap_or_default(),
password: String::new(),
// ...
}
}
}