mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
Refactored settings page.
This commit is contained in:
parent
20a4eb0f8f
commit
ab802c0683
39 changed files with 472 additions and 470 deletions
|
@ -12,7 +12,7 @@ process.on('unhandledRejection', (err) => { throw err; });
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const querystring = require('querystring');
|
const querystring = require('querystring');
|
||||||
import {settings} from '../node/utils/Settings';
|
import settings from '../node/utils/Settings';
|
||||||
const supertest = require('supertest');
|
const supertest = require('supertest');
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
|
|
@ -49,7 +49,7 @@ const unescape = (val) => {
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const log4js = require('log4js');
|
const log4js = require('log4js');
|
||||||
const readline = require('readline');
|
const readline = require('readline');
|
||||||
import {settings} from '../node/utils/Settings';
|
import settings from '../node/utils/Settings';
|
||||||
const ueberDB = require('ueberdb2');
|
const ueberDB = require('ueberdb2');
|
||||||
|
|
||||||
const dbWrapperSettings = {
|
const dbWrapperSettings = {
|
||||||
|
|
|
@ -14,7 +14,7 @@ process.on('unhandledRejection', (err) => { throw err; });
|
||||||
|
|
||||||
const dirtyDb = require('dirty');
|
const dirtyDb = require('dirty');
|
||||||
const log4js = require('log4js');
|
const log4js = require('log4js');
|
||||||
import {settings} from '../node/utils/Settings';
|
import settings from '../node/utils/Settings';
|
||||||
const ueberDB = require('ueberdb2');
|
const ueberDB = require('ueberdb2');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ process.on('unhandledRejection', (err) => { throw err; });
|
||||||
cache: '0', // The cache slows things down when you're mostly writing.
|
cache: '0', // The cache slows things down when you're mostly writing.
|
||||||
writeInterval: 0, // Write directly to the database, don't buffer
|
writeInterval: 0, // Write directly to the database, don't buffer
|
||||||
};
|
};
|
||||||
const db = new ueberDB.database( // eslint-disable-line new-cap
|
const db = new ueberDB.Database( // eslint-disable-line new-cap
|
||||||
settings.dbType,
|
settings.dbType,
|
||||||
settings.dbSettings,
|
settings.dbSettings,
|
||||||
dbWrapperSettings,
|
dbWrapperSettings,
|
||||||
|
|
|
@ -19,7 +19,7 @@ let valueCount = 0;
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
// initialize database
|
// initialize database
|
||||||
import {settings} from '../node/utils/Settings';
|
import settings from '../node/utils/Settings';
|
||||||
const db = require('../node/db/DB');
|
const db = require('../node/db/DB');
|
||||||
await db.init();
|
await db.init();
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ const AttributePool = require('../../static/js/AttributePool');
|
||||||
const Stream = require('../utils/Stream');
|
const Stream = require('../utils/Stream');
|
||||||
const assert = require('assert').strict;
|
const assert = require('assert').strict;
|
||||||
const db = require('./DB');
|
const db = require('./DB');
|
||||||
import {settings} from '../utils/Settings';
|
import settings from '../utils/Settings';
|
||||||
const authorManager = require('./AuthorManager');
|
const authorManager = require('./AuthorManager');
|
||||||
const padManager = require('./PadManager');
|
const padManager = require('./PadManager');
|
||||||
const padMessageHandler = require('../handler/PadMessageHandler');
|
const padMessageHandler = require('../handler/PadMessageHandler');
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
const CustomError = require('../utils/customError');
|
const CustomError = require('../utils/customError');
|
||||||
const Pad = require('../db/Pad');
|
const Pad = require('../db/Pad');
|
||||||
const db = require('./DB');
|
const db = require('./DB');
|
||||||
import {settings} from '../utils/Settings';
|
import settings from '../utils/Settings';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A cache of all loaded Pads.
|
* A cache of all loaded Pads.
|
||||||
|
|
|
@ -24,7 +24,7 @@ const hooks = require('../../static/js/pluginfw/hooks.js');
|
||||||
const padManager = require('./PadManager');
|
const padManager = require('./PadManager');
|
||||||
const readOnlyManager = require('./ReadOnlyManager');
|
const readOnlyManager = require('./ReadOnlyManager');
|
||||||
const sessionManager = require('./SessionManager');
|
const sessionManager = require('./SessionManager');
|
||||||
import {settings} from '../utils/Settings';
|
import settings from '../utils/Settings';
|
||||||
const webaccess = require('../hooks/express/webaccess');
|
const webaccess = require('../hooks/express/webaccess');
|
||||||
const log4js = require('log4js');
|
const log4js = require('log4js');
|
||||||
const authLogger = log4js.getLogger('auth');
|
const authLogger = log4js.getLogger('auth');
|
||||||
|
|
|
@ -25,7 +25,7 @@ import fs from 'fs';
|
||||||
const hooks = require('../../static/js/pluginfw/hooks.js');
|
const hooks = require('../../static/js/pluginfw/hooks.js');
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import resolve from 'resolve';
|
import resolve from 'resolve';
|
||||||
import {root, settings} from '../utils/Settings'
|
import settings from '../utils/Settings'
|
||||||
|
|
||||||
const templateCache = new Map();
|
const templateCache = new Map();
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ exports.require = (name: string, args: any, mod: any) => {
|
||||||
basedir = path.dirname(mod.filename);
|
basedir = path.dirname(mod.filename);
|
||||||
paths = mod.paths;
|
paths = mod.paths;
|
||||||
}
|
}
|
||||||
paths.push(root + '/plugin_packages')
|
paths.push(settings.root + '/plugin_packages')
|
||||||
|
|
||||||
const ejspath = resolve.sync(name, {paths, basedir, extensions: ['.html', '.ejs']});
|
const ejspath = resolve.sync(name, {paths, basedir, extensions: ['.html', '.ejs']});
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ const exporthtml = require('../utils/ExportHtml');
|
||||||
const exporttxt = require('../utils/ExportTxt');
|
const exporttxt = require('../utils/ExportTxt');
|
||||||
const exportEtherpad = require('../utils/ExportEtherpad');
|
const exportEtherpad = require('../utils/ExportEtherpad');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
import {settings} from '../utils/Settings';
|
import settings from '../utils/Settings';
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const hooks = require('../../static/js/pluginfw/hooks');
|
const hooks = require('../../static/js/pluginfw/hooks');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
|
|
|
@ -25,7 +25,7 @@ const padManager = require('../db/PadManager');
|
||||||
const padMessageHandler = require('./PadMessageHandler');
|
const padMessageHandler = require('./PadMessageHandler');
|
||||||
const fs = require('fs').promises;
|
const fs = require('fs').promises;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
import {settings} from '../utils/Settings';
|
import settings from '../utils/Settings';
|
||||||
const {Formidable} = require('formidable');
|
const {Formidable} = require('formidable');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const importHtml = require('../utils/ImportHtml');
|
const importHtml = require('../utils/ImportHtml');
|
||||||
|
|
|
@ -28,7 +28,7 @@ const AttributeManager = require('../../static/js/AttributeManager');
|
||||||
const authorManager = require('../db/AuthorManager');
|
const authorManager = require('../db/AuthorManager');
|
||||||
const {padutils} = require('../../static/js/pad_utils');
|
const {padutils} = require('../../static/js/pad_utils');
|
||||||
const readOnlyManager = require('../db/ReadOnlyManager');
|
const readOnlyManager = require('../db/ReadOnlyManager');
|
||||||
import {abiwordAvailable, exportAvailable, randomVersionString, settings, sofficeAvailable} from '../utils/Settings';
|
import settings from '../utils/Settings';
|
||||||
const securityManager = require('../db/SecurityManager');
|
const securityManager = require('../db/SecurityManager');
|
||||||
const plugins = require('../../static/js/pluginfw/plugin_defs.js');
|
const plugins = require('../../static/js/pluginfw/plugin_defs.js');
|
||||||
const log4js = require('log4js');
|
const log4js = require('log4js');
|
||||||
|
@ -930,7 +930,7 @@ const handleClientReady = async (socket, message) => {
|
||||||
const clientVars = {
|
const clientVars = {
|
||||||
skinName: settings.skinName,
|
skinName: settings.skinName,
|
||||||
skinVariants: settings.skinVariants,
|
skinVariants: settings.skinVariants,
|
||||||
randomVersionString: randomVersionString,
|
randomVersionString: settings.randomVersionString,
|
||||||
accountPrivs: {
|
accountPrivs: {
|
||||||
maxRevisions: 100,
|
maxRevisions: 100,
|
||||||
},
|
},
|
||||||
|
@ -964,9 +964,9 @@ const handleClientReady = async (socket, message) => {
|
||||||
serverTimestamp: Date.now(),
|
serverTimestamp: Date.now(),
|
||||||
sessionRefreshInterval: settings.cookie.sessionRefreshInterval,
|
sessionRefreshInterval: settings.cookie.sessionRefreshInterval,
|
||||||
userId: sessionInfo.author,
|
userId: sessionInfo.author,
|
||||||
abiwordAvailable: abiwordAvailable(),
|
abiwordAvailable: settings.abiwordAvailable(),
|
||||||
sofficeAvailable: sofficeAvailable(),
|
sofficeAvailable: settings.sofficeAvailable(),
|
||||||
exportAvailable: exportAvailable(),
|
exportAvailable: settings.exportAvailable(),
|
||||||
plugins: {
|
plugins: {
|
||||||
plugins: plugins.plugins,
|
plugins: plugins.plugins,
|
||||||
parts: plugins.parts,
|
parts: plugins.parts,
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const log4js = require('log4js');
|
const log4js = require('log4js');
|
||||||
import {settings} from '../utils/Settings';
|
import settings from '../utils/Settings';
|
||||||
const stats = require('../../node/stats')
|
const stats = require('../../node/stats')
|
||||||
|
|
||||||
const logger = log4js.getLogger('socket.io');
|
const logger = log4js.getLogger('socket.io');
|
||||||
|
|
|
@ -14,7 +14,7 @@ import fs from 'fs';
|
||||||
const hooks = require('../../static/js/pluginfw/hooks');
|
const hooks = require('../../static/js/pluginfw/hooks');
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
const SessionStore = require('../db/SessionStore');
|
const SessionStore = require('../db/SessionStore');
|
||||||
import {getEpVersion, getGitCommit, settings} from '../utils/Settings';
|
import settings from '../utils/Settings';
|
||||||
const stats = require('../stats')
|
const stats = require('../stats')
|
||||||
import util from 'util';
|
import util from 'util';
|
||||||
const webaccess = require('./express/webaccess');
|
const webaccess = require('./express/webaccess');
|
||||||
|
@ -68,9 +68,9 @@ const closeServer = async () => {
|
||||||
exports.createServer = async () => {
|
exports.createServer = async () => {
|
||||||
console.log('Report bugs at https://github.com/ether/etherpad-lite/issues');
|
console.log('Report bugs at https://github.com/ether/etherpad-lite/issues');
|
||||||
|
|
||||||
serverName = `Etherpad ${getGitCommit()} (https://etherpad.org)`;
|
serverName = `Etherpad ${settings.getGitCommit()} (https://etherpad.org)`;
|
||||||
|
|
||||||
console.log(`Your Etherpad version is ${getEpVersion()} (${getGitCommit()})`);
|
console.log(`Your Etherpad version is ${settings.getEpVersion()} (${settings.getGitCommit()})`);
|
||||||
|
|
||||||
await exports.restartServer();
|
await exports.restartServer();
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {QueryType} from "../../types/QueryType";
|
||||||
import {PluginType} from "../../types/Plugin";
|
import {PluginType} from "../../types/Plugin";
|
||||||
|
|
||||||
const eejs = require('../../eejs');
|
const eejs = require('../../eejs');
|
||||||
import {getEpVersion, getGitCommit} from '../../utils/Settings';
|
import settings from '../../utils/Settings';
|
||||||
const installer = require('../../../static/js/pluginfw/installer');
|
const installer = require('../../../static/js/pluginfw/installer');
|
||||||
const pluginDefs = require('../../../static/js/pluginfw/plugin_defs');
|
const pluginDefs = require('../../../static/js/pluginfw/plugin_defs');
|
||||||
const plugins = require('../../../static/js/pluginfw/plugins');
|
const plugins = require('../../../static/js/pluginfw/plugins');
|
||||||
|
@ -24,8 +24,8 @@ exports.expressCreateServer = (hookName:string, args: ArgsExpressType, cb:Functi
|
||||||
});
|
});
|
||||||
|
|
||||||
args.app.get('/admin/plugins/info', (req:any, res:any) => {
|
args.app.get('/admin/plugins/info', (req:any, res:any) => {
|
||||||
const gitCommit = getGitCommit();
|
const gitCommit = settings.getGitCommit();
|
||||||
const epVersion = getEpVersion();
|
const epVersion = settings.getEpVersion();
|
||||||
|
|
||||||
res.send(eejs.require('ep_etherpad-lite/templates/admin/plugins-info.html', {
|
res.send(eejs.require('ep_etherpad-lite/templates/admin/plugins-info.html', {
|
||||||
gitCommit,
|
gitCommit,
|
||||||
|
|
|
@ -4,7 +4,7 @@ const eejs = require('../../eejs');
|
||||||
const fsp = require('fs').promises;
|
const fsp = require('fs').promises;
|
||||||
const hooks = require('../../../static/js/pluginfw/hooks');
|
const hooks = require('../../../static/js/pluginfw/hooks');
|
||||||
const plugins = require('../../../static/js/pluginfw/plugins');
|
const plugins = require('../../../static/js/pluginfw/plugins');
|
||||||
import {reloadSettings, settings} from '../../utils/Settings';
|
import settings from '../../utils/Settings';
|
||||||
|
|
||||||
exports.expressCreateServer = (hookName:string, {app}:any) => {
|
exports.expressCreateServer = (hookName:string, {app}:any) => {
|
||||||
app.get('/admin/settings', (req:any, res:any) => {
|
app.get('/admin/settings', (req:any, res:any) => {
|
||||||
|
@ -44,7 +44,7 @@ exports.socketio = (hookName:string, {io}:any) => {
|
||||||
|
|
||||||
socket.on('restartServer', async () => {
|
socket.on('restartServer', async () => {
|
||||||
console.log('Admin request to restart server through a socket on /admin/settings');
|
console.log('Admin request to restart server through a socket on /admin/settings');
|
||||||
reloadSettings();
|
settings.reloadSettings();
|
||||||
await plugins.update();
|
await plugins.update();
|
||||||
await hooks.aCallAll('loadSettings', {settings});
|
await hooks.aCallAll('loadSettings', {settings});
|
||||||
await hooks.aCallAll('restartServer');
|
await hooks.aCallAll('restartServer');
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import {ArgsExpressType} from "../../types/ArgsExpressType";
|
import {ArgsExpressType} from "../../types/ArgsExpressType";
|
||||||
|
|
||||||
const hasPadAccess = require('../../padaccess');
|
const hasPadAccess = require('../../padaccess');
|
||||||
import {exportAvailable, settings} from '../../utils/Settings';
|
import settings from '../../utils/Settings';
|
||||||
const exportHandler = require('../../handler/ExportHandler');
|
const exportHandler = require('../../handler/ExportHandler');
|
||||||
const importHandler = require('../../handler/ImportHandler');
|
const importHandler = require('../../handler/ImportHandler');
|
||||||
const padManager = require('../../db/PadManager');
|
const padManager = require('../../db/PadManager');
|
||||||
|
@ -35,7 +35,7 @@ exports.expressCreateServer = (hookName:string, args:ArgsExpressType, cb:Functio
|
||||||
}
|
}
|
||||||
|
|
||||||
// if abiword is disabled, and this is a format we only support with abiword, output a message
|
// if abiword is disabled, and this is a format we only support with abiword, output a message
|
||||||
if (exportAvailable() === 'no' &&
|
if (settings.exportAvailable() === 'no' &&
|
||||||
['odt', 'pdf', 'doc'].indexOf(req.params.type) !== -1) {
|
['odt', 'pdf', 'doc'].indexOf(req.params.type) !== -1) {
|
||||||
console.error(`Impossible to export pad "${req.params.pad}" in ${req.params.type} format.` +
|
console.error(`Impossible to export pad "${req.params.pad}" in ${req.params.type} format.` +
|
||||||
' There is no converter configured');
|
' There is no converter configured');
|
||||||
|
|
|
@ -24,7 +24,7 @@ const cloneDeep = require('lodash.clonedeep');
|
||||||
const createHTTPError = require('http-errors');
|
const createHTTPError = require('http-errors');
|
||||||
|
|
||||||
const apiHandler = require('../../handler/APIHandler');
|
const apiHandler = require('../../handler/APIHandler');
|
||||||
import {settings} from '../../utils/Settings';
|
import settings from '../../utils/Settings';
|
||||||
|
|
||||||
const log4js = require('log4js');
|
const log4js = require('log4js');
|
||||||
const logger = log4js.getLogger('API');
|
const logger = log4js.getLogger('API');
|
||||||
|
|
|
@ -6,7 +6,7 @@ const events = require('events');
|
||||||
const express = require('../express');
|
const express = require('../express');
|
||||||
const log4js = require('log4js');
|
const log4js = require('log4js');
|
||||||
const proxyaddr = require('proxy-addr');
|
const proxyaddr = require('proxy-addr');
|
||||||
import {settings} from '../../utils/Settings';
|
import settings from '../../utils/Settings';
|
||||||
import {Server} from 'socket.io'
|
import {Server} from 'socket.io'
|
||||||
const socketIORouter = require('../../handler/SocketIORouter');
|
const socketIORouter = require('../../handler/SocketIORouter');
|
||||||
const hooks = require('../../../static/js/pluginfw/hooks');
|
const hooks = require('../../../static/js/pluginfw/hooks');
|
||||||
|
|
|
@ -6,7 +6,7 @@ const fs = require('fs');
|
||||||
const fsp = fs.promises;
|
const fsp = fs.promises;
|
||||||
const toolbar = require('../../utils/toolbar');
|
const toolbar = require('../../utils/toolbar');
|
||||||
const hooks = require('../../../static/js/pluginfw/hooks');
|
const hooks = require('../../../static/js/pluginfw/hooks');
|
||||||
import {getEpVersion, root, settings} from '../../utils/Settings';
|
import settings from '../../utils/Settings';
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const webaccess = require('./webaccess');
|
const webaccess = require('./webaccess');
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ exports.expressPreSession = async (hookName, {app}) => {
|
||||||
res.set('Content-Type', 'application/health+json');
|
res.set('Content-Type', 'application/health+json');
|
||||||
res.json({
|
res.json({
|
||||||
status: 'pass',
|
status: 'pass',
|
||||||
releaseId: getEpVersion(),
|
releaseId: settings.getEpVersion(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -31,11 +31,11 @@ exports.expressPreSession = async (hookName, {app}) => {
|
||||||
|
|
||||||
app.get('/robots.txt', (req, res) => {
|
app.get('/robots.txt', (req, res) => {
|
||||||
let filePath =
|
let filePath =
|
||||||
path.join(root, 'src', 'static', 'skins', settings.skinName, 'robots.txt');
|
path.join(settings.root, 'src', 'static', 'skins', settings.skinName, 'robots.txt');
|
||||||
res.sendFile(filePath, (err) => {
|
res.sendFile(filePath, (err) => {
|
||||||
// there is no custom robots.txt, send the default robots.txt which dissallows all
|
// there is no custom robots.txt, send the default robots.txt which dissallows all
|
||||||
if (err) {
|
if (err) {
|
||||||
filePath = path.join(root, 'src', 'static', 'robots.txt');
|
filePath = path.join(settings.root, 'src', 'static', 'robots.txt');
|
||||||
res.sendFile(filePath);
|
res.sendFile(filePath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -54,9 +54,9 @@ exports.expressPreSession = async (hookName, {app}) => {
|
||||||
|
|
||||||
|
|
||||||
const fns = [
|
const fns = [
|
||||||
...(settings.favicon ? [path.resolve(root, settings.favicon)] : []),
|
...(settings.favicon ? [path.resolve(settings.root, settings.favicon)] : []),
|
||||||
path.join(root, 'src', 'static', 'skins', settings.skinName, 'favicon.ico'),
|
path.join(settings.root, 'src', 'static', 'skins', settings.skinName, 'favicon.ico'),
|
||||||
path.join(root, 'src', 'static', 'favicon.ico'),
|
path.join(settings.root, 'src', 'static', 'favicon.ico'),
|
||||||
];
|
];
|
||||||
for (const fn of fns) {
|
for (const fn of fns) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -5,7 +5,7 @@ const fs = require('fs').promises;
|
||||||
const minify = require('../../utils/Minify');
|
const minify = require('../../utils/Minify');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const plugins = require('../../../static/js/pluginfw/plugin_defs');
|
const plugins = require('../../../static/js/pluginfw/plugin_defs');
|
||||||
import {root, settings} from '../../utils/Settings';
|
import {settings} from '../../utils/Settings';
|
||||||
const CachingMiddleware = require('../../utils/caching_middleware');
|
const CachingMiddleware = require('../../utils/caching_middleware');
|
||||||
const Yajsml = require('etherpad-yajsml');
|
const Yajsml = require('etherpad-yajsml');
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ const getTar = async () => {
|
||||||
return `ep_etherpad-lite/static/js/${path}`;
|
return `ep_etherpad-lite/static/js/${path}`;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const tarJson = await fs.readFile(path.join(root, 'src/node/utils/tar.json'), 'utf8');
|
const tarJson = await fs.readFile(path.join(settings.root, 'src/node/utils/tar.json'), 'utf8');
|
||||||
const tar = {};
|
const tar = {};
|
||||||
for (const [key, relativeFiles] of Object.entries(JSON.parse(tarJson))) {
|
for (const [key, relativeFiles] of Object.entries(JSON.parse(tarJson))) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
|
@ -4,7 +4,7 @@ const path = require('path');
|
||||||
const fsp = require('fs').promises;
|
const fsp = require('fs').promises;
|
||||||
const plugins = require('../../../static/js/pluginfw/plugin_defs');
|
const plugins = require('../../../static/js/pluginfw/plugin_defs');
|
||||||
const sanitizePathname = require('../../utils/sanitizePathname');
|
const sanitizePathname = require('../../utils/sanitizePathname');
|
||||||
import {root, settings} from '../../utils/Settings';
|
import {settings} from '../../utils/Settings';
|
||||||
|
|
||||||
// Returns all *.js files under specDir (recursively) as relative paths to specDir, using '/'
|
// Returns all *.js files under specDir (recursively) as relative paths to specDir, using '/'
|
||||||
// instead of path.sep to separate pathname components.
|
// instead of path.sep to separate pathname components.
|
||||||
|
@ -57,7 +57,7 @@ exports.expressPreSession = async (hookName, {app}) => {
|
||||||
})().catch((err) => next(err || new Error(err)));
|
})().catch((err) => next(err || new Error(err)));
|
||||||
});
|
});
|
||||||
|
|
||||||
const rootTestFolder = path.join(root, 'src/tests/frontend/');
|
const rootTestFolder = path.join(settings.root, 'src/tests/frontend/');
|
||||||
|
|
||||||
app.get('/tests/frontend/index.html', (req, res) => {
|
app.get('/tests/frontend/index.html', (req, res) => {
|
||||||
res.redirect(['./', ...req.url.split('?').slice(1)].join('?'));
|
res.redirect(['./', ...req.url.split('?').slice(1)].join('?'));
|
||||||
|
|
|
@ -9,7 +9,7 @@ const path = require('path');
|
||||||
const _ = require('underscore');
|
const _ = require('underscore');
|
||||||
const pluginDefs = require('../../static/js/pluginfw/plugin_defs.js');
|
const pluginDefs = require('../../static/js/pluginfw/plugin_defs.js');
|
||||||
const existsSync = require('../utils/path_exists');
|
const existsSync = require('../utils/path_exists');
|
||||||
import {settings, root} from '../utils/Settings';
|
import {settings} from '../utils/Settings';
|
||||||
|
|
||||||
// returns all existing messages merged together and grouped by langcode
|
// returns all existing messages merged together and grouped by langcode
|
||||||
// {es: {"foo": "string"}, en:...}
|
// {es: {"foo": "string"}, en:...}
|
||||||
|
@ -40,7 +40,7 @@ const getAllLocales = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// add core supported languages first
|
// add core supported languages first
|
||||||
extractLangs(path.join(root, 'src/locales'));
|
extractLangs(path.join(settings.root, 'src/locales'));
|
||||||
|
|
||||||
// add plugins languages (if any)
|
// add plugins languages (if any)
|
||||||
for (const {package: {path: pluginPath}} of Object.values<I18nPluginDefs>(pluginDefs.plugins)) {
|
for (const {package: {path: pluginPath}} of Object.values<I18nPluginDefs>(pluginDefs.plugins)) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
export type SettingsObj = {
|
export type SettingsObj = {
|
||||||
|
root: string;
|
||||||
settingsFilename: string;
|
settingsFilename: string;
|
||||||
credentialsFilename: string;
|
credentialsFilename: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
@ -111,4 +112,14 @@ export type SettingsObj = {
|
||||||
enableAdminUITests: boolean;
|
enableAdminUITests: boolean;
|
||||||
lowerCasePadIds: boolean;
|
lowerCasePadIds: boolean;
|
||||||
randomVersionString: string;
|
randomVersionString: string;
|
||||||
|
getEpVersion: ()=>string;
|
||||||
|
abiwordAvailable: ()=>string;
|
||||||
|
sofficeAvailable: ()=>string;
|
||||||
|
exportAvailable: ()=>string;
|
||||||
|
getGitCommit: ()=>string;
|
||||||
|
storeSettings: (newSettings: SettingsObj)=>void;
|
||||||
|
coerceValue: (stringVal: string)=> string | number | boolean | null | undefined;
|
||||||
|
lookupEnvironmentVariables: (settings: SettingsObj)=>SettingsObj;
|
||||||
|
parseSettings: (settingsFilename: string, isSettings: boolean) => any;
|
||||||
|
reloadSettings: ()=>void;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {root, settings} from './Settings';
|
import {settings} from './Settings';
|
||||||
const fs = require('fs').promises;
|
const fs = require('fs').promises;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const plugins = require('../../static/js/pluginfw/plugin_defs');
|
const plugins = require('../../static/js/pluginfw/plugin_defs');
|
||||||
|
@ -33,7 +33,7 @@ const sanitizePathname = require('./sanitizePathname');
|
||||||
|
|
||||||
const logger = log4js.getLogger('Minify');
|
const logger = log4js.getLogger('Minify');
|
||||||
|
|
||||||
const ROOT_DIR = path.join(root, 'src/static/');
|
const ROOT_DIR = path.join(settings.root, 'src/static/');
|
||||||
|
|
||||||
const threadsPool = new Threads.Pool(() => Threads.spawn(new Threads.Worker('./MinifyWorker')), 2);
|
const threadsPool = new Threads.Pool(() => Threads.spawn(new Threads.Worker('./MinifyWorker')), 2);
|
||||||
|
|
||||||
|
|
|
@ -78,9 +78,9 @@ const initLogging = (config: any) => {
|
||||||
initLogging(defaultLogConfig(defaultLogLevel));
|
initLogging(defaultLogConfig(defaultLogLevel));
|
||||||
|
|
||||||
|
|
||||||
export const root = absolutePaths.findEtherpadRoot()
|
const root = absolutePaths.findEtherpadRoot();
|
||||||
|
|
||||||
export const settings: SettingsObj = {
|
export const settings: SettingsObj = {
|
||||||
|
root: absolutePaths.findEtherpadRoot(),
|
||||||
settingsFilename: absolutePaths.makeAbsolute(argv.settings || 'settings.json'),
|
settingsFilename: absolutePaths.makeAbsolute(argv.settings || 'settings.json'),
|
||||||
credentialsFilename: absolutePaths.makeAbsolute(argv.credentials || 'credentials.json'),
|
credentialsFilename: absolutePaths.makeAbsolute(argv.credentials || 'credentials.json'),
|
||||||
/**
|
/**
|
||||||
|
@ -403,35 +403,27 @@ export const settings: SettingsObj = {
|
||||||
* e.g. /p/EtHeRpAd to /p/etherpad
|
* e.g. /p/EtHeRpAd to /p/etherpad
|
||||||
*/
|
*/
|
||||||
lowerCasePadIds: false,
|
lowerCasePadIds: false,
|
||||||
randomVersionString: randomString(4)
|
randomVersionString: randomString(4),
|
||||||
}
|
// Return etherpad version from package.json
|
||||||
|
getEpVersion:()=>require('../../package.json').version,
|
||||||
/* Root path of the installation */
|
// checks if abiword is avaiable
|
||||||
logger.info('All relative paths will be interpreted relative to the identified ' +
|
abiwordAvailable: () => {
|
||||||
`Etherpad base dir: ${root}`);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// checks if abiword is avaiable
|
|
||||||
export const abiwordAvailable = () => {
|
|
||||||
if (settings.abiword != null) {
|
if (settings.abiword != null) {
|
||||||
return os.type().indexOf('Windows') !== -1 ? 'withoutPDF' : 'yes';
|
return os.type().indexOf('Windows') !== -1 ? 'withoutPDF' : 'yes';
|
||||||
} else {
|
} else {
|
||||||
return 'no';
|
return 'no';
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
sofficeAvailable: () => {
|
||||||
export const sofficeAvailable = () => {
|
|
||||||
if (settings.soffice != null) {
|
if (settings.soffice != null) {
|
||||||
return os.type().indexOf('Windows') !== -1 ? 'withoutPDF' : 'yes';
|
return os.type().indexOf('Windows') !== -1 ? 'withoutPDF' : 'yes';
|
||||||
} else {
|
} else {
|
||||||
return 'no';
|
return 'no';
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
exportAvailable: () => {
|
||||||
export const exportAvailable = () => {
|
const abiword = settings.abiwordAvailable();
|
||||||
const abiword = abiwordAvailable();
|
const soffice = settings.sofficeAvailable();
|
||||||
const soffice = sofficeAvailable();
|
|
||||||
|
|
||||||
if (abiword === 'no' && soffice === 'no') {
|
if (abiword === 'no' && soffice === 'no') {
|
||||||
return 'no';
|
return 'no';
|
||||||
|
@ -441,10 +433,9 @@ export const exportAvailable = () => {
|
||||||
} else {
|
} else {
|
||||||
return 'yes';
|
return 'yes';
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
// Provide git version if available
|
||||||
// Provide git version if available
|
getGitCommit: () => {
|
||||||
export const getGitCommit = () => {
|
|
||||||
let version = '';
|
let version = '';
|
||||||
try {
|
try {
|
||||||
let rootPath = root;
|
let rootPath = root;
|
||||||
|
@ -466,19 +457,15 @@ export const getGitCommit = () => {
|
||||||
logger.warn(`Can't get git version for server header\n${e.message}`);
|
logger.warn(`Can't get git version for server header\n${e.message}`);
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
};
|
},
|
||||||
|
/**
|
||||||
// Return etherpad version from package.json
|
|
||||||
export const getEpVersion = () => require('../../package.json').version;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Receives a settingsObj and, if the property name is a valid configuration
|
* Receives a settingsObj and, if the property name is a valid configuration
|
||||||
* item, stores it in the module's exported properties via a side effect.
|
* item, stores it in the module's exported properties via a side effect.
|
||||||
*
|
*
|
||||||
* This code refactors a previous version that copied & pasted the same code for
|
* This code refactors a previous version that copied & pasted the same code for
|
||||||
* both "settings.json" and "credentials.json".
|
* both "settings.json" and "credentials.json".
|
||||||
*/
|
*/
|
||||||
const storeSettings = (settingsObj: MapArrayType<any>) => {
|
storeSettings: (settingsObj: MapArrayType<any>) => {
|
||||||
for (const i of Object.keys(settingsObj || {})) {
|
for (const i of Object.keys(settingsObj || {})) {
|
||||||
if (nonSettings.includes(i)) {
|
if (nonSettings.includes(i)) {
|
||||||
logger.warn(`Ignoring setting: '${i}'`);
|
logger.warn(`Ignoring setting: '${i}'`);
|
||||||
|
@ -506,9 +493,8 @@ const storeSettings = (settingsObj: MapArrayType<any>) => {
|
||||||
logger.warn(`Unknown Setting: '${i}'. This setting doesn't exist or it was removed`);
|
logger.warn(`Unknown Setting: '${i}'. This setting doesn't exist or it was removed`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
/*
|
||||||
/*
|
|
||||||
* If stringValue is a numeric string, or its value is "true" or "false", coerce
|
* If stringValue is a numeric string, or its value is "true" or "false", coerce
|
||||||
* them to appropriate JS types. Otherwise return stringValue as-is.
|
* them to appropriate JS types. Otherwise return stringValue as-is.
|
||||||
*
|
*
|
||||||
|
@ -519,8 +505,8 @@ const storeSettings = (settingsObj: MapArrayType<any>) => {
|
||||||
* If the user wants a variable to be null by default, he'll have to use the
|
* If the user wants a variable to be null by default, he'll have to use the
|
||||||
* short syntax "${ABIWORD}", and not "${ABIWORD:null}": the latter would result
|
* short syntax "${ABIWORD}", and not "${ABIWORD:null}": the latter would result
|
||||||
* in the literal string "null", instead.
|
* in the literal string "null", instead.
|
||||||
*/
|
* */
|
||||||
const coerceValue = (stringValue: string) => {
|
coerceValue: (stringValue: string) => {
|
||||||
// cooked from https://stackoverflow.com/questions/175739/built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number
|
// cooked from https://stackoverflow.com/questions/175739/built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const isNumeric = !isNaN(stringValue) && !isNaN(parseFloat(stringValue) && isFinite(stringValue));
|
const isNumeric = !isNaN(stringValue) && !isNaN(parseFloat(stringValue) && isFinite(stringValue));
|
||||||
|
@ -543,9 +529,13 @@ const coerceValue = (stringValue: string) => {
|
||||||
default:
|
default:
|
||||||
return stringValue;
|
return stringValue;
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
* Takes a javascript object containing Etherpad's configuration, and returns
|
* Takes a javascript object containing Etherpad's configuration, and returns
|
||||||
* another object, in which all the string properties whose value is of the form
|
* another object, in which all the string properties whose value is of the form
|
||||||
* "${ENV_VAR}" or "${ENV_VAR:default_value}" got their value replaced with the
|
* "${ENV_VAR}" or "${ENV_VAR:default_value}" got their value replaced with the
|
||||||
|
@ -581,7 +571,7 @@ const coerceValue = (stringValue: string) => {
|
||||||
*
|
*
|
||||||
* see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter
|
* see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter
|
||||||
*/
|
*/
|
||||||
const lookupEnvironmentVariables = (obj: object) => {
|
lookupEnvironmentVariables: (obj: object) => {
|
||||||
const stringifiedAndReplaced = JSON.stringify(obj, (key, value) => {
|
const stringifiedAndReplaced = JSON.stringify(obj, (key, value) => {
|
||||||
/*
|
/*
|
||||||
* the first invocation of replacer() is with an empty key. Just go on, or
|
* the first invocation of replacer() is with an empty key. Just go on, or
|
||||||
|
@ -641,7 +631,7 @@ const lookupEnvironmentVariables = (obj: object) => {
|
||||||
logger.debug(`Environment variable "${envVarName}" not found for ` +
|
logger.debug(`Environment variable "${envVarName}" not found for ` +
|
||||||
`configuration key "${key}". Falling back to default value.`);
|
`configuration key "${key}". Falling back to default value.`);
|
||||||
|
|
||||||
return coerceValue(defaultValue);
|
return settings.coerceValue(defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// envVarName contained some value.
|
// envVarName contained some value.
|
||||||
|
@ -653,13 +643,14 @@ const lookupEnvironmentVariables = (obj: object) => {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`Configuration key "${key}" will be read from environment variable "${envVarName}"`);
|
`Configuration key "${key}" will be read from environment variable "${envVarName}"`);
|
||||||
|
|
||||||
return coerceValue(envVarValue!);
|
return settings.coerceValue(envVarValue!);
|
||||||
});
|
});
|
||||||
|
|
||||||
return JSON.parse(stringifiedAndReplaced);
|
return JSON.parse(stringifiedAndReplaced);
|
||||||
};
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* - reads the JSON configuration file settingsFilename from disk
|
* - reads the JSON configuration file settingsFilename from disk
|
||||||
* - strips the comments
|
* - strips the comments
|
||||||
* - replaces environment variables calling lookupEnvironmentVariables()
|
* - replaces environment variables calling lookupEnvironmentVariables()
|
||||||
|
@ -667,7 +658,7 @@ const lookupEnvironmentVariables = (obj: object) => {
|
||||||
*
|
*
|
||||||
* The isSettings variable only controls the error logging.
|
* The isSettings variable only controls the error logging.
|
||||||
*/
|
*/
|
||||||
export const parseSettings = (settingsFilename: string, isSettings: boolean) => {
|
parseSettings: (settingsFilename: string, isSettings: boolean) => {
|
||||||
let settingsStr = '';
|
let settingsStr = '';
|
||||||
|
|
||||||
let settingsType, notFoundMessage, notFoundFunction;
|
let settingsType, notFoundMessage, notFoundFunction;
|
||||||
|
@ -699,22 +690,19 @@ export const parseSettings = (settingsFilename: string, isSettings: boolean) =>
|
||||||
|
|
||||||
logger.info(`${settingsType} loaded from: ${settingsFilename}`);
|
logger.info(`${settingsType} loaded from: ${settingsFilename}`);
|
||||||
|
|
||||||
return lookupEnvironmentVariables(settings);
|
return settings.lookupEnvironmentVariables(settings);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
logger.error(`There was an error processing your ${settingsType} ` +
|
logger.error(`There was an error processing your ${settingsType} ` +
|
||||||
`file from ${settingsFilename}: ${e.message}`);
|
`file from ${settingsFilename}: ${e.message}`);
|
||||||
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
reloadSettings:() => {
|
||||||
export let randomVersionString: string | undefined
|
const settingsParsed = settings.parseSettings(settings.settingsFilename, true);
|
||||||
|
const credentials = settings.parseSettings(settings.credentialsFilename, false);
|
||||||
export const reloadSettings = () => {
|
settings.storeSettings(settingsParsed);
|
||||||
const settingsParsed = parseSettings(settings.settingsFilename, true);
|
settings.storeSettings(credentials);
|
||||||
const credentials = parseSettings(settings.credentialsFilename, false);
|
|
||||||
storeSettings(settingsParsed);
|
|
||||||
storeSettings(credentials);
|
|
||||||
|
|
||||||
// Init logging config
|
// Init logging config
|
||||||
settings.logconfig = defaultLogConfig(settings.loglevel ? settings.loglevel : defaultLogLevel);
|
settings.logconfig = defaultLogConfig(settings.loglevel ? settings.loglevel : defaultLogLevel);
|
||||||
|
@ -842,14 +830,16 @@ export const reloadSettings = () => {
|
||||||
* ACHTUNG: this may prevent caching HTTP proxies to work
|
* ACHTUNG: this may prevent caching HTTP proxies to work
|
||||||
* TODO: remove the "?v=randomstring" parameter, and replace with hashed filenames instead
|
* TODO: remove the "?v=randomstring" parameter, and replace with hashed filenames instead
|
||||||
*/
|
*/
|
||||||
randomVersionString = randomString(4);
|
logger.info(`Random string used for versioning assets: ${settings.randomVersionString}`);
|
||||||
logger.info(`Random string used for versioning assets: ${randomVersionString}`);
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
/* Root path of the installation */
|
||||||
export const exportedForTestingOnly = {
|
logger.info('All relative paths will be interpreted relative to the identified ' +
|
||||||
parseSettings,
|
`Etherpad base dir: ${root}`);
|
||||||
};
|
|
||||||
|
|
||||||
// initially load settings
|
// initially load settings
|
||||||
reloadSettings();
|
settings.reloadSettings
|
||||||
|
|
||||||
|
|
||||||
|
export default settings
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
const semver = require('semver');
|
const semver = require('semver');
|
||||||
import {getEpVersion, settings} from './Settings';
|
import {settings} from './Settings';
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const headers = {
|
const headers = {
|
||||||
'User-Agent': 'Etherpad/' + getEpVersion(),
|
'User-Agent': 'Etherpad/' + settings.getEpVersion(),
|
||||||
}
|
}
|
||||||
|
|
||||||
type Infos = {
|
type Infos = {
|
||||||
|
@ -45,7 +45,7 @@ exports.getLatestVersion = () => {
|
||||||
exports.needsUpdate = async (cb: Function) => {
|
exports.needsUpdate = async (cb: Function) => {
|
||||||
await loadEtherpadInformations()
|
await loadEtherpadInformations()
|
||||||
.then((info:Infos) => {
|
.then((info:Infos) => {
|
||||||
if (semver.gt(info.latestVersion, getEpVersion())) {
|
if (semver.gt(info.latestVersion, settings.getEpVersion())) {
|
||||||
if (cb) return cb(true);
|
if (cb) return cb(true);
|
||||||
}
|
}
|
||||||
}).catch((err: Error) => {
|
}).catch((err: Error) => {
|
||||||
|
|
|
@ -21,7 +21,7 @@ const fs = require('fs');
|
||||||
const fsp = fs.promises;
|
const fsp = fs.promises;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const zlib = require('zlib');
|
const zlib = require('zlib');
|
||||||
import {root} from './Settings';
|
import {settings} from './Settings';
|
||||||
const existsSync = require('./path_exists');
|
const existsSync = require('./path_exists');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ const util = require('util');
|
||||||
const _crypto = require('crypto');
|
const _crypto = require('crypto');
|
||||||
|
|
||||||
|
|
||||||
let CACHE_DIR = path.join(root, 'var/');
|
let CACHE_DIR = path.join(settings.root, 'var/');
|
||||||
CACHE_DIR = existsSync(CACHE_DIR) ? CACHE_DIR : undefined;
|
CACHE_DIR = existsSync(CACHE_DIR) ? CACHE_DIR : undefined;
|
||||||
|
|
||||||
type Headers = {
|
type Headers = {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {ChildProcess} from "node:child_process";
|
||||||
import {PromiseWithStd} from "../types/PromiseWithStd";
|
import {PromiseWithStd} from "../types/PromiseWithStd";
|
||||||
import {Readable} from "node:stream";
|
import {Readable} from "node:stream";
|
||||||
|
|
||||||
import {root} from "./Settings";
|
import {settings} from "./Settings";
|
||||||
|
|
||||||
import spawn from 'cross-spawn';
|
import spawn from 'cross-spawn';
|
||||||
import log4js from 'log4js';
|
import log4js from 'log4js';
|
||||||
|
@ -77,7 +77,7 @@ const logLines = (readable: undefined | Readable | null, logLineFn: (arg0: (stri
|
||||||
module.exports = exports = (args: string[], opts:any = {}) => {
|
module.exports = exports = (args: string[], opts:any = {}) => {
|
||||||
logger.debug(`Executing command: ${args.join(' ')}`);
|
logger.debug(`Executing command: ${args.join(' ')}`);
|
||||||
|
|
||||||
opts = {cwd: root, ...opts};
|
opts = {cwd: settings.root, ...opts};
|
||||||
logger.debug(`cwd: ${opts.cwd}`);
|
logger.debug(`cwd: ${opts.cwd}`);
|
||||||
|
|
||||||
// Log stdout and stderr by default.
|
// Log stdout and stderr by default.
|
||||||
|
@ -112,8 +112,8 @@ module.exports = exports = (args: string[], opts:any = {}) => {
|
||||||
opts.env = {
|
opts.env = {
|
||||||
...env, // Copy env to avoid modifying process.env or the caller's supplied env.
|
...env, // Copy env to avoid modifying process.env or the caller's supplied env.
|
||||||
[pathVarName]: [
|
[pathVarName]: [
|
||||||
path.join(root, 'src', 'node_modules', '.bin'),
|
path.join(settings.root, 'src', 'node_modules', '.bin'),
|
||||||
path.join(root, 'node_modules', '.bin'),
|
path.join(settings.root, 'node_modules', '.bin'),
|
||||||
...(PATH ? PATH.split(path.delimiter) : []),
|
...(PATH ? PATH.split(path.delimiter) : []),
|
||||||
].join(path.delimiter),
|
].join(path.delimiter),
|
||||||
};
|
};
|
||||||
|
|
|
@ -86,6 +86,7 @@
|
||||||
"@types/formidable": "^3.4.5",
|
"@types/formidable": "^3.4.5",
|
||||||
"@types/jsonminify": "^0.4.3",
|
"@types/jsonminify": "^0.4.3",
|
||||||
"@types/node": "^20.11.19",
|
"@types/node": "^20.11.19",
|
||||||
|
"@types/resolve": "^1.20.6",
|
||||||
"@types/underscore": "^1.11.15",
|
"@types/underscore": "^1.11.15",
|
||||||
"cypress": "^13.6.4",
|
"cypress": "^13.6.4",
|
||||||
"eslint": "^8.56.0",
|
"eslint": "^8.56.0",
|
||||||
|
|
|
@ -4,7 +4,7 @@ const log4js = require('log4js');
|
||||||
const plugins = require('./plugins');
|
const plugins = require('./plugins');
|
||||||
const hooks = require('./hooks');
|
const hooks = require('./hooks');
|
||||||
const runCmd = require('../../../node/utils/run_cmd');
|
const runCmd = require('../../../node/utils/run_cmd');
|
||||||
import {getEpVersion, reloadSettings, root, settings} from '../../../node/utils/Settings';
|
import {settings} from '../../../node/utils/Settings';
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const {PluginManager} = require('live-plugin-manager-pnpm');
|
const {PluginManager} = require('live-plugin-manager-pnpm');
|
||||||
const {promises: fs} = require('fs');
|
const {promises: fs} = require('fs');
|
||||||
|
@ -14,18 +14,18 @@ const logger = log4js.getLogger('plugins');
|
||||||
|
|
||||||
exports.manager = new PluginManager();
|
exports.manager = new PluginManager();
|
||||||
|
|
||||||
const installedPluginsPath = path.join(root, 'var/installed_plugins.json');
|
const installedPluginsPath = path.join(settings.root, 'var/installed_plugins.json');
|
||||||
|
|
||||||
const onAllTasksFinished = async () => {
|
const onAllTasksFinished = async () => {
|
||||||
await plugins.update();
|
await plugins.update();
|
||||||
await persistInstalledPlugins();
|
await persistInstalledPlugins();
|
||||||
reloadSettings();
|
settings.reloadSettings();
|
||||||
await hooks.aCallAll('loadSettings', {settings});
|
await hooks.aCallAll('loadSettings', {settings});
|
||||||
await hooks.aCallAll('restartServer');
|
await hooks.aCallAll('restartServer');
|
||||||
};
|
};
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
'User-Agent': `Etherpad/${getEpVersion()}`,
|
'User-Agent': `Etherpad/${settings.getEpVersion()}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
let tasks = 0;
|
let tasks = 0;
|
||||||
|
|
|
@ -9,7 +9,7 @@ const tsort = require('./tsort');
|
||||||
const pluginUtils = require('./shared');
|
const pluginUtils = require('./shared');
|
||||||
const defs = require('./plugin_defs');
|
const defs = require('./plugin_defs');
|
||||||
const {manager} = require('./installer');
|
const {manager} = require('./installer');
|
||||||
import {getEpVersion, root, settings} from "../../../node/utils/Settings";
|
import {settings} from "../../../node/utils/Settings";
|
||||||
|
|
||||||
const logger = log4js.getLogger('plugins');
|
const logger = log4js.getLogger('plugins');
|
||||||
|
|
||||||
|
@ -121,9 +121,9 @@ exports.getPackages = async () => {
|
||||||
|
|
||||||
newDependencies['ep_etherpad-lite'] = {
|
newDependencies['ep_etherpad-lite'] = {
|
||||||
name: 'ep_etherpad-lite',
|
name: 'ep_etherpad-lite',
|
||||||
version: getEpVersion(),
|
version: settings.getEpVersion(),
|
||||||
path: path.join(root, 'node_modules/ep_etherpad-lite'),
|
path: path.join(settings.root, 'node_modules/ep_etherpad-lite'),
|
||||||
realPath: path.join(root, 'src'),
|
realPath: path.join(settings.root, 'src'),
|
||||||
};
|
};
|
||||||
|
|
||||||
return newDependencies;
|
return newDependencies;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<%
|
<%
|
||||||
var settings = require("ep_etherpad-lite/node/utils/Settings").settings
|
var settings = require("ep_etherpad-lite/node/utils/Settings")
|
||||||
%>
|
%>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<%
|
<%
|
||||||
var settings = require("ep_etherpad-lite/node/utils/Settings").settings
|
var settings = require("ep_etherpad-lite/node/utils/Settings")
|
||||||
, langs = require("ep_etherpad-lite/node/hooks/i18n").availableLangs
|
, langs = require("ep_etherpad-lite/node/hooks/i18n").availableLangs
|
||||||
, pluginUtils = require('ep_etherpad-lite/static/js/pluginfw/shared')
|
, pluginUtils = require('ep_etherpad-lite/static/js/pluginfw/shared')
|
||||||
;
|
;
|
||||||
|
@ -455,10 +455,10 @@
|
||||||
<!-- Bootstrap page -->
|
<!-- Bootstrap page -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt
|
// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt
|
||||||
var clientVars = {
|
const clientVars = {
|
||||||
// This is needed to fetch /pluginfw/plugin-definitions.json, which happens before the
|
// This is needed to fetch /pluginfw/plugin-definitions.json, which happens before the
|
||||||
// server sends the CLIENT_VARS message.
|
// server sends the CLIENT_VARS message.
|
||||||
randomVersionString: <%-JSON.stringify(settings.randomVersionString)%>,
|
randomVersionString: <;%-JSON.stringify(settings.randomVersionString)%>,
|
||||||
};
|
};
|
||||||
(function () {
|
(function () {
|
||||||
var pathComponents = location.pathname.split('/');
|
var pathComponents = location.pathname.split('/');
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<%
|
<%
|
||||||
var settings = require("ep_etherpad-lite/node/utils/Settings").settings
|
var settings = require("ep_etherpad-lite/node/utils/Settings")
|
||||||
, langs = require("ep_etherpad-lite/node/hooks/i18n").availableLangs
|
, langs = require("ep_etherpad-lite/node/hooks/i18n").availableLangs
|
||||||
%>
|
%>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
|
|
|
@ -5,7 +5,7 @@ const common = require('../common');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const fsp = fs.promises;
|
const fsp = fs.promises;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
import {root, settings} from '../../../node/utils/Settings'
|
import {settings} from '../../../node/utils/Settings'
|
||||||
const superagent = require('superagent');
|
const superagent = require('superagent');
|
||||||
|
|
||||||
describe(__filename, function () {
|
describe(__filename, function () {
|
||||||
|
@ -19,13 +19,13 @@ describe(__filename, function () {
|
||||||
before(async function () {
|
before(async function () {
|
||||||
agent = await common.init();
|
agent = await common.init();
|
||||||
wantCustomIcon = await fsp.readFile(path.join(__dirname, 'favicon-test-custom.png'));
|
wantCustomIcon = await fsp.readFile(path.join(__dirname, 'favicon-test-custom.png'));
|
||||||
wantDefaultIcon = await fsp.readFile(path.join(root, 'src', 'static', 'favicon.ico'));
|
wantDefaultIcon = await fsp.readFile(path.join(settings.root, 'src', 'static', 'favicon.ico'));
|
||||||
wantSkinIcon = await fsp.readFile(path.join(__dirname, 'favicon-test-skin.png'));
|
wantSkinIcon = await fsp.readFile(path.join(__dirname, 'favicon-test-skin.png'));
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
backupSettings = {...settings};
|
backupSettings = {...settings};
|
||||||
skinDir = await fsp.mkdtemp(path.join(root, 'src', 'static', 'skins', 'test-'));
|
skinDir = await fsp.mkdtemp(path.join(settings.root, 'src', 'static', 'skins', 'test-'));
|
||||||
settings.skinName = path.basename(skinDir);
|
settings.skinName = path.basename(skinDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ describe(__filename, function () {
|
||||||
|
|
||||||
it('uses custom favicon if set (relative pathname)', async function () {
|
it('uses custom favicon if set (relative pathname)', async function () {
|
||||||
settings.favicon =
|
settings.favicon =
|
||||||
path.relative(root, path.join(__dirname, 'favicon-test-custom.png'));
|
path.relative(settings.root, path.join(__dirname, 'favicon-test-custom.png'));
|
||||||
assert(!path.isAbsolute(settings.favicon));
|
assert(!path.isAbsolute(settings.favicon));
|
||||||
const {body: gotIcon} = await agent.get('/favicon.ico')
|
const {body: gotIcon} = await agent.get('/favicon.ico')
|
||||||
.accept('png').buffer(true).parse(superagent.parse.image)
|
.accept('png').buffer(true).parse(superagent.parse.image)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const assert = require('assert').strict;
|
const assert = require('assert').strict;
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
import * as settings from '../../../node/utils/Settings';
|
import settings from '../../../node/utils/Settings';
|
||||||
const superagent = require('superagent');
|
const superagent = require('superagent');
|
||||||
|
|
||||||
describe(__filename, function () {
|
describe(__filename, function () {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const assert = require('assert').strict;
|
const assert = require('assert').strict;
|
||||||
import {parseSettings} from '../../../node/utils/Settings';
|
import settings from '../../../node/utils/Settings';
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const process = require('process');
|
const process = require('process');
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ describe(__filename, function () {
|
||||||
before(async function () {
|
before(async function () {
|
||||||
for (const tc of envVarSubstTestCases) process.env[tc.var] = tc.val;
|
for (const tc of envVarSubstTestCases) process.env[tc.var] = tc.val;
|
||||||
delete process.env.UNSET_VAR;
|
delete process.env.UNSET_VAR;
|
||||||
settings = parseSettings(path.join(__dirname, 'settings.json'), true);
|
settings = settings.parseSettings(path.join(__dirname, 'settings.json'), true);
|
||||||
assert(settings != null);
|
assert(settings != null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
import * as settings from '../../../node/utils/Settings';
|
import settings from '../../../node/utils/Settings';
|
||||||
|
|
||||||
describe(__filename, function () {
|
describe(__filename, function () {
|
||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
const assert = require('assert').strict;
|
const assert = require('assert').strict;
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const plugins = require('../../../static/js/pluginfw/plugin_defs');
|
const plugins = require('../../../static/js/pluginfw/plugin_defs');
|
||||||
import * as settings from '../../../node/utils/Settings';
|
import settings from '../../../node/utils/Settings';
|
||||||
|
|
||||||
describe(__filename, function () {
|
describe(__filename, function () {
|
||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
|
|
Loading…
Reference in a new issue