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
-
+
[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
- engine
@@ -51,6 +51,5 @@
Description
Switch between source and target languages, as long as the source language isn't "auto"
- Return to Mai
diff --git a/docs/index.html b/docs/index.html
new file mode 100644
index 0000000..5b32e69
--- /dev/null
+++ b/docs/index.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ Mai | Documentation
+
+
+
+
+
+
+
+
diff --git a/static/docs.css b/docs/style.css
similarity index 100%
rename from static/docs.css
rename to docs/style.css
diff --git a/example/mai.ini b/example/mai.ini
new file mode 100644
index 0000000..2e69394
--- /dev/null
+++ b/example/mai.ini
@@ -0,0 +1,5 @@
+[mai]
+listen = "127.0.0.1:5000"
+rootdir = "./static"
+tmplpath = "./views"
+user = "www"
diff --git a/example/simplytranslate.ini b/example/simplytranslate.ini
deleted file mode 100644
index 126cf95..0000000
--- a/example/simplytranslate.ini
+++ /dev/null
@@ -1,3 +0,0 @@
-listen = "127.0.0.1:5000"
-rootdir = "/home/yakumo_izuru/Repos/simplytranslate/static"
-tmplpath = "./views"
diff --git a/rc.d/FreeBSD b/rc.d/FreeBSD
index 93d2119..a63d87c 100644
--- a/rc.d/FreeBSD
+++ b/rc.d/FreeBSD
@@ -13,9 +13,9 @@ rcvar="mai_enable"
load_rc_config $name
-: ${mai_user:="www"}
: ${mai_enable:="NO"}
: ${mai_config="/usr/local/etc/mai/mai.ini"}
+: ${mai_chdir="/usr/local/share/mai"}
pidfile="/var/run/${name}.pid"
command="/usr/sbin/daemon"
@@ -23,4 +23,6 @@ procname="/usr/local/bin/${name}"
mai_args="-f ${mai_config}"
command_args="-S -m 3 -s info -l daemon -p ${pidfile} /usr/bin/env ${procname} ${mai_args}"
+required_files="${mai_config}"
+
run_rc_command "$1"
diff --git a/rc.d/NetBSD b/rc.d/NetBSD
new file mode 100644
index 0000000..0ff793f
--- /dev/null
+++ b/rc.d/NetBSD
@@ -0,0 +1,26 @@
+#!/bin/sh
+# $TheSupernovaDuo$
+#
+# PROVIDE: mai
+# REQUIRE: NETWORKING DAEMON
+# BEFORE: LOGIN
+# KEYWORD: shutdown
+
+$_rc_subr_loaded . /etc/rc.subr
+
+name="mai"
+rcvar=$name
+command="/usr/pkg/bin/mai"
+command_args="-f /usr/pkg/etc/mai/mai.ini"
+pidfile="/var/run/${name}.pid"
+start_cmd="mai_start"
+
+required_files="/usr/pkg/etc/mai/mai.ini"
+
+mai_start() {
+ $command $command_args
+ pgrep -n $name > $pidfile
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/rc.d/immortal.yml b/rc.d/immortal.yml
index c4de33d..f4a5477 100644
--- a/rc.d/immortal.yml
+++ b/rc.d/immortal.yml
@@ -1,2 +1 @@
cmd: /usr/local/bin/mai -f /usr/local/etc/mai/mai.ini
-user: www