mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 06:37:10 -04:00
Fixed timeslider
This commit is contained in:
parent
ea5073ce13
commit
a3e9f29558
4 changed files with 85 additions and 49 deletions
|
@ -98,10 +98,30 @@ exports.expressCreateServer = async (hookName: string, args: any, cb: Function)
|
|||
})(),
|
||||
settings,
|
||||
}));
|
||||
|
||||
await fsp.writeFile(
|
||||
path.join(settings.root, 'var/js/timesliderBootstrap.js'),
|
||||
eejs.require('ep_etherpad-lite/templates/timeSliderBootstrap.js', {
|
||||
pluginModules: (() => {
|
||||
const pluginModules = new Set();
|
||||
for (const part of plugins.parts) {
|
||||
for (const [, hookFnName] of Object.entries(part.client_hooks || {})) {
|
||||
console.log(hookFnName.split(':')[0])
|
||||
pluginModules.add(hookFnName.split(':')[0]);
|
||||
}
|
||||
}
|
||||
return [...pluginModules];
|
||||
})(),
|
||||
settings,
|
||||
}));
|
||||
|
||||
const hash = createHash('sha256').update(fs.readFileSync(path.join(settings.root, 'var/js/padbootstrap.js'))).digest('hex');
|
||||
const hashTimeSlider = createHash('sha256').update(fs.readFileSync(path.join(settings.root, 'var/js/timeSliderBootstrap.js'))).digest('hex');
|
||||
|
||||
const fileName = `padbootstrap-${hash.substring(0,16)}.min.js`
|
||||
const result = buildSync({
|
||||
const fileNameTimeSlider = `timeSliderBootstrap-${hash.substring(0,16)}.min.js`
|
||||
|
||||
buildSync({
|
||||
entryPoints: [settings.root + "/var/js/padbootstrap.js"], // Entry file(s)
|
||||
bundle: true, // Bundle the files together
|
||||
minify: false, // Minify the output
|
||||
|
@ -114,6 +134,19 @@ exports.expressCreateServer = async (hookName: string, args: any, cb: Function)
|
|||
outfile: settings.root + `/var/js/${fileName}`, // Output file
|
||||
})
|
||||
|
||||
buildSync({
|
||||
entryPoints: [settings.root + "/var/js/timesliderBootstrap.js"], // Entry file(s)
|
||||
bundle: true, // Bundle the files together
|
||||
minify: false, // Minify the output
|
||||
sourcemap: true, // Generate source maps
|
||||
sourceRoot: settings.root+"/src/static/js/",
|
||||
target: ['es2020'], // Target ECMAScript version
|
||||
metafile: true,
|
||||
|
||||
write: true, // Do not write to file system,
|
||||
outfile: settings.root + `/var/js/${fileNameTimeSlider}`, // Output file
|
||||
})
|
||||
|
||||
|
||||
args.app.get(`/${fileName}`, (req: any, res: any) => {
|
||||
res.sendFile(settings.root+`/var/js/${fileName}`)
|
||||
|
@ -123,6 +156,17 @@ exports.expressCreateServer = async (hookName: string, args: any, cb: Function)
|
|||
res.sendFile(settings.root+`/var/js/${fileName}.map`)
|
||||
})
|
||||
|
||||
args.app.get(`/${fileNameTimeSlider}`, (req: any, res: any) => {
|
||||
res.sendFile(settings.root+`/var/js/${fileNameTimeSlider}`)
|
||||
})
|
||||
|
||||
args.app.get(`/${fileNameTimeSlider}.map`, (req: any, res: any) => {
|
||||
res.sendFile(settings.root+`/var/js/${fileNameTimeSlider}.map`)
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// serve pad.html under /p
|
||||
args.app.get('/p/:pad', (req: any, res: any, next: Function) => {
|
||||
|
@ -153,6 +197,7 @@ exports.expressCreateServer = async (hookName: string, args: any, cb: Function)
|
|||
res.send(eejs.require('ep_etherpad-lite/templates/timeslider.html', {
|
||||
req,
|
||||
toolbar,
|
||||
entrypoint: "/"+fileNameTimeSlider
|
||||
}));
|
||||
});
|
||||
|
||||
|
|
2
src/static/js/vendors/html10n.js
vendored
2
src/static/js/vendors/html10n.js
vendored
|
@ -725,7 +725,7 @@ export let html10n = (function(window, document, undefined) {
|
|||
return;
|
||||
|
||||
// initialize _pluralRules
|
||||
if (!this._pluralRules)
|
||||
if (!("_pluralRules" in this))
|
||||
this._pluralRules = getPluralRules(html10n.language);
|
||||
var index = this._pluralRules(n);
|
||||
|
||||
|
|
37
src/templates/timeSliderBootstrap.js
Normal file
37
src/templates/timeSliderBootstrap.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt
|
||||
window.clientVars = {
|
||||
// This is needed to fetch /pluginfw/plugin-definitions.json, which happens before the
|
||||
// server sends the CLIENT_VARS message.
|
||||
randomVersionString: <%-JSON.stringify(settings.randomVersionString)%>,
|
||||
};
|
||||
let BroadcastSlider;
|
||||
|
||||
|
||||
(function () {
|
||||
const timeSlider = require('ep_etherpad-lite/static/js/timeslider')
|
||||
const pathComponents = location.pathname.split('/');
|
||||
|
||||
// Strip 'p', the padname and 'timeslider' from the pathname and set as baseURL
|
||||
const baseURL = pathComponents.slice(0,pathComponents.length-3).join('/') + '/';
|
||||
require('ep_etherpad-lite/static/js/l10n')
|
||||
window.$ = window.jQuery = require('ep_etherpad-lite/static/js/rjquery').jQuery; // Expose jQuery #HACK
|
||||
require('ep_etherpad-lite/static/js/vendors/gritter')
|
||||
|
||||
window.browser = require('ep_etherpad-lite/static/js/vendors/browser');
|
||||
|
||||
window.plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins');
|
||||
const socket = timeSlider.socket;
|
||||
BroadcastSlider = timeSlider.BroadcastSlider;
|
||||
plugins.baseURL = baseURL;
|
||||
plugins.update(function () {
|
||||
|
||||
|
||||
/* TODO: These globals shouldn't exist. */
|
||||
|
||||
});
|
||||
const padeditbar = require('ep_etherpad-lite/static/js/pad_editbar').padeditbar;
|
||||
const padimpexp = require('ep_etherpad-lite/static/js/pad_impexp').padimpexp;
|
||||
timeSlider.baseURL = baseURL;
|
||||
timeSlider.init();
|
||||
padeditbar.init()
|
||||
})();
|
|
@ -47,8 +47,6 @@
|
|||
|
||||
<link rel="localizations" type="application/l10n+json" href="../../locales.json" />
|
||||
<% e.begin_block("timesliderScripts"); %>
|
||||
<script type="text/javascript" src="../../static/js/vendors/html10n.js?v=<%=settings.randomVersionString%>"></script>
|
||||
<script type="text/javascript" src="../../static/js/l10n.js?v=<%=settings.randomVersionString%>"></script>
|
||||
<% e.end_block(); %>
|
||||
</head>
|
||||
|
||||
|
@ -250,58 +248,14 @@
|
|||
<!-------- JAVASCRIPT --------->
|
||||
<!----------------------------->
|
||||
|
||||
<script type="text/javascript" src="../../static/js/require-kernel.js?v=<%=settings.randomVersionString%>"></script>
|
||||
<script type="text/javascript" src="../../socket.io/socket.io.js"></script>
|
||||
|
||||
<!-- Include base packages manually (this help with debugging) -->
|
||||
<script type="text/javascript" src="../../javascripts/lib/ep_etherpad-lite/static/js/timeslider.js?callback=require.define&v=<%=settings.randomVersionString%>"></script>
|
||||
<script type="text/javascript" src="../../javascripts/lib/ep_etherpad-lite/static/js/ace2_common.js?callback=require.define&v=<%=settings.randomVersionString%>"></script>
|
||||
|
||||
<script type="text/javascript" src="../../static/skins/<%=encodeURI(settings.skinName)%>/timeslider.js?v=<%=settings.randomVersionString%>"></script>
|
||||
|
||||
<!-- Bootstrap -->
|
||||
<script type="text/javascript" >
|
||||
// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt
|
||||
var clientVars = {
|
||||
// This is needed to fetch /pluginfw/plugin-definitions.json, which happens before the
|
||||
// server sends the CLIENT_VARS message.
|
||||
randomVersionString: <%-JSON.stringify(settings.randomVersionString)%>,
|
||||
};
|
||||
let BroadcastSlider;
|
||||
(function () {
|
||||
const pathComponents = location.pathname.split('/');
|
||||
|
||||
// Strip 'p', the padname and 'timeslider' from the pathname and set as baseURL
|
||||
const baseURL = pathComponents.slice(0,pathComponents.length-3).join('/') + '/';
|
||||
|
||||
|
||||
require.setRootURI(baseURL + "javascripts/src");
|
||||
require.setLibraryURI(baseURL + "javascripts/lib");
|
||||
require.setGlobalKeyPath("require");
|
||||
|
||||
$ = jQuery = require('ep_etherpad-lite/static/js/rjquery').jQuery; // Expose jQuery #HACK
|
||||
browser = require('ep_etherpad-lite/static/js/vendors/browser');
|
||||
|
||||
const plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins');
|
||||
const socket = require('ep_etherpad-lite/static/js/timeslider').socket;
|
||||
BroadcastSlider = require('ep_etherpad-lite/static/js/timeslider').BroadcastSlider;
|
||||
plugins.baseURL = baseURL;
|
||||
|
||||
plugins.update(function () {
|
||||
const hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
||||
const timeslider = require('ep_etherpad-lite/static/js/timeslider')
|
||||
timeslider.baseURL = baseURL;
|
||||
timeslider.init();
|
||||
|
||||
/* TODO: These globals shouldn't exist. */
|
||||
const padeditbar = require('ep_etherpad-lite/static/js/pad_editbar').padeditbar;
|
||||
const padimpexp = require('ep_etherpad-lite/static/js/pad_impexp').padimpexp;
|
||||
|
||||
padeditbar.init()
|
||||
});
|
||||
})();
|
||||
// @license-end
|
||||
</script>
|
||||
<script src="<%=entrypoint%>"></script>
|
||||
<% e.end_block(); %>
|
||||
<div style="display:none"><a href="/javascript" data-jslicense="1">JavaScript license information</a></div>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue