- Timestamp:
- Feb 7, 2024, 12:26:14 AM (16 months ago)
- Location:
- trunk
- Files:
-
- 4 added
- 1 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/README.md
r60 r67 2 2 A privacy friendly frontend to multiple translation engines. 3 3 4 ### History 5 1. SimplyTranslate was founded by [metalune and fattalion](https://codeberg.org/SimpleWeb/SimplyTranslate-Web). It was written in Python. 6 2. Fattalion created a Go implementation. 7 3. Both metalune and fattalion retired, and they handed SimplyTranslate over to ManeraKai. 8 4. [Izuru Yakumo The Violet Hermit](https://geidontei.chaotic.ninja/usr/yakumo_izuru) stole it, and renamed it after [Mai](https://en.touhouwiki.net/wiki/Mai) from [Mystic Square](https://en.touhouwiki.net/wiki/Mystic_Square) 9 10 ### Instances 11 | URL | Location | Cloudflare? | 12 |-----|----------|-------------| 13 | [tr.chaotic.ninja](https://tr.chaotic.ninja) | DE | No | 14 15 ### Installation 16 17 ```shell 18 % git clone https://git.chaotic.ninja/yakumo.izuru/mai 19 % cd mai 20 % make 21 # make install 22 ``` 23 24 ### Setup 25 For [nginx](https://www.nginx.com) you can use this snippet, this also serves the static resources. 26 27 ```nginx 28 location / { 29 proxy_set_header Host $host; 30 proxy_pass http://localhost:5000; 31 } 32 ``` 33 34 ### Legal notice 35 Mai does not host any content. All content shown on any Mai instances is from [Google Translate](https://translate.google.com), [Reverso](https://www.reverso.net/), [iCIBA](https://www.iciba.net) and [LibreTranslate](https://libretranslate.com) 36 37 Mai is not affiliated with none of the above, which this program relays. 38 39 Trademarks belong to their respective owners. 40 Google Translate is a trademark of [Google LLC](https://www.google.com). Reverso is a trademark of Reverso, et cetera. 41 42 The creators and maintainers of this repository assume no liability for the accuracy and timeliness of any information provided above. Trademark owner information was researched to the best of the author's knowledge at the time of curation and may be outdated or incorrect. 4 * [How to install](INSTALL.md) 5 * [List of instances](INSTANCES.md) 6 * [Legal notice](LEGAL.md) 43 7 44 8 ### Other projects -
trunk/cmd/mai/main.go
r66 r67 22 22 var ( 23 23 configfile string 24 groupname string 25 username string 24 26 ) 25 27 var conf struct { 26 group string27 28 listen string 28 29 staticpath string 29 30 tmplpath string 30 user string31 31 } 32 32 func main() { … … 42 42 conf.tmplpath = "./views" 43 43 44 if conf.user!= "" {45 uid, gid, err := usergroupids( conf.user, conf.group)44 if username != "" { 45 uid, gid, err := usergroupids(username, groupname) 46 46 if err != nil { 47 47 fmt.Println(err) … … 259 259 } 260 260 }) 261 app.Get("/robots.txt", func(c *fiber.Ctx) error { 262 return c.SendString("User-Agent: *\nDisallow: /\n") 263 }) 261 264 app.Get("/version", func(c *fiber.Ctx) error { 262 265 return c.JSON(fiber.Map{ -
trunk/cmd/mai/parseflags.go
r66 r67 8 8 func parseFlags() { 9 9 flag.StringVar(&configfile, "f", "", "Configuration file") 10 flag.StringVar(&username, "u", "", "Sets the user to which privilege dropping is done") 11 flag.StringVar(&groupname, "g", "", "Sets the group to which privilege dropping is done") 10 12 flag.Parse() 11 13 } -
trunk/cmd/mai/readconf.go
r66 r67 11 11 return err 12 12 } 13 conf.group = cfg.Section("mai").Key("group").String()14 13 conf.listen = cfg.Section("mai").Key("listen").String() 15 14 conf.staticpath = cfg.Section("mai").Key("static").String() 16 15 conf.tmplpath = cfg.Section("mai").Key("templates").String() 17 conf.user = cfg.Section("mai").Key("user").String()18 16 19 17 return nil -
trunk/cmd/mai/usergroupids.go
r63 r67 15 15 gid, _ := strconv.Atoi(u.Gid) 16 16 17 if conf.group!= "" {17 if groupname != "" { 18 18 g, err := user.LookupGroup(groupname) 19 19 if err != nil { -
trunk/docs/api/index.html
r66 r67 8 8 </head> 9 9 <body id="body"> 10 <h1 id="header">API Documentation</h1> 11 <br><hr> 12 <h2 class="get">[GET] /api/translate</h2> 13 <h2 class="post">[POST] /api/translate</h2> 14 <h3>Description</h3> 15 <p>Translation endpoint, input must be URL-encoded (e.g. multi-byte characters, words separated by space)</p> 16 <h3>Arguments</h3> 17 <ul> 18 <li>engine</li> 19 <li>from</li> 20 <li>text</li> 21 <li>to</li> 22 </ul> 23 <h3>Examples</h3> 24 <p><pre><code>GET /api/translate?engine=google&from=auto&to=en&text="sonrisa"</code></pre></p> 25 <hr> 26 <h2 class="get">[GET] /api/source_languages</h2> 27 <h2 class="get">[GET] /api/target_languages</h2> 28 <h3>Description</h3> 29 <p>Get a JSON array of supported source and target languages for a particular engine</p> 30 <h3>Arguments</h3> 31 <ul> 32 <li>engine</li> 33 </ul> 34 <h3>Examples</h3> 35 <p><pre><code>GET /api/source_languages?engine=google</code></pre></p> 36 <p><pre><code>GET /api/target_languages?engine=google</code></pre></p> 37 <hr> 38 <h2 class="get">[GET] /api/tts</h2> 39 <h3>Description</h3> 40 <p>Obtain text-to-speech audio files from an engine, provided said engine supports them</p> 41 <h3>Arguments</h3> 42 <ul> 43 <li>engine</li> 44 <li>lang</li> 45 <li>text</li> 46 </ul> 47 <h3>Examples</h3> 48 <p><pre><code>GET /api/tts?engine=google&lang=en&text="hi"</code></pre></p> 49 <hr> 50 <h2 class="post">[POST] /switchlanguages</h2> 51 <h3>Description</h3> 52 <p>Switch between source and target languages, as long as the source language isn't "auto"</p> 53 <hr> 10 <h1>API documentation</h1> 11 <table border="1" align="center"> 12 <tr> 13 <td> 14 <h2 class="get">[GET] /api/translate</h2> 15 <h2 class="post">[POST] /api/translate</h2> 16 <h3>Description</h3> 17 <p>Translation endpoint, input must be URL-encoded (e.g. multi-byte characters, words separated by space)</p> 18 <h3>Arguments</h3> 19 <ul> 20 <li>engine</li> 21 <li>from</li> 22 <li>text</li> 23 <li>to</li> 24 </ul> 25 </td> 26 </tr> 27 <tr> 28 <td> 29 <h2 class="get">[GET] /api/source_languages</h2> 30 <h2 class="get">[GET] /api/target_languages</h2> 31 <h3>Description</h3> 32 <p>Get a JSON array of supported source and target languages for a particular engine</p> 33 <h3>Arguments</h3> 34 <ul> 35 <li>engine</li> 36 </ul> 37 </td> 38 </tr> 39 <tr> 40 <td> 41 <h2 class="get">[GET] /api/tts</h2> 42 <h3>Description</h3> 43 <p>Obtain text-to-speech audio files from an engine, provided said engine supports them</p> 44 <h3>Arguments</h3> 45 <ul> 46 <li>engine</li> 47 <li>lang</li> 48 <li>text</li> 49 </ul> 50 </td> 51 </tr> 52 <tr> 53 <td> 54 <h2 class="get">[GET] /robots.txt</h2> 55 </td> 56 </tr> 57 <tr> 58 <td> 59 <h2 class="post">[POST] /switchlanguages</h2> 60 <h3>Description</h3> 61 <p>Switch between source and target languages, as long as the source language isn't "auto"</p> 62 <p>Must only be called inside the form interface</p> 63 </td> 64 </tr> 65 <tr> 66 <td> 67 <h2 class="get">[GET] /version</h2> 68 <h3>Description</h3> 69 <p>Return the software version as a JSON array</p> 70 </td> 71 </tr> 72 </table> 54 73 </body> 55 74 </html> -
trunk/docs/index.html
r66 r67 7 7 <title>Mai | Documentation</title> 8 8 </head> 9 <body id="body"> 10 <img src="/static/favicon128x128.png" style="text-align: center;"> 11 <h1 id="header">Documentation</h1> 12 <ul id="nav"> 13 <li><a href="/docs/api">API</a></li> 14 </ul> 9 <body> 10 <table> 11 <tr><td> 12 <table border="1" align="left"> 13 <tr> 14 <td><a href="/docs/api">API</a></td> 15 </tr> 16 </table> 17 </tr></td> 18 <tr><td> 19 <table border="1" align="center"> 20 <tr> 21 <td> 22 <p>Welcome to Mai's documentation!<p> 23 <p>See the menu for the available entries</p> 24 <p>Anything else is covered by the man pages</p> 25 </td> 26 </tr> 27 </table> 28 </td></tr> 29 </table> 15 30 </body> 16 31 </html> -
trunk/docs/style.css
r66 r67 1 /*2 * Taken from vnpower3 */4 5 * {6 box-sizing: border-box; }7 8 1 body { 9 top: 0; 10 margin: 0; 11 background-color: #1d1f21; 12 color: white; 13 font-family: "Open Sans", "Roboto", "Noto Sans", "Noto Sans CJK JP", sans-serif; 14 line-height: 1.618; 2 background-color: #f8cfd2; 3 color: rgb(206, 147, 191); 15 4 } 16 5 17 h2.get{18 color: orange;6 a, a:visited { 7 color: rgb(206, 147, 191); 19 8 } 20 9 21 h2.post { 22 color: green; 10 @media screen and (prefers-color-scheme: dark) { 11 body { 12 background-color: #700000; 13 color: #ffffff; 14 } 15 a, a:visited { 16 color: #18c018; 17 } 23 18 } 24 19 25 @media (max-width: 684px) { 26 body { 27 font-size: 1rem; } } 28 29 @media (max-width: 382px) { 30 body { 31 font-size: 1rem; } } 32 33 a { 34 color: #81a2be; 35 text-decoration-color: #81a2be; } 36 37 #header { 38 width: 100%; 39 min-width: 320px; 40 background-color: #282a2e; } 41 42 #header img { 43 width: 280px; } 44 45 #header-content { 46 margin: 0 auto; 47 width: min-content; } 48 49 #nav { 50 display: flex; 51 justify-content: center; 52 background-color: #373b41; } 53 54 #footer { 55 margin-top: 0.5rem; 56 text-align: center; } 57 58 #body { 59 min-height: 75vh; 60 max-width: 800px; 61 margin: 1rem auto; 62 padding: 0 0.6rem; } 63 #body h1, 64 #body h2, 65 #body h3, 66 #body h4, 67 #body h5, 68 #body h6 { 69 line-height: 1.1; 70 font-family: sans-serif; 71 font-weight: 700; 72 margin-top: 1rem; 73 margin-bottom: 1rem; 74 overflow-wrap: break-word; 75 word-wrap: break-word; 76 -ms-word-break: break-all; 77 word-break: break-word; } 78 #body h1 { 79 border-bottom: 1px solid #b5bd68; 80 display: block; } 81 #body p { 82 margin-top: 0px; 83 margin-bottom: 0.5rem; } 84 #body li > p { 85 padding: 0; 86 margin: 0; } 87 #body small, 88 #body sub, 89 #body sup { 90 font-size: 75%; } 91 #body img, 92 #body video { 93 height: auto; 94 max-width: 100%; 95 margin-top: 0.5rem; 96 margin-bottom: 0.5rem; 97 box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.12), 0px 2px 2px 0px rgba(0, 0, 0, 0.12), 0px 4px 4px 0px rgba(0, 0, 0, 0.12), 0px 8px 8px 0px rgba(0, 0, 0, 0.12), 0px 16px 16px 0px rgba(0, 0, 0, 0.12); } 98 #body pre { 99 background-color: #373b41; 100 display: block; 101 padding: 1em; 102 overflow-x: auto; 103 margin-top: 0px; 104 margin-bottom: 0.5rem; } 105 #body code, #body kbd, #body samp { 106 padding: 0 0.5em; 107 background-color: #373b41; 108 white-space: pre-wrap; } 109 #body pre > code { 110 padding: 0; 111 background-color: transparent; 112 white-space: pre; 113 font-size: 1em; } 114 20 table { 21 border-color: white; 22 } -
trunk/engines/engine.go
r60 r67 25 25 "google": &GoogleTranslate{}, 26 26 "reverso": &Reverso{}, 27 "iciba": &ICIBA{},28 27 "libretranslate": &LibreTranslate{ 29 28 InstanceURL: os.Getenv("MAI_LIBRETRANSLATE_INSTANCE"), -
trunk/example/mai.ini
r66 r67 3 3 rootdir = "./static" 4 4 tmplpath = "./views" 5 user = "www" -
trunk/mai.1
r65 r67 8 8 .Nm 9 9 .Op Fl f Ar config-file 10 .Op Fl u Ar user 11 .Op Fl g Ar group 10 12 .Sh DESCRIPTION 11 13 This project has been forked from the remains of the … … 15 17 Much to anyone's dismay, this was named after 16 18 .Lk https://en.touhouwiki.net/wiki/Mai Mai from Mystic Square 19 .Sh FEATURES 20 .Bl -tag -width 11n -compact 21 .It Command-line tool 22 See 23 .Xr suwako 1 24 .It Privilege dropping 25 Stolen from 26 .Xr partage 1 27 just so you do not run this as root 28 .El 17 29 .Sh AUTHORS 18 30 .An fattalion … … 21 33 .Sh MAINTAINERS 22 34 .An Izuru Yakumo Aq Mt yakumo.izuru@chaotic.ninja 23 .Sh BUGS24 iCIBA engine doesn't work, throws HTTP 500 -
trunk/mai.ini.5
r63 r67 8 8 .Ss [mai] section 9 9 .Bl -tag -width 11n 10 .It group11 Group ID for dropping privileges to.12 If unset, assume the GID of user13 10 .It listen 14 11 HTTP port for the server to listen. … … 20 17 Directory where the templates are located. 21 18 Default is "./views" 22 .It user23 User ID for dropping privileges to.24 19 .El 25 20 .Sh ENVIRONMENT -
trunk/rc.d/FreeBSD
r66 r67 21 21 command="/usr/sbin/daemon" 22 22 procname="/usr/local/bin/${name}" 23 mai_args="-f ${mai_config} "23 mai_args="-f ${mai_config} -u www -g www" 24 24 command_args="-S -m 3 -s info -l daemon -p ${pidfile} /usr/bin/env ${procname} ${mai_args}" 25 25 -
trunk/rc.d/NetBSD
r66 r67 12 12 rcvar=$name 13 13 command="/usr/pkg/bin/mai" 14 command_args="-f /usr/pkg/etc/mai/mai.ini "14 command_args="-f /usr/pkg/etc/mai/mai.ini -u www -g www" 15 15 pidfile="/var/run/${name}.pid" 16 16 start_cmd="mai_start" -
trunk/rc.d/OpenBSD
r56 r67 3 3 4 4 daemon="/usr/local/bin/mai" 5 daemon_flags="-f /usr/local/etc/mai/mai.ini "5 daemon_flags="-f /usr/local/etc/mai/mai.ini -u www -g www" 6 6 7 7 . /etc/rc.d/rc.subr -
trunk/rc.d/immortal.yml
r66 r67 1 cmd: /usr/local/bin/mai -f /usr/local/etc/mai/mai.ini 1 cmd: /usr/local/bin/mai -f /usr/local/etc/mai/mai.ini -g www -u www 2 cwd: /usr/local/share/mai -
trunk/views/index.html
r56 r67 128 128 <footer class="center"> 129 129 <p> 130 <a href="https://git.chaotic.ninja/yakumo.izuru/mai">Source code</a><br> 131 a <em>Mirage AIB</em> project | Favicon source is <a href="https://pixiv.net/en/artworks/97787072">ユキマイ</a> 130 <a href="https://git.chaotic.ninja/yakumo.izuru/mai">Source code</a> 131 </p> 132 <p> 133 A <a href="https://mirage.h0stname.net">Mirage AIB</a> project 132 134 </p> 133 135 </footer>
Note:
See TracChangeset
for help on using the changeset viewer.