From 2435673dff7d6e57aaf24f8dc2e3c7c16d36d0a4 Mon Sep 17 00:00:00 2001 From: "yakumo.izuru" Date: Sun, 21 Jan 2024 15:43:25 +0000 Subject: [PATCH] =?UTF-8?q?=E3=81=93=E3=82=8C=E4=BB=A5=E4=B8=8A=E5=A3=8A?= =?UTF-8?q?=E3=82=8C=E3=82=8B=E3=81=93=E3=81=A8=E3=81=AF=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=81=A8=E6=80=9D=E3=81=84=E3=81=BE=E3=81=99=E3=81=8B=EF=BC=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Izuru Yakumo git-svn-id: file:///srv/svn/repo/mai/trunk@66 e410bdd4-646f-c54f-a7ce-fffcc4f439ae --- cmd/mai/main.go | 8 ++++++++ cmd/mai/{flag.go => parseflags.go} | 0 cmd/mai/readconf.go | 1 - {static/docs => docs/api}/index.html | 7 +++---- docs/index.html | 17 +++++++++++++++++ static/docs.css => docs/style.css | 0 example/mai.ini | 5 +++++ example/simplytranslate.ini | 3 --- rc.d/FreeBSD | 4 +++- rc.d/NetBSD | 26 ++++++++++++++++++++++++++ rc.d/immortal.yml | 1 - 11 files changed, 62 insertions(+), 10 deletions(-) rename cmd/mai/{flag.go => parseflags.go} (100%) rename {static/docs => docs/api}/index.html (89%) create mode 100644 docs/index.html rename static/docs.css => docs/style.css (100%) create mode 100644 example/mai.ini delete mode 100644 example/simplytranslate.ini create mode 100644 rc.d/NetBSD diff --git a/cmd/mai/main.go b/cmd/mai/main.go index 609fd31..bd17042 100644 --- a/cmd/mai/main.go +++ b/cmd/mai/main.go @@ -14,6 +14,7 @@ import ( "marisa.chaotic.ninja/mai/engines" "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v2/middleware/favicon" "github.com/gofiber/fiber/v2/middleware/logger" "github.com/gofiber/fiber/v2/middleware/limiter" "github.com/gofiber/template/html/v2" @@ -60,6 +61,12 @@ func main() { Views: engine, }) + app.Use(favicon.New( + favicon.Config{ + File: conf.staticpath + "/favicon.ico", + }, + )) + app.Use(logger.New( logger.Config{ Format: "==> ${ip}:${port} ${status} - ${method} ${path}\n", @@ -280,5 +287,6 @@ func main() { ByteRange: true, Browse: true, }) + app.Static("/docs", "./docs", fiber.Static{}) app.Listen(conf.listen) } diff --git a/cmd/mai/flag.go b/cmd/mai/parseflags.go similarity index 100% rename from cmd/mai/flag.go rename to cmd/mai/parseflags.go diff --git a/cmd/mai/readconf.go b/cmd/mai/readconf.go index 4fe9248..9e86bb3 100644 --- a/cmd/mai/readconf.go +++ b/cmd/mai/readconf.go @@ -10,7 +10,6 @@ func readConf(file string) error { if err != nil { return err } - conf.group = cfg.Section("mai").Key("group").String() conf.listen = cfg.Section("mai").Key("listen").String() conf.staticpath = cfg.Section("mai").Key("static").String() diff --git a/static/docs/index.html b/docs/api/index.html similarity index 89% rename from static/docs/index.html rename to docs/api/index.html index c61ea82..ef9b03e 100644 --- a/static/docs/index.html +++ b/docs/api/index.html @@ -1,18 +1,18 @@ - + API Documentation | Mai -

Documentation

+

API Documentation



[GET] /api/translate

[POST] /api/translate

Description

-

Translation endpoint

+

Translation endpoint, input must be URL-encoded (e.g. multi-byte characters, words separated by space)

Arguments