mirror of
https://dev.s-ul.net/Galexion/MaiMaiDXNet.git
synced 2024-11-24 00:50: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:
parent
319ae958cc
commit
025a78d824
@ -1,8 +1,8 @@
|
||||
const { serverType, ArtConnSettings, DXMemorialImageDirectory } = require('./config.json');
|
||||
const { serverType, ArtConnSettings, aquaSrvDir } = require('./config.json');
|
||||
const sqlite3 = require('sqlite3').verbose();
|
||||
var db = undefined;
|
||||
if (serverType === 0) {
|
||||
db = new sqlite3.Database(DXMemorialImageDirectory + '\\db.sqlite');
|
||||
db = new sqlite3.Database(aquaSrvDir + '\\db.sqlite');
|
||||
}
|
||||
const mysql = require('mysql');
|
||||
var con = mysql.createConnection(ArtConnSettings)
|
||||
|
27
index.js
27
index.js
@ -10,7 +10,32 @@ var apiRouter = require('./routes/api');
|
||||
var config = require("./config.json");
|
||||
|
||||
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
|
||||
});
|
||||
|
||||
|
@ -51,7 +51,7 @@ form.addEventListener("submit", function (event) {
|
||||
|
||||
let releventData = {
|
||||
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)
|
||||
// Set the cookie expiration to 7 days from now
|
||||
|
@ -371,7 +371,11 @@ async function userImageFormatter(div) {
|
||||
memorialImage.addEventListener("error", function () {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
22
readme.md
22
readme.md
@ -47,7 +47,8 @@ Create a `config.json` file and paste this in, with paths to your instance.
|
||||
"user":"MaiDXNet",
|
||||
"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
|
||||
|
||||
### 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.
|
||||
|
||||
```json
|
||||
{
|
||||
"serverType": 1,
|
||||
"aquaSrvDir": "A:\\path\\to\\aqua\\data",
|
||||
"ArtImageImport": true,
|
||||
"ArtImageDirectory":"S:\\Artemis\\Server\\Image\\Directory",
|
||||
"ArtConnSettings": {
|
||||
"host":"192.168.smt.hng",
|
||||
"user":"MaiDXNet",
|
||||
"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'@'%';
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
Goal for Milestone 1:
|
||||
|
@ -78,11 +78,13 @@ var {getExtId,getUserArea,getUserScores,getUserUnbanned,getUserBanned, getUserDa
|
||||
});
|
||||
|
||||
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
|
||||
const files = fs.readdirSync(config.DXMemorialImageDirectory);
|
||||
const files = fs.readdirSync(config.imageFolder);
|
||||
// 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
|
||||
res.send(imageNames);
|
||||
});
|
||||
|
@ -30,7 +30,7 @@ router.get('/user', async function (req, res, next) {
|
||||
if (cookies.aime_card_id === undefined) {
|
||||
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) {
|
||||
res.render('error', { error: err });
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<% var rootPath='../' ; %>
|
||||
|
||||
<%- include(rootPath + 'templates/header.ejs' ); %>
|
||||
<% function normalizeText(text) { return text .normalize('NFD') .replace(/[\u0300-\u036f]/g, ''
|
||||
).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">
|
||||
<h1>Yo! Welcome Back <%= normalizeText(user.user_name) %>!</h1>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user