2021-01-21 21:06:52 +00:00
|
|
|
'use strict';
|
2024-02-05 21:13:02 +01:00
|
|
|
import {ArgsExpressType} from "../../types/ArgsExpressType";
|
2024-03-09 23:07:09 +01:00
|
|
|
import path from "path";
|
2024-03-10 23:18:50 +01:00
|
|
|
import fs from "fs";
|
2024-03-13 10:48:51 +01:00
|
|
|
import express from "express";
|
2024-03-09 23:07:09 +01:00
|
|
|
const settings = require('ep_etherpad-lite/node/utils/Settings');
|
2012-11-05 12:58:02 +00:00
|
|
|
|
2024-03-09 23:07:09 +01:00
|
|
|
const ADMIN_PATH = path.join(settings.root, 'src', 'templates', 'admin');
|
2023-10-17 12:49:56 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add the admin navigation link
|
|
|
|
* @param hookName {String} the name of the hook
|
|
|
|
* @param args {Object} the object containing the arguments
|
|
|
|
* @param {Function} cb the callback function
|
|
|
|
* @return {*}
|
|
|
|
*/
|
2024-02-05 21:13:02 +01:00
|
|
|
exports.expressCreateServer = (hookName:string, args: ArgsExpressType, cb:Function): any => {
|
2024-03-13 10:48:51 +01:00
|
|
|
args.app.use('/admin/', express.static(path.join(__dirname, '../../../templates/admin'), {maxAge: 1000 * 60 * 60 * 24}));
|
|
|
|
args.app.get('/admin/*', (_request:any, response:any)=>{
|
|
|
|
response.sendFile(path.resolve(__dirname,'../../../templates/admin', 'index.html'));
|
|
|
|
} )
|
2024-03-09 23:07:09 +01:00
|
|
|
args.app.get('/admin', (req:any, res:any, next:Function) => {
|
|
|
|
if ('/' !== req.path[req.path.length - 1]) return res.redirect('./admin/');
|
|
|
|
})
|
2020-10-10 22:51:26 -04:00
|
|
|
return cb();
|
2020-11-23 13:24:19 -05:00
|
|
|
};
|