aboutsummaryrefslogtreecommitdiff
path: root/htdocs/public/metranslator/api
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2021-12-04 10:58:59 +0100
committerMinteck <contact@minteck.org>2021-12-04 10:58:59 +0100
commite618c3f52c1c4ae161650679cda24eecbba579bb (patch)
treea160a9f18847be1be73fb1c2ac2bc25b1e756e27 /htdocs/public/metranslator/api
parentbce13ee94deb2a4914784bb4268dc1d7bc0f11ed (diff)
downloadwolfeye-js-e618c3f52c1c4ae161650679cda24eecbba579bb.tar.gz
wolfeye-js-e618c3f52c1c4ae161650679cda24eecbba579bb.tar.bz2
wolfeye-js-e618c3f52c1c4ae161650679cda24eecbba579bb.zip
Code is now more cute!
Diffstat (limited to 'htdocs/public/metranslator/api')
-rw-r--r--htdocs/public/metranslator/api/index.ejs33
1 files changed, 33 insertions, 0 deletions
diff --git a/htdocs/public/metranslator/api/index.ejs b/htdocs/public/metranslator/api/index.ejs
new file mode 100644
index 0000000..47800bd
--- /dev/null
+++ b/htdocs/public/metranslator/api/index.ejs
@@ -0,0 +1,33 @@
+<%
+
+ res.writeHead(200, {'Content-Type': "application/json"});
+
+ if (get['t']) {
+ if (get['t'] === "en") {
+ target = "en";
+ } else {
+ target = "mt";
+ }
+ } else {
+ res.end();
+ }
+
+ if (get['u']) {
+ text = get['u'];
+
+ if (text.length > 500) {
+ res.end();
+ }
+
+ text = text.split("\"").join("''");
+ } else {
+ res.end();
+ }
+
+ aw = JSON.parse(child_process.execSync(`cd /mnt/metranslator-api && node index.js api ${target} "${text}"`).toString());
+ last = child_process.execSync("cd /mnt/metranslator-api && git log -1 --pretty=format:'%an'")
+ aw["system"]["version"] = aw["system"]["version"] + "-" + fs.readFileSync("/mnt/metranslator-api/.git/refs/heads/trunk").toString().substr(0, 8);
+ aw["system"]["last_author"] = last;
+ aw["call"] = "cd /mnt/metranslator-api && node index.js api {$target} \"{$text}\"";
+
+ %><%- JSON.stringify(aw); %> \ No newline at end of file