- Go 87.3%
- HTML 6.5%
- CSS 3.7%
- JavaScript 1.7%
- Shell 0.3%
- Other 0.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Three tests were passing without testing what they claimed. The malformed-info table was almost entirely dead: seven of its eight blocks were JSON arrays where a data block must be an object, so they failed as "the data block is not valid JSON" before any row was looked at. The checks they were there to watch — an empty key, a row with no value, a field named twice — were exercised by nothing. The table now holds well-formed blocks with bad "info" values, and each case carries the words its error must contain, so a case cannot pass by being refused for some other reason. That is what let it rot: "there was an error" is satisfied by any error. The duplicate-key case was the worst of them, because the help page promises that rule to a reader while the test that named it was checking the shape of an object row. The two registries document that PagesWithTag and PagesWithType return a copy, because the mutators insert into those lists in place. Neither was tested: returning the registry's own slice changed no test result. Both now write into the slice they were handed and then ask the registry, which is the direction that fails reliably — watching the returned slice change after another page is tagged depends on whether the insert reallocated, and with a one-element list it always does. An earlier draft of this test made exactly that mistake and passed against a registry handing out its own array. TagsOfPage's copy is structural rather than a branch, so its test guards a future refactor instead of a present risk; it is kept because it costs a millisecond and states the promise. |
||
| internal | ||
| .dockerignore | ||
| .gitignore | ||
| .mailmap | ||
| build.sh | ||
| cli.go | ||
| cli_test.go | ||
| config.md | ||
| csrf_test.go | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| httpd.go | ||
| httpd_test.go | ||
| image.sh | ||
| license.txt | ||
| logging.go | ||
| logging_test.go | ||
| main.go | ||
| readme.md | ||
| reload_test.go | ||
| repo_helper_test.go | ||
| routes_test.go | ||
| saving_test.go | ||
| scripts_test.go | ||
| tests.sh | ||
🔗 Mojowiki
Mojowiki is a lightweight wiki engine. Pages are plain files, history is a
Git repository, and there is nothing to install but the binary and git. It is
a fork of Mycorrhiza Wiki by Timur Ismagilov.
Features
- No database to run. Everything is a plain file in a directory, so
installing is copying a binary and a
gitexecutable, backing up is copying a directory, and you can edit pages with any text editor. - Everything is a page. A page is a unit of content: a picture, a video or a text article. Pages can transclude and link each other, forming a tight network of hypertext.
- Pages are authored in Mojomarkup, a markup language that is designed to be unambiguous yet easy to use. It has headings, lists, tables, quotes, code blocks, transclusions, and inline objects such as colour swatches.
- Metadata lives in the page file. A page's facts — its tags, its type, the
rows of its info box, and anything else you care to keep — sit in a
#DATA#block at the top of the page's own text, as JSON. The wiki reads the fields it knows and carries the rest through untouched, so metadata is versioned, mergeable, and travels with the page: copy the file and its facts go with it. No sidecar files, no database, nothing to keep in sync. - Tags organize pages without any hierarchy restrictions: a page carries any number of them, and adding one is an edit with history like any other. Pages nest if you like hierarchies.
- A page has at most one type — what it is, rather than what it is about. Types suggest themselves as you type one, and the info box shows what a page is under its name.
- History of changes. Every edit is a Git commit, so nothing is lost and the wiki can be cloned like any repository. Recent changes are published as a JSON Feed.
- Concurrent edits are merged, not overwritten. Two people saving the same page at once keep both their changes: the wiki merges them by block where it can, by word where one paragraph carries both, and shows the author only the words they both changed, with a diff of what the other person did. A save is refused while the conflict is still unresolved.
- Keyboard-driven navigation. Press
?to see the list of shortcuts. - Support for authorization. Username-password accounts, with rights managed from the admin panel.
- Link previews. Pages carry the title and description that chat apps and search engines show when someone shares them.
- Interwiki support.
Installing
Mojowiki requires Go 1.26.3 or newer to build, and the git program to run. It
shells out to git for every edit rather than linking a library, so git must
be on the PATH of the account the wiki runs as. That is the only runtime
dependency.
Build from a checkout:
$ git clone https://git.mojosa.su/service/mojowiki
$ cd mojowiki
$ go build -o mojowiki .
Then put the binary anywhere on your PATH:
$ install -Dm755 mojowiki ~/.local/bin/mojowiki
go build uses cgo, so the result links against libc. For a static binary you
can copy to a machine without one, disable cgo:
$ CGO_ENABLED=0 go build -o mojowiki .
./build.sh is the same build with the machine's paths trimmed out of the
binary, so a stack trace does not name the machine it was built on.
The manual page is not installed by a build:
$ install -Dm644 internal/help/mojowiki.1 /usr/local/share/man/man1/mojowiki.1
Docker
./image.sh builds the container image. It has to run inside a git checkout,
because the image records which build it came from, and a build context without
.git has nothing to record. A plain docker build must supply that value:
$ docker build --build-arg VERSION="$(git describe --tags --dirty)" -t mojowiki .
$ docker run -p 1737:1737 -v /srv/wiki:/wiki mojowiki
The entry point is mojowiki serve, so the image serves the directory you mount
at /wiki. The image is Alpine with git and an ssh client, about 54 MB.
Usage
Run the wiki against a directory:
$ mojowiki serve /srv/wiki
The directory is created if it does not exist, with a config.json holding the
defaults. Every setting is documented in config.md.
Authorisation is on by default, so a new wiki has no administrator and nothing can be edited until one exists:
$ mojowiki create-admin alice /srv/wiki
The password is read from stdin, so this works from a pipe, a compose file or a Kubernetes job as well as from a shell.
The wiki listens on 0.0.0.0:1737 unless told otherwise, with -listen-addr or
MOJOWIKI_LISTEN_ADDR. Set URL in config.json to the address the wiki is
actually reached on, so that feeds and link previews point at it.
It logs to stderr. MOJOWIKI_LOG_FORMAT=json gives one JSON object per line for
a log collector, and MOJOWIKI_LOG_LEVEL sets the threshold: debug, info
(the default), warn or error.
GET /health answers 200 while the process is serving. It is a liveness
probe, not a deeper health check:
$ curl -fsS http://127.0.0.1:1737/health
{"status":"ok"}
One process per wiki directory: a second server on the same directory exits at
once and names the pid that holds it, because two of them would run git
against the same index and lose edits. The lock is .mojowiki.lock in the wiki
directory and is held by the kernel, so a killed process does not leave the wiki
unstartable.
There is no CI; tests.sh is the gate. It runs the formatter, go vet, the
build, the tests, and the tests again under the race detector.
$ ./tests.sh # everything, about two minutes
$ ./tests.sh --quick # no race pass, about ten seconds
Differences from Mycorrhiza Wiki
- English only. The interface and the help pages are in English; there is no language setting.
- Settings are edited in the admin panel, and take effect immediately.
- One feed format. Recent changes are published as JSON Feed; RSS and Atom are not produced. Their old addresses redirect.
- The listen address is a startup option, not part of the wiki's own settings.
- Signing in is required by default. A new wiki has no administrator until you create one.
Licence
AGPL-3.0. See license.txt. The licence is unchanged from upstream Mycorrhiza Wiki.
Thanks
Mojowiki is a fork of Mycorrhiza Wiki, created by Timur Ismagilov and improved by its contributors. Thank you for the engine this is built on.
Official repository: https://git.mojosa.su/service/mojowiki