mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-01-05 17:40:26 +00:00
Clean some stuff, update README.md
Now with pictures
This commit is contained in:
parent
839b1e2448
commit
d0c3225db5
32
README.md
32
README.md
@ -1,9 +1,11 @@
|
||||
# 🍄 Mycorrhiza Wiki 1.2
|
||||
A wiki engine.
|
||||
<img src="https://mycorrhiza.lesarbr.es/binary/release/1.2/screenshot" alt="A screenshot of Mycorrhiza Wiki home hypha in the Safari browser" width="500">
|
||||
|
||||
**Mycorrhiza Wiki** is a filesystem and git-based wiki engine.
|
||||
|
||||
[Main wiki](https://mycorrhiza.lesarbr.es)
|
||||
|
||||
# Usage
|
||||
## Usage
|
||||
```
|
||||
mycorrhiza [OPTIONS...] WIKI_PATH
|
||||
|
||||
@ -17,8 +19,8 @@ Options:
|
||||
```
|
||||
|
||||
## Features
|
||||
* Wiki pages (called hyphae) are written in mycomarkup
|
||||
* Edit pages through html forms, a graphical preview and a toolbar that helps you use mycomarkup
|
||||
* Wiki pages (called hyphae) are written in Mycomarkup
|
||||
* Edit pages through HTML forms, a graphical preview and a toolbar that helps you use Mycomarkup
|
||||
* Responsive design, dark theme (synced with system theme)
|
||||
* Works in text browsers
|
||||
* Everything is stored as simple files, no database required. You can run a wiki on almost any directory and get something to work with
|
||||
@ -33,22 +35,24 @@ Options:
|
||||
* Light on resources
|
||||
* Authorization with pre-set credentials, registration
|
||||
* Basic Gemini protocol support
|
||||
* Hotkeys (press `?` to see what hotkeys there are)
|
||||
|
||||
# Building
|
||||
## Building
|
||||
See [the guide](https://mycorrhiza.lesarbr.es/hypha/guide/deployment) on the wiki.
|
||||
|
||||
# Installing
|
||||
|
||||
## AUR
|
||||
## Installing
|
||||
|
||||
### AUR
|
||||
You can install Mycorrhiza Wiki from AUR using your favorite package manager on any Arch Linux-derivative distro (Arch, Manjaro, Garuda, etc):
|
||||
```sh
|
||||
yay -S mycorrhiza # or mycorrhiza-bin if you don't want to
|
||||
# build it from scratch
|
||||
# Build from sources
|
||||
yay -S mycorrhiza
|
||||
# OR
|
||||
# Use pre-built binaries from the Releases page
|
||||
yay -S mycorrhiza-bin
|
||||
```
|
||||
|
||||
## Docker
|
||||
|
||||
### Docker
|
||||
You can run Mycorrhiza Wiki in Docker using Dockerfile provided by this repository. Clone the repo and build the image:
|
||||
```sh
|
||||
git clone https://github.com/bouncepaw/mycorrhiza/
|
||||
@ -76,6 +80,6 @@ docker run -v /dev/shm/:/config -v /dev/shm/example-wiki:/wiki -p 80:1737 mycorr
|
||||
```
|
||||
|
||||
## Contributing
|
||||
Help is always needed. We have a [tg chat](https://t.me/mycorrhizadev) where some development is coordinated. You can also sponsor bouncepaw on [boosty](https://boosty.to/bouncepaw). Feel free to open an issue or contact us directly.
|
||||
We always need help. We have a [Telegram chat](https://t.me/mycorrhizadev) where we coordinate development. You can also sponsor @bouncepaw on [Boosty](https://boosty.to/bouncepaw). Feel free to open an issue or contact us directly.
|
||||
|
||||
You can view list of all planned features on [our kanban board](https://github.com/bouncepaw/mycorrhiza/projects/1).
|
||||
You can view list of many planned features on [our kanban board](https://github.com/bouncepaw/mycorrhiza/projects/1).
|
||||
|
@ -1,31 +0,0 @@
|
||||
# The Structure
|
||||
Here I am, doing new stuff before finishing the old stuff.
|
||||
|
||||
See https://github.com/bouncepaw/mycorrhiza/issues/57 for the discussion.
|
||||
|
||||
## The idea
|
||||
Instead of letting users figure everything out by themselves, we think of the best (in our opinion) file layout and force it onto the users and remove the possibility of configuring it.
|
||||
|
||||
## What is inside the Structure
|
||||
### Root
|
||||
The whole wiki is inside one directory or inside one of its subdirectories. Only the Mycorrhiza binary itself and Git (and possible future runtime dependencies) might be outside that directory. That directory (called _root directory_) can have any name.
|
||||
|
||||
### Subdirectories
|
||||
* `wiki.git` is a valid Git repository. If it is not present or is not a valid Git repository, the engine shall fail to work. When the Wizard is implemented, the engine will offer to make the Git repository.
|
||||
* `cache` contains temporary files such as user token caches. Wiki administrators can safely delete this directory and expect the wiki to continue working. In the future, stuff like pre-rendered HTML can be stored here.
|
||||
* All other subdirectories are ignored.
|
||||
|
||||
### User configuration
|
||||
* `registered-users.json` contains a JSON array of all registered users. The engine will edit this file, and the administrators should not edit by themselves, unless they really want to.
|
||||
* `fixed-users.json` contains a JSON array of all fixed users. Wiki administrators will edit this file by themselves.
|
||||
|
||||
### Wiki configuration
|
||||
* `config.ini` is the main configuration file.
|
||||
|
||||
### Customisation
|
||||
* `favicon.ico` is the Favicon as you know it.
|
||||
* `common.css` redefines the built-in CSS, the Common style.
|
||||
* `custom.css` is sent to the user after the Common style.
|
||||
|
||||
### Meta
|
||||
* `README.txt` contains a short description of the files that can be inside the Structure. A small reminder for the administrators.
|
57
util/util.go
57
util/util.go
@ -3,37 +3,19 @@ package util
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"github.com/bouncepaw/mycomarkup/util"
|
||||
"github.com/bouncepaw/mycorrhiza/cfg"
|
||||
"log"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/cfg"
|
||||
)
|
||||
|
||||
// PrepareRq strips the trailing / in rq.URL.Path. In the future it might do more stuff for making all request structs uniform.
|
||||
func PrepareRq(rq *http.Request) {
|
||||
rq.URL.Path = strings.TrimSuffix(rq.URL.Path, "/")
|
||||
}
|
||||
|
||||
// LettersNumbersOnly keeps letters and numbers only in the given string.
|
||||
func LettersNumbersOnly(s string) string {
|
||||
var (
|
||||
ret strings.Builder
|
||||
usedUnderscore bool
|
||||
)
|
||||
for _, r := range s {
|
||||
if unicode.IsLetter(r) || unicode.IsNumber(r) {
|
||||
ret.WriteRune(r)
|
||||
usedUnderscore = false
|
||||
} else if !usedUnderscore {
|
||||
ret.WriteRune('_')
|
||||
usedUnderscore = true
|
||||
}
|
||||
}
|
||||
return strings.Trim(ret.String(), "_")
|
||||
}
|
||||
|
||||
// ShorterPath is used by handlerList to display shorter path to the files. It simply strips WikiGitDir.
|
||||
func ShorterPath(path string) string {
|
||||
if strings.HasPrefix(path, cfg.WikiGitDir) {
|
||||
@ -50,16 +32,17 @@ func ShorterPath(path string) string {
|
||||
func HTTP404Page(w http.ResponseWriter, page string) {
|
||||
w.Header().Set("Content-Type", "text/html;charset=utf-8")
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
w.Write([]byte(page))
|
||||
_, _ = w.Write([]byte(page))
|
||||
}
|
||||
|
||||
// HTTP200Page wraps some frequently used things for successful 200 responses.
|
||||
func HTTP200Page(w http.ResponseWriter, page string) {
|
||||
w.Header().Set("Content-Type", "text/html;charset=utf-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte(page))
|
||||
_, _ = w.Write([]byte(page))
|
||||
}
|
||||
|
||||
// RandomString generates a random string of the given length. It is cryptographically secure to some extent.
|
||||
func RandomString(n int) (string, error) {
|
||||
bytes := make([]byte, n)
|
||||
if _, err := rand.Read(bytes); err != nil {
|
||||
@ -68,36 +51,30 @@ func RandomString(n int) (string, error) {
|
||||
return hex.EncodeToString(bytes), nil
|
||||
}
|
||||
|
||||
// Strip hypha name from all ancestor names, replace _ with spaces, title case
|
||||
// BeautifulName makes the ugly name beautiful by replacing _ with spaces and using title case.
|
||||
func BeautifulName(uglyName string) string {
|
||||
if uglyName == "" {
|
||||
return uglyName
|
||||
}
|
||||
return strings.Title(strings.ReplaceAll(uglyName, "_", " "))
|
||||
// Why not reuse
|
||||
return util.BeautifulName(uglyName)
|
||||
}
|
||||
|
||||
// CanonicalName makes sure the `name` is canonical. A name is canonical if it is lowercase and all spaces are replaced with underscores.
|
||||
func CanonicalName(name string) string {
|
||||
return strings.ToLower(
|
||||
strings.ReplaceAll(
|
||||
strings.TrimRight(
|
||||
strings.TrimLeft(name, "_"),
|
||||
"_",
|
||||
), " ", "_"))
|
||||
return util.CanonicalName(name)
|
||||
}
|
||||
|
||||
// HyphaPattern is a pattern which all hyphae must match.
|
||||
var HyphaPattern = regexp.MustCompile(`[^?!:#@><*|"'&%{}]+`)
|
||||
// hyphaPattern is a pattern which all hypha names must match.
|
||||
var hyphaPattern = regexp.MustCompile(`[^?!:#@><*|"'&%{}]+`)
|
||||
|
||||
var UsernamePattern = regexp.MustCompile(`[^?!:#@><*|"'&%{}/]+`)
|
||||
var usernamePattern = regexp.MustCompile(`[^?!:#@><*|"'&%{}/]+`)
|
||||
|
||||
// IsCanonicalName checks if the `name` is canonical.
|
||||
func IsCanonicalName(name string) bool {
|
||||
return HyphaPattern.MatchString(name)
|
||||
return hyphaPattern.MatchString(name)
|
||||
}
|
||||
|
||||
// IsPossibleUsername is true if the given username is ok. Same as IsCanonicalName, but cannot have / in it and cannot be equal to "anon" or "wikimind"
|
||||
func IsPossibleUsername(username string) bool {
|
||||
return username != "anon" && UsernamePattern.MatchString(strings.TrimSpace(username))
|
||||
return username != "anon" && username != "wikimind" && usernamePattern.MatchString(strings.TrimSpace(username))
|
||||
}
|
||||
|
||||
// HyphaNameFromRq extracts hypha name from http request. You have to also pass the action which is embedded in the url or several actions. For url /hypha/hypha, the action would be "hypha".
|
||||
@ -108,6 +85,6 @@ func HyphaNameFromRq(rq *http.Request, actions ...string) string {
|
||||
return CanonicalName(strings.TrimPrefix(p, "/"+action+"/"))
|
||||
}
|
||||
}
|
||||
log.Println("HyphaNameFromRq: this request is invalid, fallback to home hypha")
|
||||
log.Println("HyphaNameFromRq: this request is invalid, fall back to home hypha")
|
||||
return cfg.HomeHypha
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user