mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
Fixed comp
This commit is contained in:
parent
99c834651c
commit
d70387966b
7 changed files with 33 additions and 31 deletions
|
@ -14,12 +14,12 @@ import {pluginDefs} from '../../../static/js/pluginfw/plugin_defs';
|
||||||
import {build, buildSync} from 'esbuild'
|
import {build, buildSync} from 'esbuild'
|
||||||
let ioI: { sockets: { sockets: any[]; }; } | null = null
|
let ioI: { sockets: { sockets: any[]; }; } | null = null
|
||||||
|
|
||||||
exports.socketio = (hookName: string, {io}: any) => {
|
export const socketio = (hookName: string, {io}: any) => {
|
||||||
ioI = io
|
ioI = io
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
exports.expressPreSession = async (hookName:string, {app}:any) => {
|
export const expressPreSession = async (hookName:string, {app}:any) => {
|
||||||
// This endpoint is intended to conform to:
|
// This endpoint is intended to conform to:
|
||||||
// https://www.ietf.org/archive/id/draft-inadarei-api-health-check-06.html
|
// https://www.ietf.org/archive/id/draft-inadarei-api-health-check-06.html
|
||||||
app.get('/health', (req:any, res:any) => {
|
app.get('/health', (req:any, res:any) => {
|
||||||
|
@ -227,7 +227,7 @@ const convertTypescriptWatched = (content: string, cb: (output:string, hash: str
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.expressCreateServer = async (hookName: string, args: any, cb: Function) => {
|
export const expressCreateServer = async (hookName: string, args: any, cb: Function) => {
|
||||||
// serve index.html under /
|
// serve index.html under /
|
||||||
args.app.get('/', (req: any, res: any) => {
|
args.app.get('/', (req: any, res: any) => {
|
||||||
res.send(requireP('ep_etherpad-lite/templates/index.html', {req}));
|
res.send(requireP('ep_etherpad-lite/templates/index.html', {req}));
|
||||||
|
@ -235,7 +235,8 @@ exports.expressCreateServer = async (hookName: string, args: any, cb: Function)
|
||||||
|
|
||||||
|
|
||||||
const padString = requireP('ep_etherpad-lite/templates/padBootstrap.ts', {
|
const padString = requireP('ep_etherpad-lite/templates/padBootstrap.ts', {
|
||||||
pluginModules: (() => {
|
// @ts-ignore
|
||||||
|
pluginModules: (() => {
|
||||||
const pluginModules = new Set();
|
const pluginModules = new Set();
|
||||||
for (const part of pluginDefs.getParts()) {
|
for (const part of pluginDefs.getParts()) {
|
||||||
for (const [, hookFnName] of Object.entries(part.client_hooks || {})) {
|
for (const [, hookFnName] of Object.entries(part.client_hooks || {})) {
|
||||||
|
@ -249,6 +250,7 @@ exports.expressCreateServer = async (hookName: string, args: any, cb: Function)
|
||||||
})
|
})
|
||||||
|
|
||||||
const timeSliderString = requireP('ep_etherpad-lite/templates/timeSliderBootstrap.ts', {
|
const timeSliderString = requireP('ep_etherpad-lite/templates/timeSliderBootstrap.ts', {
|
||||||
|
// @ts-ignore
|
||||||
pluginModules: (() => {
|
pluginModules: (() => {
|
||||||
const pluginModules = new Set();
|
const pluginModules = new Set();
|
||||||
for (const part of pluginDefs.getParts()) {
|
for (const part of pluginDefs.getParts()) {
|
||||||
|
|
|
@ -122,17 +122,18 @@ const generateLocaleIndex = (locales:MapArrayType<string>) => {
|
||||||
return JSON.stringify(result);
|
return JSON.stringify(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export let availableLangs: any
|
||||||
|
|
||||||
exports.expressPreSession = async (hookName:string, {app}:any) => {
|
export const expressPreSession = async (hookName:string, {app}:any) => {
|
||||||
// regenerate locales on server restart
|
// regenerate locales on server restart
|
||||||
const locales = getAllLocales();
|
const locales = getAllLocales();
|
||||||
const localeIndex = generateLocaleIndex(locales);
|
const localeIndex = generateLocaleIndex(locales);
|
||||||
exports.availableLangs = getAvailableLangs(locales);
|
availableLangs = getAvailableLangs(locales);
|
||||||
|
|
||||||
app.get('/locales/:locale', (req:any, res:any) => {
|
app.get('/locales/:locale', (req:any, res:any) => {
|
||||||
// works with /locale/en and /locale/en.json requests
|
// works with /locale/en and /locale/en.json requests
|
||||||
const locale = req.params.locale.split('.')[0];
|
const locale = req.params.locale.split('.')[0];
|
||||||
if (Object.prototype.hasOwnProperty.call(exports.availableLangs, locale)) {
|
if (Object.prototype.hasOwnProperty.call(availableLangs, locale)) {
|
||||||
res.setHeader('Cache-Control', `public, max-age=${settings.maxAge}`);
|
res.setHeader('Cache-Control', `public, max-age=${settings.maxAge}`);
|
||||||
res.setHeader('Content-Type', 'application/json; charset=utf-8');
|
res.setHeader('Content-Type', 'application/json; charset=utf-8');
|
||||||
res.send(`{"${locale}":${JSON.stringify(locales[locale])}}`);
|
res.send(`{"${locale}":${JSON.stringify(locales[locale])}}`);
|
||||||
|
|
|
@ -61,7 +61,7 @@ const requestURI = async (url: string, method: string, headers: MapArrayType<any
|
||||||
let mockResponse;
|
let mockResponse;
|
||||||
const p = new Promise((resolve) => {
|
const p = new Promise((resolve) => {
|
||||||
mockResponse = {
|
mockResponse = {
|
||||||
writeHead: (_status, _headers) => {
|
writeHead: (_status: number, _headers: { [x: string]: any; }) => {
|
||||||
status = _status;
|
status = _status;
|
||||||
for (const header in _headers) {
|
for (const header in _headers) {
|
||||||
if (Object.prototype.hasOwnProperty.call(_headers, header)) {
|
if (Object.prototype.hasOwnProperty.call(_headers, header)) {
|
||||||
|
@ -69,16 +69,16 @@ const requestURI = async (url: string, method: string, headers: MapArrayType<any
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setHeader: (header, value) => {
|
setHeader: (header: string, value: { toString: () => any; }) => {
|
||||||
headers[header.toLowerCase()] = value.toString();
|
headers[header.toLowerCase()] = value.toString();
|
||||||
},
|
},
|
||||||
header: (header: string, value: string) => {
|
header: (header: string, value: string) => {
|
||||||
headers[header.toLowerCase()] = value.toString();
|
headers[header.toLowerCase()] = value.toString();
|
||||||
},
|
},
|
||||||
write: (_content) => {
|
write: (_content: string) => {
|
||||||
_content && content.push(_content);
|
_content && content.push(_content);
|
||||||
},
|
},
|
||||||
end: (_content) => {
|
end: (_content: string) => {
|
||||||
_content && content.push(_content);
|
_content && content.push(_content);
|
||||||
resolve([status, headers, content.join('')]);
|
resolve([status, headers, content.join('')]);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<%
|
<%
|
||||||
var settings = require("ep_etherpad-lite/node/utils/Settings");
|
import settings from 'ep_etherpad-lite/node/utils/Settings'
|
||||||
%>
|
%>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
<%
|
<%
|
||||||
var settings = require("ep_etherpad-lite/node/utils/Settings")
|
import settings from 'ep_etherpad-lite/node/utils/Settings'
|
||||||
, langs = require("ep_etherpad-lite/node/hooks/i18n").availableLangs
|
import langs from 'ep_etherpad-lite/node/hooks/i18n'
|
||||||
, pluginUtils = require('ep_etherpad-lite/static/js/pluginfw/shared')
|
import {pluginUtils} from 'ep_etherpad-lite/static/js/pluginfw/shared'
|
||||||
;
|
|
||||||
%>
|
%>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html translate="no" class="pad <%=pluginUtils.clientPluginNames().join(' '); %> <%=settings.skinVariants%>">
|
<html translate="no" class="pad <%=pluginUtils.clientPluginNames().join(' '); %> <%=settings.skinVariants%>">
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import browser from '../static/js/vendors/browser'
|
import browser from 'ep_etherpad-lite/static/js/vendors/browser'
|
||||||
import {padeditbar} from '../static/js/pad_editbar'
|
import {padeditbar} from 'ep_etherpad-lite/static/js/pad_editbar'
|
||||||
import {padImpExp} from '../static/js/pad_impexp'
|
import {padImpExp} from 'ep_etherpad-lite/static/js/pad_impexp'
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
|
||||||
|
@ -17,20 +17,20 @@ import {padImpExp} from '../static/js/pad_impexp'
|
||||||
//window.require.resolveTmp = require.resolve('ep_etherpad-lite/static/js/pad_cookie');
|
//window.require.resolveTmp = require.resolve('ep_etherpad-lite/static/js/pad_cookie');
|
||||||
|
|
||||||
const basePath = new URL('..', window.location.href).pathname;
|
const basePath = new URL('..', window.location.href).pathname;
|
||||||
window.$ = window.jQuery = require('../../src/static/js/vendors/jquery');
|
window.$ = window.jQuery = require('ep_etherpad-lite/static/js/vendors/jquery');
|
||||||
window.browser = browser;
|
window.browser = browser;
|
||||||
const pad = require('../../src/static/js/pad');
|
const pad = require('ep_etherpad-lite/static/js/pad');
|
||||||
pad.baseURL = basePath;
|
pad.baseURL = basePath;
|
||||||
window.plugins = require('../../src/static/js/pluginfw/client_plugins');
|
window.plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins');
|
||||||
const hooks = require('../../src/static/js/pluginfw/hooks');
|
const hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
||||||
|
|
||||||
// TODO: These globals shouldn't exist.
|
// TODO: These globals shouldn't exist.
|
||||||
window.pad = pad.pad;
|
window.pad = pad.pad;
|
||||||
window.chat = require('../../src/static/js/chat').chat;
|
window.chat = require('ep_etherpad-lite/static/js/chat').chat;
|
||||||
window.padeditbar = padeditbar;
|
window.padeditbar = padeditbar;
|
||||||
window.padimpexp = padimpexp;
|
window.padimpexp = padImpExp;
|
||||||
await import('../../src/static/js/skin_variants')
|
await import('ep_etherpad-lite/static/js/skin_variants')
|
||||||
await import('../../src/static/js/basic_error_handler')
|
await import('ep_etherpad-lite/static/js/basic_error_handler')
|
||||||
|
|
||||||
window.plugins.baseURL = basePath;
|
window.plugins.baseURL = basePath;
|
||||||
await window.plugins.update(new Map([
|
await window.plugins.update(new Map([
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt
|
// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt
|
||||||
|
|
||||||
import {setBaseURl} from "ep_etherpad-lite/static/js/timeslider";
|
import {setBaseURl} from "ep_etherpad-lite/static/js/timeslider";
|
||||||
import {padeditbar as padbar} from '../static/js/pad_editbar'
|
import {padeditbar as padbar} from 'ep_etherpad-lite/static/js/pad_editbar'
|
||||||
import {padImpExp as padExp} from '../static/js/pad_impexp'
|
import {padImpExp as padExp} from 'ep_etherpad-lite/static/js/pad_impexp'
|
||||||
|
import browser from "ep_etherpad-lite/static/js/vendors/browser";
|
||||||
window.clientVars = {
|
window.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.
|
||||||
|
@ -21,7 +21,7 @@ import * as timeSlider from 'ep_etherpad-lite/static/js/timeslider'
|
||||||
window.$ = window.jQuery = require('ep_etherpad-lite/static/js/vendors/jquery'); // Expose jQuery #HACK
|
window.$ = window.jQuery = require('ep_etherpad-lite/static/js/vendors/jquery'); // Expose jQuery #HACK
|
||||||
require('ep_etherpad-lite/static/js/vendors/gritter')
|
require('ep_etherpad-lite/static/js/vendors/gritter')
|
||||||
|
|
||||||
window.browser = require('src/static/js/vendors/browser');
|
window.browser = browser;
|
||||||
|
|
||||||
window.plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins');
|
window.plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins');
|
||||||
const socket = timeSlider.socket;
|
const socket = timeSlider.socket;
|
||||||
|
|
Loading…
Reference in a new issue