1
0
mirror of https://dev.s-ul.net/Galexion/MaiMaiDXNet.git synced 2024-11-24 03:20:10 +01:00

made it so artemis memorial photos are accessible, and made it so you can change the port within the config file.

This commit is contained in:
Galexion 2023-07-17 02:16:54 -04:00
parent 319ae958cc
commit 025a78d824
8 changed files with 67 additions and 14 deletions

View File

@ -1,8 +1,8 @@
const { serverType, ArtConnSettings, DXMemorialImageDirectory } = require('./config.json'); const { serverType, ArtConnSettings, aquaSrvDir } = require('./config.json');
const sqlite3 = require('sqlite3').verbose(); const sqlite3 = require('sqlite3').verbose();
var db = undefined; var db = undefined;
if (serverType === 0) { if (serverType === 0) {
db = new sqlite3.Database(DXMemorialImageDirectory + '\\db.sqlite'); db = new sqlite3.Database(aquaSrvDir + '\\db.sqlite');
} }
const mysql = require('mysql'); const mysql = require('mysql');
var con = mysql.createConnection(ArtConnSettings) var con = mysql.createConnection(ArtConnSettings)

View File

@ -10,7 +10,32 @@ var apiRouter = require('./routes/api');
var config = require("./config.json"); var config = require("./config.json");
if (config.serverType === 0) { // Only run the image Importer when Aqua is active if (config.serverType === 0) { // Only run the image Importer when Aqua is active
const watcher = chokidar.watch(config.DXMemorialImageDirectory, { const watcher = chokidar.watch(config.aquaSrvDir, {
persistent: true
});
watcher
.on('add', (filePath) => {
const isImage = /\.(jpe?g|png|gif)$/i.test(filePath);
if (isImage) {
const fileName = path.basename(filePath);
const destPath = path.join(config.imageFolder, fileName);
fs.access(destPath, (err) => {
if (err) {
fs.copyFile(filePath, destPath, (err) => {
if (err) throw err;
console.log(`${fileName} Imported.`);
});
} else {
}
});
}
})
.on('error', (error) => {
console.error(`Watcher error: ${error}`);
});
} else if (config.ArtImageDirectory){
const watcher = chokidar.watch(config.ArtImageDirectory, {
persistent: true persistent: true
}); });

View File

@ -51,7 +51,7 @@ form.addEventListener("submit", function (event) {
let releventData = { let releventData = {
luid: data.data.luid || data.data.access_code, luid: data.data.luid || data.data.access_code,
ext_id: data.data.ext_id ext_id: data.data.ext_id || data.data.user
} }
console.log(releventData) console.log(releventData)
// Set the cookie expiration to 7 days from now // Set the cookie expiration to 7 days from now

View File

@ -371,7 +371,11 @@ async function userImageFormatter(div) {
memorialImage.addEventListener("error", function () { memorialImage.addEventListener("error", function () {
this.src = "assets/icon/UI_Icon_000000.png"; this.src = "assets/icon/UI_Icon_000000.png";
}); });
memorialImage.src = "images/" + imageName + '.jpg'; if(window.serverType === 0) {
memorialImage.src = "images/" + imageName + '.jpg';
} else {
memorialImage.src = "images/" + imageName + '.jpeg';
}
imageInfoDiv.append(memorialImage) imageInfoDiv.append(memorialImage)
} }
} }

View File

@ -47,7 +47,8 @@ Create a `config.json` file and paste this in, with paths to your instance.
"user":"MaiDXNet", "user":"MaiDXNet",
"password":"aSecurePassword" "password":"aSecurePassword"
}, },
"imageFolder": "N:\\MaiMaiDXNet\\public\\images" "imageFolder": "N:\\MaiMaiDXNet\\public\\images",
"hostPort": "8000"
} }
``` ```
@ -59,20 +60,20 @@ Note: `imageFolder` leads to the `/public/images` folder of the directory.
## Artemis ## Artemis
### WARNING: Artemis currently does not have support for Memorial Photos, and none will be imported when attempting to use Artemis.
Create a `config.json` file and paste this in, with paths to your instance. Create a `config.json` file and paste this in, with paths to your instance.
```json ```json
{ {
"serverType": 1, "serverType": 1,
"aquaSrvDir": "A:\\path\\to\\aqua\\data", "ArtImageImport": true,
"ArtImageDirectory":"S:\\Artemis\\Server\\Image\\Directory",
"ArtConnSettings": { "ArtConnSettings": {
"host":"192.168.smt.hng", "host":"192.168.smt.hng",
"user":"MaiDXNet", "user":"MaiDXNet",
"pass":"aSecurePassword" "pass":"aSecurePassword"
}, },
"imageFolder": "N:\\MaiMaiDXNet\\public\\images" "imageFolder": "N:\\MaiMaiDXNet\\public\\images",
"hostPort": "8000"
} }
``` ```
@ -87,6 +88,17 @@ CREATE USER 'MaiDXNet'@'%' IDENTIFIED BY 'aSecurePassword';
GRANT Alter,Create,Delete,Drop,Index,Insert,References,Select,Update ON aime.* TO 'MaiDXNet'@'%'; GRANT Alter,Create,Delete,Drop,Index,Insert,References,Select,Update ON aime.* TO 'MaiDXNet'@'%';
``` ```
Note: you'll need to configure `mai2.yaml` to enable Photo Sending to Artemis. Ensure that you have a image directory ready.
```yaml
photos: True
photos_dir: "S:\\Artemis\\Server\\Image\\Directory"
movies: false
movies_dir: "S:\\Artemis\\Server\\Movie\\Directory"
```
If you can't update Artemis to a version that supports Photo Exporting, or simply don't want to use Memorial Photo's, please set `"ArtImageImport": false`.
# Project Progress # Project Progress
Goal for Milestone 1: Goal for Milestone 1:

View File

@ -78,11 +78,13 @@ var {getExtId,getUserArea,getUserScores,getUserUnbanned,getUserBanned, getUserDa
}); });
router.get('/getmemorialimagelist/', function (req,res,next) { router.get('/getmemorialimagelist/', function (req,res,next) {
let ext = ".jpg"; let ext = ".jpg";
let ext2 = ".jpeg";
// Use fs.readdirSync() to get the file names synchronously // Use fs.readdirSync() to get the file names synchronously
const files = fs.readdirSync(config.DXMemorialImageDirectory); const files = fs.readdirSync(config.imageFolder);
// Filter the files by extension and create an array of names // Filter the files by extension and create an array of names
const imageNames = files.filter(file => file.endsWith(ext)).map(file => file.slice(0, -ext.length)); const imageNames = files.filter(file => file.endsWith('.jpg') || file.endsWith('.jpeg')).map(file => file.endsWith('.jpeg') ? file.slice(0, -5) : file.slice(0, -4));
// Create and return a JSON object with the image names // Create and return a JSON object with the image names
res.send(imageNames); res.send(imageNames);
}); });

View File

@ -30,7 +30,7 @@ router.get('/user', async function (req, res, next) {
if (cookies.aime_card_id === undefined) { if (cookies.aime_card_id === undefined) {
return res.redirect("/") return res.redirect("/")
} }
res.render('user', { title: title, userdata: await getUserData(req) }); res.render('user', { title: title, userdata: await getUserData(req), params:{serverType: config.serverType}});
} catch (err) { } catch (err) {
res.render('error', { error: err }); res.render('error', { error: err });
} }

View File

@ -1,4 +1,5 @@
<% var rootPath='../' ; %> <% var rootPath='../' ; %>
<%- include(rootPath + 'templates/header.ejs' ); %> <%- include(rootPath + 'templates/header.ejs' ); %>
<% function normalizeText(text) { return text .normalize('NFD') .replace(/[\u0300-\u036f]/g, '' <% function normalizeText(text) { return text .normalize('NFD') .replace(/[\u0300-\u036f]/g, ''
).replace(/[\uFF01-\uFF5E]/g, function(ch) { return String.fromCharCode(ch.charCodeAt(0) - 0xFEE0); }); } %> ).replace(/[\uFF01-\uFF5E]/g, function(ch) { return String.fromCharCode(ch.charCodeAt(0) - 0xFEE0); }); } %>
@ -20,6 +21,15 @@ if(userdata.user_name !== undefined) {
} }
} }
%> %>
<% if (params.serverType===0) { %>
<script>
window.serverType = 0;
</script>
<% } else { %>
<script>
window.serverType = 1;
</script>
<% } %>
<div id="User"> <div id="User">
<h1>Yo! Welcome Back <%= normalizeText(user.user_name) %>!</h1> <h1>Yo! Welcome Back <%= normalizeText(user.user_name) %>!</h1>