A TiddlyWiki HTTP Server written in Go.
cd
into the directory that was just created.empty.html
file inside the www
subfolder.empty.html
file to index.html
../twserver
.All server settings can be tweaked using a configuration file located beside the server binary.
The configuration file must use the same name as the binary and saved with the .json
extension.
Create a configuration file in JSON
format (on Linux/macOS):
touch twserver.json
Open the file with your favorite text editor and write the following values (default):
{
"Host": "",
"Port": 8080,
"DocumentRootDir": "./www",
"IndexFile": "index.html",
"BackupDir": "./backup",
"BackupFileFormat": ":name:.:date:.html",
"ServeDirs": [],
"LogFileName": "./logs/twserver.log",
"LogMaxSize": 4,
"LogMaxBackups": 16,
"LogMaxAge": 28,
"LogCompress": true
}
Tweak the values as needed, save the file and restart the server.
By default, the HTTP server only serves the index file and rejects any other request. To serve one or more custom directories containing extra resources (such as images), you have to add them by tweaking the ServeDirs
value in the configuration file.
images
directory located in ./images
and accessed via the URL <wiki_url>/img/
:
{
"ServeDirs": [
{
"URL": "/img/",
"Path": "./images"
}
]
}
./images
directory can now be reached via <wiki_url>/img/
and displayed inside any wiki post.Building is done with the go
tool. If you have setup your GOPATH
correctly, the following should work:
go get github.com/k4rian/twserver-go
go build -ldflags "-w -s" github.com/k4rian/twserver-go
The rotating logging system is powered by lumberjack:
gopkg.in/natefinch/lumberjack.v2="v2.2.1"
A Docker image is available on Docker Hub under k4rian/twserver and its corresponding source repository on GitHub.