move classes and base config into includes directory
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
var WTVAdmin = require("./WTVAdmin.js");
|
||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||
var auth = wtva.isAuthorized();
|
||||
if (auth === true) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
var WTVAdmin = require("./WTVAdmin.js");
|
||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||
var auth = wtva.isAuthorized();
|
||||
if (auth === true) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
var WTVAdmin = require("./WTVAdmin.js");
|
||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||
var auth = wtva.isAuthorized();
|
||||
if (auth === true) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
var WTVAdmin = require("./WTVAdmin.js");
|
||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||
var auth = wtva.isAuthorized();
|
||||
if (auth === true) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
var WTVAdmin = require("./WTVAdmin.js");
|
||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||
var auth = wtva.isAuthorized();
|
||||
if (auth === true) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
var WTVAdmin = require("./WTVAdmin.js");
|
||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||
var auth = wtva.isAuthorized();
|
||||
if (auth === true) {
|
||||
@@ -20,7 +20,7 @@ if (auth === true) {
|
||||
userAccount.switchUserID(user_info.user_id, false, false);
|
||||
if (request_headers.query.confirm) {
|
||||
var polyzooot = 1407;
|
||||
var WTVBGMusic = require("./WTVBGMusic.js");
|
||||
var WTVBGMusic = require(classPath + "/WTVBGMusic.js");
|
||||
var wtvbgm = new WTVBGMusic(minisrv_config, userAccount);
|
||||
var bgmcat = wtvbgm.getSongCategory(polyzooot);
|
||||
var music_obj = wtvbgm.getMusicObj();
|
||||
@@ -35,7 +35,7 @@ if (auth === true) {
|
||||
userAccount.saveSessionData();
|
||||
}
|
||||
if (request_headers.query.reset) {
|
||||
var WTVBGMusic = require("./WTVBGMusic.js");
|
||||
var WTVBGMusic = require(classPath + "/WTVBGMusic.js");
|
||||
userAccount.deleteSessionData("wtv-bgmusic")
|
||||
var wtvbgm = new WTVBGMusic(minisrv_config, userAccount);
|
||||
var music_obj = wtvbgm.getMusicObj(true);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
var WTVAdmin = require("./WTVAdmin.js");
|
||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||
var auth = wtva.isAuthorized();
|
||||
if (auth === true) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
var WTVAdmin = require("./WTVAdmin.js");
|
||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||
var auth = wtva.isAuthorized();
|
||||
if (auth === true) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
var WTVAdmin = require("./WTVAdmin.js");
|
||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||
var auth = wtva.isAuthorized();
|
||||
if (auth === true) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
var WTVAdmin = require("./WTVAdmin.js");
|
||||
var WTVAdmin = require(classPath + "/WTVAdmin.js");
|
||||
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
|
||||
var auth = wtva.isAuthorized();
|
||||
var ssids_removed = [];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
const WTVFlashrom = require("./WTVFlashrom.js");
|
||||
const WTVFlashrom = require(classPath + "/WTVFlashrom.js");
|
||||
request_is_async = true;
|
||||
|
||||
// this build can be local or on zefie's server
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
const WTVFlashrom = require("./WTVFlashrom.js");
|
||||
const WTVFlashrom = require(classPath + "/WTVFlashrom.js");
|
||||
request_is_async = true;
|
||||
|
||||
var bf0app_update = false;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
const WTVFlashrom = require("./WTVFlashrom.js");
|
||||
const WTVFlashrom = require(classPath + "/WTVFlashrom.js");
|
||||
var wtvflashrom;
|
||||
request_is_async = true;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
const WTVFlashrom = require("./WTVFlashrom.js");
|
||||
const WTVFlashrom = require(classPath + "/WTVFlashrom.js");
|
||||
request_is_async = true;
|
||||
|
||||
// this build can be local or on zefie's server
|
||||
|
||||
@@ -25,7 +25,7 @@ async function selectGroup(client, group) {
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
console.log("WTVNews Error -", "Command: grop", e);
|
||||
console.log("WTVNews Error -", "Command: selectGroup", e);
|
||||
}
|
||||
return false;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ if (!request_headers.query.registering) {
|
||||
headers = errpage[0];
|
||||
data = errpage[1];
|
||||
} else {
|
||||
const WTVRegister = require("./WTVRegister.js")
|
||||
const WTVRegister = require(classPath + "/WTVRegister.js")
|
||||
var wtvr = new WTVRegister(minisrv_config, SessionStore);
|
||||
var errpage = null;
|
||||
if (!request_headers.query.registering) errpage = wtvshared.doErrorPage(400);
|
||||
|
||||
@@ -5,7 +5,7 @@ if (!request_headers.query.registering) {
|
||||
headers = errpage[0];
|
||||
data = errpage[1];
|
||||
} else {
|
||||
const WTVRegister = require("./WTVRegister.js")
|
||||
const WTVRegister = require(classPath + "/WTVRegister.js")
|
||||
var wtvr = new WTVRegister(minisrv_config);
|
||||
headers = `200 OK
|
||||
Content-Type: text/html`;
|
||||
|
||||
@@ -3,7 +3,7 @@ var minisrv_service_file = true;
|
||||
headers = `200 OK
|
||||
Content-Type: text/html`;
|
||||
|
||||
var WTVRegister = require("./WTVRegister.js");
|
||||
var WTVRegister = require(classPath + "/WTVRegister.js");
|
||||
var wtvr = new WTVRegister(minisrv_config);
|
||||
var namerand = Math.floor(Math.random() * 100000);
|
||||
var nickname = (minisrv_config.config.service_name + '_' + namerand)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
var minisrv_service_file = true;
|
||||
var errpage = null;
|
||||
|
||||
const WTVRegister = require("./WTVRegister.js")
|
||||
const WTVRegister = require(classPath + "/WTVRegister.js")
|
||||
const wtvr = new WTVRegister(minisrv_config, SessionStore);
|
||||
|
||||
if (session_data.user_id != 0) errpage = wtvshared.doErrorPage(400, "You are not authorized to add users to this account.");
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
'use strict';
|
||||
var classPath = __dirname + "/includes/";
|
||||
const { WTVShared, clientShowAlert } = require(classPath + "WTVShared.js");
|
||||
const wtvshared = new WTVShared(); // creates minisrv_config
|
||||
classPath = wtvshared.getAbsolutePath(classPath, __dirname);
|
||||
|
||||
const fs = require('fs');
|
||||
const tls = require('tls');
|
||||
@@ -11,16 +15,14 @@ const crypto = require('crypto')
|
||||
const CryptoJS = require('crypto-js');
|
||||
const { crc16 } = require('easy-crc');
|
||||
const process = require('process');
|
||||
const WTVSec = require('./WTVSec.js');
|
||||
const WTVLzpf = require('./WTVLzpf.js');
|
||||
const WTVClientCapabilities = require('./WTVClientCapabilities.js');
|
||||
const WTVClientSessionData = require('./WTVClientSessionData.js');
|
||||
const WTVMime = require("./WTVMime.js");
|
||||
const { WTVShared, clientShowAlert } = require("./WTVShared.js");
|
||||
const WTVFlashrom = require("./WTVFlashrom.js");
|
||||
const WTVSec = require(classPath + "/WTVSec.js");
|
||||
const WTVLzpf = require(classPath + "/WTVLzpf.js");
|
||||
const WTVClientCapabilities = require(classPath + "/WTVClientCapabilities.js");
|
||||
const WTVClientSessionData = require(classPath + "/WTVClientSessionData.js");
|
||||
const WTVMime = require(classPath + "/WTVMime.js");
|
||||
const WTVFlashrom = require(classPath + "/WTVFlashrom.js");
|
||||
const vm = require('vm');
|
||||
const express = require('express');
|
||||
const { url } = require('inspector');
|
||||
|
||||
process
|
||||
.on('SIGTERM', shutdown('SIGTERM'))
|
||||
@@ -107,9 +109,10 @@ var runScriptInVM = function (script_data, user_contextObj = {}, privileged = fa
|
||||
// The ServiceVault scripts will only be allowed to access the following fcnutions/variables.
|
||||
// Furthermore, only modifications to variables in `updateFromVM` will be saved.
|
||||
// Example: an attempt to change "minisrv_config" from a ServiceVault script would be discarded
|
||||
var WTVGuide = require("./WTVGuide.js");
|
||||
var WTVBGMusic = require("./WTVBGMusic.js");
|
||||
var WTVDownloadList = require("./WTVDownloadList.js");
|
||||
var WTVGuide = require(classPath + "/WTVGuide.js");
|
||||
var WTVBGMusic = require(classPath + "/WTVBGMusic.js");
|
||||
var WTVDownloadList = require(classPath + "/WTVDownloadList.js");
|
||||
var WTVNews = require(classPath + "/WTVNews.js");
|
||||
|
||||
// create global context object
|
||||
var contextObj = {
|
||||
@@ -128,6 +131,7 @@ var runScriptInVM = function (script_data, user_contextObj = {}, privileged = fa
|
||||
"WTVClientCapabilities": WTVClientCapabilities,
|
||||
"WTVDownloadList": WTVDownloadList,
|
||||
"WTVFlashrom": WTVFlashrom,
|
||||
"WTVNews": WTVNews,
|
||||
"strftime": require('strftime'),
|
||||
"CryptoJS": CryptoJS,
|
||||
"crypto": crypto,
|
||||
@@ -173,16 +177,26 @@ var runScriptInVM = function (script_data, user_contextObj = {}, privileged = fa
|
||||
"SessionStore": SessionStore,
|
||||
"ssid_sessions": ssid_sessions,
|
||||
"socket_sessions": socket_sessions,
|
||||
"reloadConfig": reloadConfig
|
||||
"reloadConfig": reloadConfig,
|
||||
"classPath": classPath
|
||||
}
|
||||
}
|
||||
|
||||
var options = {};
|
||||
if (filename) options = { "filename": filename };
|
||||
var eval_ctx = new vm.Script(script_data, options)
|
||||
eval_ctx.runInNewContext(contextObj, {
|
||||
"breakOnSigint": true
|
||||
});
|
||||
try {
|
||||
eval_ctx.runInNewContext(contextObj, {
|
||||
"breakOnSigint": true
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
// unload modules
|
||||
wtvshared.unloadModule(classPath + "/WTVGuide.js");
|
||||
wtvshared.unloadModule(classPath + "/WTVBGMusic.js");
|
||||
wtvshared.unloadModule(classPath + "/WTVDownloadList.js");
|
||||
|
||||
return contextObj; // updated context object with whatever global varibles the script set
|
||||
}
|
||||
@@ -1764,7 +1778,6 @@ var z_title = "zefie's wtv minisrv v" + require('./package.json').version;
|
||||
if (git_commit) z_title += " (git " + git_commit + ")";
|
||||
console.log("**** Welcome to " + z_title + " ****");
|
||||
|
||||
const wtvshared = new WTVShared(); // creates minisrv_config
|
||||
minisrv_config = wtvshared.getMiniSrvConfig(); // snatches minisrv_config
|
||||
const wtvmime = new WTVMime(minisrv_config);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const process = require('process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
var { WTVShared, clientShowAlert } = require("./WTVShared.js");
|
||||
var { WTVShared, clientShowAlert } = require(classPath + "/WTVShared.js");
|
||||
|
||||
const wtvshared = new WTVShared(); // creates minisrv_config
|
||||
var minisrv_config = wtvshared.getMiniSrvConfig(); // snatches minisrv_config
|
||||
|
||||
@@ -6,13 +6,13 @@ class WTVAdmin {
|
||||
wtvr = null;
|
||||
wtvshared = null;
|
||||
wtvclient = null;
|
||||
WTVClientSessionData = require('./WTVClientSessionData.js');
|
||||
WTVClientSessionData = require("./WTVClientSessionData.js");
|
||||
service_name = "wtv-admin";
|
||||
|
||||
constructor(minisrv_config, wtvclient, service_name) {
|
||||
this.minisrv_config = minisrv_config;
|
||||
var { WTVShared } = require('./WTVShared.js');
|
||||
var WTVRegister = require('./WTVRegister.js');
|
||||
var { WTVShared } = require("./WTVShared.js");
|
||||
var WTVRegister = require("./WTVRegister.js");
|
||||
this.wtvclient = wtvclient;
|
||||
this.wtvshared = new WTVShared(minisrv_config);
|
||||
this.wtvr = new WTVRegister(minisrv_config);
|
||||
@@ -1246,7 +1246,7 @@ class WTVBGMusic {
|
||||
constructor(minisrv_config, session_data) {
|
||||
if (!minisrv_config) throw ("minisrv_config required");
|
||||
if (!session_data) throw ("WTVClientSessionData required");
|
||||
var WTVShared = require('./WTVShared.js')['WTVShared'];
|
||||
var WTVShared = require("./WTVShared.js")['WTVShared'];
|
||||
this.minisrv_config = minisrv_config;
|
||||
this.session_data = session_data;
|
||||
this.wtvshared = new WTVShared(minisrv_config);
|
||||
@@ -1,8 +1,8 @@
|
||||
const { lib } = require('crypto-js');
|
||||
const CryptoJS = require('crypto-js');
|
||||
const WTVMail = require('./WTVMail.js')
|
||||
const WTVSec = require('./WTVSec.js');
|
||||
const WTVFavorites = require('./WTVFavorites.js');
|
||||
const WTVMail = require("./WTVMail.js")
|
||||
const WTVSec = require("./WTVSec.js");
|
||||
const WTVFavorites = require("./WTVFavorites.js");
|
||||
|
||||
|
||||
class WTVClientSessionData {
|
||||
@@ -31,8 +31,8 @@ class WTVClientSessionData {
|
||||
|
||||
constructor(minisrv_config, ssid) {
|
||||
if (!minisrv_config) throw ("minisrv_config required");
|
||||
var WTVShared = require('./WTVShared.js')['WTVShared'];
|
||||
var WTVMime = require('./WTVMime.js');
|
||||
var WTVShared = require("./WTVShared.js")['WTVShared'];
|
||||
var WTVMime = require("./WTVMime.js");
|
||||
this.minisrv_config = minisrv_config;
|
||||
this.wtvshared = new WTVShared(minisrv_config);
|
||||
this.wtvmime = new WTVMime(minisrv_config);
|
||||
@@ -16,7 +16,7 @@ class WTVDownloadList {
|
||||
* @param {string} service_name Service name to use in wtv-urls
|
||||
*/
|
||||
constructor(minisrv_config, service_name = "wtv-disk") {
|
||||
var { WTVShared, clientShowAlert } = require('./WTVShared.js');
|
||||
var { WTVShared, clientShowAlert } = require("./WTVShared.js");
|
||||
this.minisrv_config = minisrv_config;
|
||||
this.wtvshared = new WTVShared(minisrv_config);
|
||||
this.clientShowAlert = clientShowAlert;
|
||||
@@ -18,9 +18,9 @@ class WTVFavorites {
|
||||
constructor(minisrv_config, wtvclient) {
|
||||
if (!minisrv_config) throw ("minisrv_config required");
|
||||
if (!wtvclient) throw ("WTVClientSessionData required");
|
||||
var WTVShared = require('./WTVShared.js')['WTVShared'];
|
||||
var WTVMime = require('./WTVMime.js');
|
||||
this.WTVClientSessionData = require('./WTVClientSessionData.js');
|
||||
var WTVShared = require("./WTVShared.js")['WTVShared'];
|
||||
var WTVMime = require("./WTVMime.js");
|
||||
this.WTVClientSessionData = require("./WTVClientSessionData.js");
|
||||
this.minisrv_config = minisrv_config;
|
||||
this.wtvshared = new WTVShared(minisrv_config);
|
||||
this.wtvmime = new WTVMime(minisrv_config);
|
||||
@@ -12,7 +12,7 @@ class WTVFlashrom {
|
||||
|
||||
|
||||
constructor(minisrv_config, service_vaults, service_name, use_zefie_server = true, bf0app_update = false, no_debug = false) {
|
||||
var { WTVShared } = require('./WTVShared.js');
|
||||
var { WTVShared } = require("./WTVShared.js");
|
||||
this.service_vaults = service_vaults;
|
||||
this.service_name = service_name;
|
||||
this.use_zefie_server = use_zefie_server;
|
||||
@@ -8,26 +8,13 @@ class WTVGuide {
|
||||
constructor(minisrv_config, session_data, socket, runScriptInVM) {
|
||||
if (!minisrv_config) throw ("minisrv_config required");
|
||||
if (!session_data) throw ("WTVClientSessionData required");
|
||||
var WTVShared = require('./WTVShared.js')['WTVShared'];
|
||||
var WTVShared = require("./WTVShared.js")['WTVShared'];
|
||||
this.minisrv_config = minisrv_config;
|
||||
this.session_data = session_data;
|
||||
this.wtvshared = new WTVShared(minisrv_config);
|
||||
this.runScriptInVM = runScriptInVM;
|
||||
}
|
||||
|
||||
unloadModule(moduleName) {
|
||||
// for handling template classes
|
||||
var solvedName = require.resolve(moduleName),
|
||||
nodeModule = require.cache[solvedName];
|
||||
if (nodeModule) {
|
||||
for (var i = 0; i < nodeModule.children.length; i++) {
|
||||
var child = nodeModule.children[i];
|
||||
deleteModule(child.filename);
|
||||
}
|
||||
delete require.cache[solvedName];
|
||||
}
|
||||
}
|
||||
|
||||
generatePage(topic, subtopic, page = null) {
|
||||
// sanitize a bit
|
||||
|
||||
@@ -197,7 +184,7 @@ class WTVGuide {
|
||||
console.log(" * wtv-template error:", e)
|
||||
}
|
||||
// unload and clean up module
|
||||
this.unloadModule(template);
|
||||
wtvshared.unloadModule(template);
|
||||
}
|
||||
|
||||
// return generated page
|
||||
@@ -22,9 +22,9 @@ class WTVMail {
|
||||
|
||||
constructor(minisrv_config, wtvclient) {
|
||||
if (!minisrv_config) throw ("minisrv_config required");
|
||||
var WTVShared = require('./WTVShared.js')['WTVShared'];
|
||||
var WTVMime = require('./WTVMime.js');
|
||||
this.WTVClientSessionData = require('./WTVClientSessionData.js');
|
||||
var WTVShared = require("./WTVShared.js")['WTVShared'];
|
||||
var WTVMime = require("./WTVMime.js");
|
||||
this.WTVClientSessionData = require("./WTVClientSessionData.js");
|
||||
this.minisrv_config = minisrv_config;
|
||||
this.wtvshared = new WTVShared(minisrv_config);
|
||||
this.wtvmime = new WTVMime(minisrv_config);
|
||||
@@ -11,7 +11,7 @@ class WTVMime {
|
||||
|
||||
|
||||
constructor(minisrv_config) {
|
||||
var WTVShared = require('./WTVShared.js')['WTVShared'];
|
||||
var WTVShared = require("./WTVShared.js")['WTVShared'];
|
||||
this.minisrv_config = minisrv_config;
|
||||
this.wtvshared = new WTVShared(minisrv_config);
|
||||
if (!String.prototype.reverse) {
|
||||
5
zefie_wtvp_minisrv/includes/WTVNews.js
Normal file
5
zefie_wtvp_minisrv/includes/WTVNews.js
Normal file
@@ -0,0 +1,5 @@
|
||||
class WTVNews {
|
||||
|
||||
}
|
||||
|
||||
module.exports = WTVNews;
|
||||
@@ -13,6 +13,7 @@ class WTVShared {
|
||||
html_entities = require('html-entities'); // used externally by service scripts
|
||||
sanitizeHtml = require('sanitize-html');
|
||||
iconv = require('iconv-lite');
|
||||
parentDirectory = process.cwd()
|
||||
|
||||
minisrv_config = [];
|
||||
|
||||
@@ -38,6 +39,7 @@ class WTVShared {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getServiceString(service, overrides = {}) {
|
||||
// used externally by service scripts
|
||||
if (service === "all") {
|
||||
@@ -159,7 +161,7 @@ class WTVShared {
|
||||
returnAbsolutePath(check_path) {
|
||||
if (check_path.substring(0, 1) != this.path.sep && check_path.substring(1, 1) != ":") {
|
||||
// non-absolute path, so use current directory as base
|
||||
check_path = (__dirname + this.path.sep + check_path);
|
||||
check_path = this.parentDirectory + this.path.sep + check_path;
|
||||
} else {
|
||||
// already absolute path
|
||||
}
|
||||
@@ -176,9 +178,10 @@ class WTVShared {
|
||||
|
||||
getUserConfig() {
|
||||
try {
|
||||
if (this.fs.lstatSync(__dirname + "/user_config.json")) {
|
||||
var user_config_filename = this.getAbsolutePath("user_config.json", this.parentDirectory);
|
||||
if (this.fs.lstatSync(user_config_filename)) {
|
||||
try {
|
||||
var minisrv_user_config = JSON.parse(this.fs.readFileSync(__dirname + this.path.sep + "user_config.json"));
|
||||
var minisrv_user_config = JSON.parse(this.fs.readFileSync(user_config_filename));
|
||||
} catch (e) {
|
||||
console.error("ERROR: Could not read user_config.json", e);
|
||||
var throw_me = true;
|
||||
@@ -198,7 +201,7 @@ class WTVShared {
|
||||
readMiniSrvConfig(user_config = true, notices = true, reload_notice = false) {
|
||||
if (notices || reload_notice) console.log(" *** Reading global configuration...");
|
||||
try {
|
||||
var minisrv_config = JSON.parse(this.fs.readFileSync(__dirname + this.path.sep + "config.json"));
|
||||
var minisrv_config = JSON.parse(this.fs.readFileSync(this.getAbsolutePath("config.json", __dirname)));
|
||||
} catch (e) {
|
||||
throw ("ERROR: Could not read config.json", e);
|
||||
}
|
||||
@@ -222,6 +225,7 @@ class WTVShared {
|
||||
try {
|
||||
if (notices || reload_notice) console.log(" *** Reading user configuration...");
|
||||
var minisrv_user_config = this.getUserConfig()
|
||||
if (!minisrv_user_config) throw "ERROR: Could not read user_config.json";
|
||||
try {
|
||||
minisrv_config = integrateConfig(minisrv_config, minisrv_user_config)
|
||||
} catch (e) {
|
||||
@@ -290,7 +294,7 @@ class WTVShared {
|
||||
var new_user_config = {};
|
||||
Object.assign(new_user_config, minisrv_user_config, config);
|
||||
if (this.minisrv_config.config.debug_flags.debug) console.log(" * Writing new user configuration...");
|
||||
this.fs.writeFileSync(__dirname + this.path.sep + "user_config.json", JSON.stringify(new_user_config, null, "\t"));
|
||||
this.fs.writeFileSync(this.getAbsolutePath("user_config.json", parentDirectory), JSON.stringify(new_user_config, null, "\t"));
|
||||
}
|
||||
catch (e) {
|
||||
if (this.minisrv_config.config.debug_flags) {
|
||||
@@ -460,19 +464,35 @@ class WTVShared {
|
||||
return obj;
|
||||
}
|
||||
|
||||
unloadModule(moduleName) {
|
||||
// for handling template classes
|
||||
var solvedName = require.resolve(moduleName),
|
||||
nodeModule = require.cache[solvedName];
|
||||
if (nodeModule) {
|
||||
for (var i = 0; i < nodeModule.children.length; i++) {
|
||||
var child = nodeModule.children[i];
|
||||
this.unloadModule(child.filename);
|
||||
}
|
||||
delete require.cache[solvedName];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an absolute path
|
||||
* @param {string} path
|
||||
* @param {string} directory Root directory
|
||||
*/
|
||||
getAbsolutePath(path, directory = __dirname) {
|
||||
if (path.substring(0, 1) != this.path.sep && path.substring(1, 1) != ":") {
|
||||
// non-absolute path, so use current directory as base
|
||||
path = (directory + this.path.sep + path);
|
||||
} else {
|
||||
// already absolute path
|
||||
getAbsolutePath(path, directory = null) {
|
||||
if (directory) {
|
||||
if (path.indexOf(directory) == -1) {
|
||||
directory = this.getAbsolutePath(directory);
|
||||
try {
|
||||
if (this.fs.lstatSync(directory).isDirectory()) directory = directory + this.path.sep;
|
||||
} catch (e) { }
|
||||
path = directory + path;
|
||||
}
|
||||
}
|
||||
return this.fixPathSlashes(path);
|
||||
return this.fixPathSlashes(this.path.resolve(path));
|
||||
}
|
||||
|
||||
/**
|
||||
4
zefie_wtvp_minisrv/package-lock.json
generated
4
zefie_wtvp_minisrv/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "zefie_wtvp_minisrv",
|
||||
"version": "0.9.31",
|
||||
"version": "0.9.32",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "zefie_wtvp_minisrv",
|
||||
"version": "0.9.31",
|
||||
"version": "0.9.32",
|
||||
"license": "GPL3",
|
||||
"dependencies": {
|
||||
"adm-zip": "^0.5.9",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { WTVShared } = require("./WTVShared.js");
|
||||
const { WTVShared } = require(classPath + "/WTVShared.js");
|
||||
var wtvshared = new WTVShared(null, true);
|
||||
const fs = require('fs');
|
||||
|
||||
|
||||
@@ -31,7 +31,10 @@
|
||||
<ItemGroup>
|
||||
<Content Include=".gitignore" />
|
||||
<Content Include="app.js" />
|
||||
<Content Include="config.json" />
|
||||
<Content Include="includes\WTVNews.js">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="includes\config.json" />
|
||||
<Content Include="diskmap_gen.js">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
@@ -1101,47 +1104,48 @@
|
||||
<Content Include="SharedROMCache\UsingWebTVBanner.gif" />
|
||||
<Content Include="SharedROMCache\WebTVLogoJewel.gif" />
|
||||
<Content Include="test.js" />
|
||||
<Content Include="WTVAdmin.js" />
|
||||
<Content Include="WTVBGMusic.js">
|
||||
<Content Include="includes\WTVAdmin.js" />
|
||||
<Content Include="includes\WTVBGMusic.js">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="WTVClientSessionData.js">
|
||||
<Content Include="includes\WTVClientSessionData.js">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="user_config.example.json" />
|
||||
<Content Include="user_config.json" />
|
||||
<Content Include="WTVClientCapabilities.js">
|
||||
<Content Include="includes\WTVClientCapabilities.js">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="WTVDownloadList.js">
|
||||
<Content Include="includes\WTVDownloadList.js">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="WTVFavorites.js" />
|
||||
<Content Include="WTVFlashrom.js">
|
||||
<Content Include="includes\WTVFavorites.js" />
|
||||
<Content Include="includes\WTVFlashrom.js">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="WTVGuide.js" />
|
||||
<Content Include="WTVLzpf.js">
|
||||
<Content Include="includes\WTVGuide.js" />
|
||||
<Content Include="includes\WTVLzpf.js">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="WTVMail.js">
|
||||
<Content Include="includes\WTVMail.js">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="WTVMime.js">
|
||||
<Content Include="includes\WTVMime.js">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="WTVRegister.js">
|
||||
<Content Include="includes\WTVRegister.js">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="WTVSec.js">
|
||||
<Content Include="includes\WTVSec.js">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="package.json" />
|
||||
<Content Include="WTVShared.js">
|
||||
<Content Include="includes\WTVShared.js">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="includes\" />
|
||||
<Folder Include="ServiceDeps\" />
|
||||
<Folder Include="ServiceDeps\viewergen\" />
|
||||
<Folder Include="ServiceDeps\wtv-1800\" />
|
||||
|
||||
Reference in New Issue
Block a user