Skip to content

Commit

Permalink
docs(readme): update with more information about lib, cli and fuse
Browse files Browse the repository at this point in the history
Signed-off-by: Sandro-Alessio Gierens <sandro@gierens.de>
  • Loading branch information
gierens committed Sep 16, 2023
1 parent 3851c6d commit cf8b5a9
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 20 deletions.
141 changes: 121 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,130 @@
<div align="center">

# wikijs-rs

![](https://raw.githubusercontent.com/gierens/wikijs-rs/readme/logo/logo-small.png)

API bindings, CLI client and FUSE filesystem for Wiki.js written in Rust.

## State of Project
This project is still very early in its life, so read through the following
lines to know what's usable already.
[![Tests](https://github.com/gierens/wikijs-rs/actions/workflows/testing.yml/badge.svg)](https://github.com/gierens/wikijs-rs/actions/workflows/testing.yml)
![Crates.io](https://img.shields.io/crates/v/wikijs?link=https://crates.io/crates/wikijs)
![Crates.io](https://img.shields.io/crates/l/wikijs?link=https://crates.io/crates/wikijs)

</div>

**What's inside?**
- [Library](#library): Rust bindings to Wiki.js's entire GraphQL API as well
as asset up- and download via the REST API.
**Usable but not battle-tested**
- [CLI](#cli): Command-line client for those bindings allowing things like
editing pages with your editor.
**Usable but not complete yet**
- [Filesystem](#filesystem): A FUSE filesystem to mount your wiki and work on it locally.
**Not usable yet, heavily work-in-progress.**

## Library

The library basically gives you a struct `Api` that you hand the url and
credentials for you Wiki.js instance to, and that exposes functions for all
the different GraphQL queries and mutations as well as asset down- and upload
via the REST API. For detailed information check the
[documentation](https://docs.rs/wikijs), otherwise here a short example:

### Usage

Add the following dependency to your `Cargo.toml`:
```toml
[dependencies]
wikijs = "0.1"
```
Create an instance of `Api` and use its functions:
```rust
use wikijs::{Api, Credentials};

let api = Api::new(
"http://localhost:3000".to_string(),
Credentials::Key("my-api-key".to_string()),
);
println!("{:?}", api.page_get(1).unwrap());

**TL;DR:** library: yes, cli: not everything is there yet but yes, fuse: no
```
## CLI

### Library
All GraphQL queries and mutations as well as asset upload and download via the
REST API have their counterpart functions in the library. Those functions
should work as long as the APIs behave as expected from their specification.
Not everything has been tested yet, but it should have decent error handling
and thus be in a fairly usable state by now.
This crate ships a command-line tool also called `wikijs` to directly interact
with your Wiki.js instance from the CLI. On top of exposing the library
functions it also offers additional functionality like editing pages with
your favorite editor.

### CLI
The CLI client at the moment only implements a small part of the functions the
library offers mostly concentrating on the page module. If offers things like
listing pages, showing their metadata, editing their content via your editor,
and deleting them for example. Since it mostly just interfaces with the library
and also handles its errors it should be usable, too.
### Build
```bash
cargo build --features=cli
```

### FUSE
This is still heavily work-in-progress. So be very careful when trying it out!
### Install
```bash
cargo install wikijs --features=cli
```

### Usage
The tool takes the URL and credentials either from the arguments or
environment variables. For the latter option use something like this:
```bash
export WIKI_JS_BASE_URL=https://wiki.mydomain.com
export WIKI_JS_API_KEY=MY-SUPER-SECRET-API-KEY
```
Then you can for example create a page named `test`, list pages and edit
it with:
```bash
wikijs page create test
wikijs page list
wikijs page edit <ID>
```
where the `ID` is found in the `page list` output.

## Filesystem

**WARNING: Not really usable yet! Careful!**

This crate also ships FUSE filesystem called `wikifs` to mount your Wiki.js
instance locally and view and manipulate it with what ever programs you like.


### Build
```bash
cargo build --features=fuse
```

### Install
```bash
cargo install wikijs --features=fuse
```

### Usage
The tool takes the URL and credentials either from the arguments or
environment variables. For the latter option use something like this:
```bash
export WIKI_JS_BASE_URL=https://wiki.mydomain.com
export WIKI_JS_API_KEY=MY-SUPER-SECRET-API-KEY
```
Then you can mount the filesystem like so:
```bash
mkdir /tmp/wikijs
wikifs /tmp/wikijs
```
And in another terminal use it like this:
```bash
cd /tmp/wikijs
ls
cat test.md
```
provided you have a `markdown` page located at `/test` in your wiki.

## Contributing
Two big part where contributing is fairly easy and needed are writing tests
and documentation.

Two parts where especially first-time contributions should be fairly easy and
are also really needed is writing docstrings and integration tests. Apart from
that the CLI still needs to implement many of the library functions.

Please check issues and PRs first and maybe make an issue or draft PR of your
own so we can coordinate work. This is especially important for the FUSE
filesystem, as I'm currently heavily refactoring that.
Binary file added logo/logo-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cf8b5a9

Please sign in to comment.