これ以上壊れることはないと思いますか?
Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja> git-svn-id: file:///srv/svn/repo/mai/trunk@66 e410bdd4-646f-c54f-a7ce-fffcc4f439ae
This commit is contained in:
parent
119cdd14d4
commit
2435673dff
@ -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)
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -1,18 +1,18 @@
|
||||
<!DOCTYPE HTML PUBLIC "//W3C DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="/static/docs.css">
|
||||
<link rel="stylesheet" href="/docs/style.css">
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||
<meta name="author" content="Izuru Yakumo">
|
||||
<title>API Documentation | Mai</title>
|
||||
</head>
|
||||
<body id="body">
|
||||
<h1 id="header">Documentation</h1>
|
||||
<h1 id="header">API Documentation</h1>
|
||||
<br><hr>
|
||||
<h2 class="get">[GET] /api/translate</h2>
|
||||
<h2 class="post">[POST] /api/translate</h2>
|
||||
<h3>Description</h3>
|
||||
<p>Translation endpoint</p>
|
||||
<p>Translation endpoint, input must be URL-encoded (e.g. multi-byte characters, words separated by space)</p>
|
||||
<h3>Arguments</h3>
|
||||
<ul>
|
||||
<li>engine</li>
|
||||
@ -51,6 +51,5 @@
|
||||
<h3>Description</h3>
|
||||
<p>Switch between source and target languages, as long as the source language isn't "auto"</p>
|
||||
<hr>
|
||||
<a href="/">Return to Mai</a>
|
||||
</body>
|
||||
</html>
|
17
docs/index.html
Normal file
17
docs/index.html
Normal file
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="/docs/style.css">
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||
<meta name="author" content="Izuru Yakumo">
|
||||
<title>Mai | Documentation</title>
|
||||
</head>
|
||||
<body id="body">
|
||||
<img src="/static/favicon128x128.png" style="text-align: center;">
|
||||
<h1 id="header">Documentation</h1>
|
||||
<ul id="nav">
|
||||
<li><a href="/docs/api">API</a></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
|
5
example/mai.ini
Normal file
5
example/mai.ini
Normal file
@ -0,0 +1,5 @@
|
||||
[mai]
|
||||
listen = "127.0.0.1:5000"
|
||||
rootdir = "./static"
|
||||
tmplpath = "./views"
|
||||
user = "www"
|
@ -1,3 +0,0 @@
|
||||
listen = "127.0.0.1:5000"
|
||||
rootdir = "/home/yakumo_izuru/Repos/simplytranslate/static"
|
||||
tmplpath = "./views"
|
@ -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"
|
||||
|
26
rc.d/NetBSD
Normal file
26
rc.d/NetBSD
Normal file
@ -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"
|
@ -1,2 +1 @@
|
||||
cmd: /usr/local/bin/mai -f /usr/local/etc/mai/mai.ini
|
||||
user: www
|
||||
|
Loading…
x
Reference in New Issue
Block a user