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

Overview

wikijs-rs

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

Tests Crates.io Crates.io

What's inside?

  • 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: Command-line client for those bindings allowing things like editing pages with your editor. Usable but not complete yet
  • 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, otherwise here a short example:

Usage

Add the following dependency to your Cargo.toml:

[dependencies]
wikijs = "0.1"

Create an instance of Api and use its functions:

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());

CLI

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.

Build

cargo build --features=cli

Install

The CLI is packaged via cargo, as well as Debian and AUR package, see Installation for details.

Usage

The tool takes the URL and credentials either from the arguments or environment variables. For the latter option use something like this:

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:

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!

Also in case you wanna PR on this please coordinate via issues, as I'm currently heavily refactoring this to add a caching layer and include assets.

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

cargo build --features=fuse

Install

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:

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:

mkdir /tmp/wikijs
wikifs /tmp/wikijs

And in another terminal use it like this:

cd /tmp/wikijs
ls
cat test.md

provided you have a markdown page located at /test in your wiki.

Installation

These instructions are for the CLI only so far, as the FUSE filesystem is not ready to be shipped.

Cargo

Run the following to install the CLI from crates.io:

cargo install wikijs --features=cli

Arch

The CLI is available on AUR.

Debian and Ubuntu

The CLI is available from deb.gierens.de. The GPG public key is in this repo under deb.asc.

First make sure you have the gpg command, and otherwise install it via:

sudo apt update
sudo apt install -y gpg

Then install wikijs-rs via:

sudo mkdir -p /etc/apt/keyrings
wget -qO- https://raw.githubusercontent.com/gierens/wikijs-rs/main/deb.asc | sudo gpg --dearmor -o /etc/apt/keyrings/gierens.gpg
echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list
sudo chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list
sudo apt update
sudo apt install -y wikijs-rs

Contributing

Use small commits that make isolated changes to a single module and name them according to conventional commits.

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.

Testing

Since this depends on Wiki.js the integration tests located in tests/ can also not be done without it. Therefore the docker-compose.yml is used to run a local instance of it on port 80. This setup is also used in the CI workflows. Note that many tests assume the wiki to be fresh, no pages no anything ... that's why there is also no Docker volume, so that on every rebuild all previous data is lost. This also means you should make sure you removed everything yourself from the instance during debugging when testing.

The tests furthermore assume the wiki to have the following admin credentials:

To set this up automatically on initial startup of the wiki, you may use scripts/finalize_wiki_setup.sh which also assumes the wiki to run on http://localhost:80.

License

This projects is licensed under AGPL-3.0 since Wiki.js is, too.

You might also like...
nvim-oxi provides safe and idiomatic Rust bindings to the rich API exposed by the Neovim text editor.

🔗 nvim-oxi nvim-oxi provides safe and idiomatic Rust bindings to the rich API exposed by the Neovim text editor. The project is mostly intended for p

A tool for chatting using the ChatGPT API, written in Rust CLI.
A tool for chatting using the ChatGPT API, written in Rust CLI.

ChatGPT CLI A tool for chatting using the ChatGPT API, written in Rust CLI. You can use this tool to chat, just by setting your API Key. You can modif

Unopinionated low level API bindings focused on soundness, safety, and stronger types over raw FFI.

🔥 firehazard 🔥 Create a fire hazard by locking down your (Microsoft) Windows so nobody can escape (your security sandbox.) Unopinionated low level A

Rust bindings to the RVVM's public api

rvvm [WIP] Safe Rust bindings to the RVVM's public API. Provides the Rust-idiomatic interface to the RVVM public API. Implemented Virtual machine crea

"Rust bindings for the Matlab C API"

matlab-sys matlab-sys provides low level bindings to Matlab's C API. This allows writing MEX functions, using the C Matrix API, interacting with the C

A Rust CLI tool that helps you enforce Git policies through Git hooks both server and client side

GitPolicyEnforcer This is a command line utility written in Rust, that helps you utilize Git hooks, to enforce various policies. It currently supports

Simple but convenient CLI-based Matrix client app for sending and receiving (in Rust)

matrix-commander-rs simple but convenient CLI-based Matrix client app for sending and receiving Help create this Rust program! This project is current

A Rust client for OpenAI's API

libopenai - Rust client to interact with OpenAI's API Rust client for OpenAI's API, written with tokio and reqwest How to use To add libopenai to your

simple but convenient CLI-based Nostr client app for following users and sending DMs

nostr-commander-rs TLDR: simple but convenient CLI-based Nostr client app for publishing, sending DMs, as well as following users and channels nostr-c

Comments
  • Asset support for Filesystem

    Asset support for Filesystem

    Currently only pages and their directory structure are supported in the filesystem. Assets and asset folder should be available, too. This is gonna require some heavy refactoring.

    feature fuse 
    opened by gierens 0
  • Caching Layer for FUSE

    Caching Layer for FUSE

    Pages as well as assets should be cached in-memory and only retrieved again when their updated_at changed. This could also be included into the library so others can use it, too.

    feature lib fuse 
    opened by gierens 0
Releases(v0.1.1)
  • v0.1.1(Sep 17, 2023)

    What's Changed

    • Add more documentation to the library by @gierens in https://github.com/gierens/wikijs-rs/pull/4
    • Add Debian/Ubuntu packaging by @gierens in https://github.com/gierens/wikijs-rs/pull/5
    • Add Arch AUR package
    • Add more documentation to the README

    Full Changelog: https://github.com/gierens/wikijs-rs/compare/v0.1.0...v0.1.1

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Sep 17, 2023)

    Initial release.

    What's the State

    Library

    The library should be usable but is not battletested yet. It includes the following features:

    • structs for all types used by the GraphQL API
    • functions for all GraphQL queries and mutations
    • functions for asset download and upload via REST API
    • login via username/password for API key
    • error handling via custom module specific error types

    CLI

    This is usable but not complete yet. It includes the following features:

    • login credentials via arguments or environment variable
    • command subcommand structure in accordance to the functions offered by the library
    • commands of parts of those functions mostly focussed on the page module
    • a page edit command to modify page content via the chosen editor (EDITOR env variable or argument)

    FUSE

    This is not really usable yet and heavily work in progress. So far it does:

    • login credentials via arguments or environment variable
    • some basic operations for pages (directory structure, reading and writing pages)

    New Contributors

    • @gierens made their first contribution

    Full Changelog: https://github.com/gierens/wikijs-rs/commits/v0.1.0

    Source code(tar.gz)
    Source code(zip)
Owner
Sandro-Alessio Gierens
Cloud Computing at Leibniz Supercomputing Centre
Sandro-Alessio Gierens
FUSE filesystem that provides FizzBuzz.txt(8 Exabyte)

FizzBuzzFS root@8a2db3fc6292:/# cd /mnt/FizzBuzz/ root@8a2db3fc6292:/mnt/FizzBuzz# ls -l total 9007199254740992 -rw-r--r-- 1 501 dialout 9223372036854

todesking 8 Oct 1, 2023
fd is a program to find entries in your filesystem. It is a simple, fast and user-friendly alternative to find

fd is a program to find entries in your filesystem. It is a simple, fast and user-friendly alternative to find. While it does not aim to support all of find's powerful functionality, it provides sensible (opinionated) defaults for a majority of use cases.

David Peter 25.9k Jan 9, 2023
This utility traverses through your filesystem looking for open-source dependencies that are seeking donations by parsing README.md and FUNDING.yml files

This utility traverses through your filesystem looking for open-source dependencies that are seeking donations by parsing README.md and FUNDING.yml files

Mufeed VH 38 Dec 30, 2022
A filesystem driver that allows you to view your Blackboard course contents as if they were normal files and folders on your system!

BlackboardFS Blackboard: noun A website so bad that it might as well be a network drive. BlackboardFS is a filesystem driver that allows you to view y

null 22 Sep 4, 2023
Cover your tracks during Linux Exploitation by leaving zero traces on system logs and filesystem timestamps.

moonwalk-back Cover your tracks during Linux Exploitation / Penetration Testing by leaving zero traces on system logs and filesystem timestamps. ?? Ta

Aditya 57 Nov 24, 2024
Async filesystem facade for Rust!

floppy-disk floppy disk is a WIP, async-only filesystem facade for Rust. What? Have you ever worked with std::fs? tokio::fs? Then you've probably real

amy null 8 Apr 2, 2023
A slightly smart clipboard tool - leverage the filesystem to persist across machines after shutdown.

clipd A slightly smart clipboard using the filesystem under ~/.clipd to persist after shutdown. cowsay "clipd is great" | clipd copy clipd paste ____

null 5 Aug 9, 2022
Quickly find all blackhole directories with a huge amount of filesystem entries in a flat structure

findlargedir About Findlargedir is a tool specifically written to help quickly identify "black hole" directories on an any filesystem having more than

Dinko Korunic 24 Jan 1, 2023
Provides filesystem access for the Rhai scripting language.

About rhai-fs This crate provides filesystem access for the Rhai scripting language. Usage Cargo.toml [dependencies] rhai-fs = "0.1.2" Rhai script //

Rhai - Embedded scripting language and engine for Rust 6 Dec 5, 2022
Nimbus - A virtual, networked filesystem with strong upfront safety guarantees

The Nimbus Filesystem Nimbus is a virtual, networked filesystem that provides upfront safety guarantees to a user, intended for personal use. In parti

Max Fan 3 Jan 10, 2023