omnisrv

Dynamic Site Server? Static Site Generator? I want both!

Poster

Poster: omnisrv

https://codeberg.org/NaitLee/omnisrv

Contents

Reason

Why should I make a choice, between heavy dynamic site solutions, and inflexible static site generators?

Why should I make a choice, between complex programmed sites, and boring text-file-based sites?

Sites using omnisrv

Site   Code   Note
unseen-site.fun Link This site
amaharacya.one Link dummy-ssg support too
fsfans.club Link Pending support

Should I use it?

As for now, omnisrv is experimental and lacks document. Before using it, consider the maintainence burden.

You will also need your own template. You can just modify and use templates of existing omnisrv sites.

Or you may want to wait until omnisrv releases and there is helpful document.

How is it like?

1. Basic

omnisrv has:

Just pick the one you’d like to use.

Example commands
apt install git golang 9mount
git clone https://codeberg.org/NaitLee/omnisrv.git

cd omnisrv
./build.sh
export PATH="$(pwd)/bin:$PATH"

cd ../unseen-site
# Dynamic server
omnisrv src

# Generate static HTML files
omnisrv-ssg src
python3 -m http.server -d out

# 9P file server
omnisrv-9p -proto unix -addr /tmp/omnisrv src
9mount 'unix!/tmp/omnisrv' /mnt/omnisrv
python3 -m http.server -d /mnt/omnisrv

Of course, use a better static file server than python3 -m http.server in production.

omnisrv is suitable for personal sites, git readmes, etc.

2. Documents

An omnisrv site can be composed with markdown, plain-text and HTML files, plus objects in JSON/YAML/TOML.

Let’s call them documents.

Example documents
---
date 2025-11-20
description Meta description
---

# Title

Hello, world!

---

Copyright
{
  "head": {
    "title": "My Gallery",
    "date": "2025-11-20",
    "gallery": true
  },
  "gallery": [{
    "name": "My cat",
    "img": "/pics/cat.jpg"
  }, {
    "name": "My dog",
    "img": "/pics/dog.jpg"
  }]
}

index.* and README.* are considered index document. They are used as index.html.

.txt files can have Dash Markup, which is rendered as Dash XML; real plain text is wrapped inside <pre>.

3. Template

Use a Go template to turn documents into webpages.

Templates can be found in source code of omnisrv sites, named tmpl.html.

Minimal template
<!doctype html>
<html>
<head>
  <title>{{.Title}}</title>
</head>
<body>
  <nav>
    <ul>
      {{range .ListM}}
      <li><a href="{{.Url}}">{{.Title}}</a></li>
      {{end}}
    </ul>
  </nav>
  <main>
    {{if .Head.gallery}}{{template "gallery" .}}
    {{else}}{{.Body}}
    {{end}}
  </main>
  <footer>{{.Footer}}</footer>
</body>
</html>

{{- define "gallery" -}}
{{with .Object}}
  {{range .gallery}}
  <p><img src="{{.img}}" /></p>
  <p>{{.name}}</p>
  {{end}}
{{end}}
{{- end -}}

Also see Go template document.

Security

Vectors

omnisrv: Server, only reads site files, has no code mutating the file system.
omnisrv-9p: Server, should use loopback network, won’t mutate file system.
omnisrv-ssg: Offline run-once tool.

Sandbox

You can use omnisrv (server) inside a lightweight sandbox like bubblewrap, or jails.

As ./build.sh builds omnisrv statically linked, it’s simple to do:

#!/bin/sh
exec bwrap \
  --unshare-all --share-net --clearenv --die-with-parent \
  --ro-bind /etc/resolv.conf /etc/resolv.conf \
  --ro-bind /opt/omnisrv/bin/omnisrv /omnisrv \
  --ro-bind /opt/mysite/src /src \
  /omnisrv /src

9P

With omnisrv-9p, you can use a secure static file server, while the underlying mounted 9P file system has dynamic read-only files.

Static

If you have serious security concerns, use omnisrv-ssg with a secure static file server, or just use something else you trust.

Disclaimer

No warranty!