Compare commits

...

10 Commits

Author SHA1 Message Date
John McLear 26ba5efd25 attempt to add hooks, socket and color utils but doesnt seem to work? 2015-06-21 13:08:29 +01:00
John McLear 0f46f04dee handle urls with additional content 2015-06-21 13:02:57 +01:00
John McLear 039e01bd8f use correct plugin path 2015-06-21 12:46:02 +01:00
John McLear 4840e7ed58 support for correct paths and for plugins without client hooks 2015-06-21 12:14:15 +01:00
John McLear c866f7ac77 working include of plugin javascript files 2015-06-21 11:58:12 +01:00
John McLear 58c011ca1c logic for getting client paths from plugins 2015-06-21 11:37:47 +01:00
John McLear 99cc915d91 extend pad files so they are prefetched on each page 2015-06-21 11:08:10 +01:00
John McLear 1118cc56eb move everything to headers 2015-06-21 11:03:32 +01:00
John McLear 4a1253680c indentation 2015-06-20 12:26:12 +01:00
John McLear 01bc55b8e1 prefetch pad files from index page 2015-06-20 11:59:53 +01:00
3 changed files with 88 additions and 20 deletions

View File

@ -1,4 +1,5 @@
var path = require('path');
var async = require('async');
var eejs = require('ep_etherpad-lite/node/eejs');
var toolbar = require("ep_etherpad-lite/node/utils/toolbar");
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
@ -12,7 +13,9 @@ exports.expressCreateServer = function (hook_name, args, cb) {
//serve index.html under /
args.app.get('/', function(req, res)
{
res.send(eejs.require("ep_etherpad-lite/templates/index.html"));
sendPadHeaderFiles(res, function(){
res.send(eejs.require("ep_etherpad-lite/templates/index.html"));
});
});
//serve robots.txt
@ -33,32 +36,36 @@ exports.expressCreateServer = function (hook_name, args, cb) {
//serve pad.html under /p
args.app.get('/p/:pad', function(req, res, next)
{
// The below might break for pads being rewritten
var isReadOnly = req.url.indexOf("/p/r.") === 0;
sendPadHeaderFiles(res, function(){
// The below might break for pads being rewritten
var isReadOnly = req.url.indexOf("/p/r.") === 0;
hooks.callAll("padInitToolbar", {
toolbar: toolbar,
isReadOnly: isReadOnly
hooks.callAll("padInitToolbar", {
toolbar: toolbar,
isReadOnly: isReadOnly
});
res.send(eejs.require("ep_etherpad-lite/templates/pad.html", {
req: req,
toolbar: toolbar,
isReadOnly: isReadOnly
}));
});
res.send(eejs.require("ep_etherpad-lite/templates/pad.html", {
req: req,
toolbar: toolbar,
isReadOnly: isReadOnly
}));
});
//serve timeslider.html under /p/$padname/timeslider
args.app.get('/p/:pad/timeslider', function(req, res, next)
{
hooks.callAll("padInitToolbar", {
toolbar: toolbar
});
sendPadHeaderFiles(res, function(){
hooks.callAll("padInitToolbar", {
toolbar: toolbar
});
res.send(eejs.require("ep_etherpad-lite/templates/timeslider.html", {
req: req,
toolbar: toolbar
}));
res.send(eejs.require("ep_etherpad-lite/templates/timeslider.html", {
req: req,
toolbar: toolbar
}));
});
});
//serve favicon.ico from all path levels except as a pad name
@ -78,3 +85,63 @@ exports.expressCreateServer = function (hook_name, args, cb) {
}
/*
*
* Here we send the pad Header Files, this is used as "prefetch" which loads the browser up with
* The files it will need when visiting a pad. The idea is that this makes the users experience faster
* STILL TODO: Extend so plugins can patch into this or so the plugin framework can parse plugin files
* And inject them into this.
*
*/
function sendPadHeaderFiles(res, callback){
var plugins = hooks.plugins.plugins;
var pluginPaths = [];
// Go through each plugin and get the paths
Object.keys(plugins).forEach(function(key) {
if(key === "ep_etherpad-lite") return;
var plugin = plugins[key];
var client_hooks = plugin.parts[0].client_hooks;
if(client_hooks){
Object.keys(client_hooks).forEach(function(k){
var path = client_hooks[k];
path = path.split(":")[0];
pluginPaths.push(path);
});
}
});
// Now we need to uniquify the array so we only have unique paths
var uniquePaths = pluginPaths.filter(function(item, pos) {
return pluginPaths.indexOf(item) == pos;
})
// Next to join the array into a string so we can add it to the link value
var uniquePluginString = "";
for (var i = 0; i < uniquePaths.length; i++) {
uniquePluginString += "</javascripts/lib/"+uniquePaths[i]+".js>; rel=prefetch\, ";
}
// console.log("unique plugin string...", uniquePluginString)
res.set('Link', uniquePluginString + " <static/js/require-kernel.js>; rel=prefetch\, \
<javascripts/lib/ep_etherpad-lite/static/js/pad.js?callback=require.define>; rel=prefetch\, \
<javascripts/lib/ep_etherpad-lite/static/js/ace2_common.js?callback=require.define>; rel=prefetch\, \
<javascripts/lib/ep_etherpad-lite/static/js/ace2_inner.js?callback=require.define>; rel=prefetch\, \
<javascripts/lib/ep_etherpad-lite/static/js/colorutils.js?callback=require.define>; rel=prefetch\, \
<javascripts/lib/ep_etherpad-lite/static/js/hooks.js?callback=require.define>; rel=prefetch\, \
<javascripts/lib/unorm/lib/unorm.js?callback=require.define>; rel=prefetch\, \
<static/custom/pad.js>; rel=prefetch\, \
<socket.io/socket.io.js>; rel=prefetch\, \
<static/js/html10n.js>; rel=prefetch\, \
<static/js/l10n.js>; rel=prefetch\, \
<static/css/pad.css>; rel=prefetch\, \
<static/custom/pad.css>; rel=prefetch\, \
<static/css/iframe_editor.css>; rel=prefetch\, \
<pluginfw/plugin-definitions.json>; rel=prefetch\, \
<locales.json>; rel=prefetch\, \
<static/font/fontawesome-etherpad.woff>; rel=prefetch");
callback();
}

View File

@ -3,6 +3,7 @@
"pad.js"
, "pad_utils.js"
, "browser.js"
, "colorutils.js"
, "pad_cookie.js"
, "pad_editor.js"
, "pad_editbar.js"

View File

@ -32,8 +32,8 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<link rel="shortcut icon" href="<%=settings.favicon%>">
<link rel="localizations" type="application/l10n+json" href="locales.json">
<script type="text/javascript" src="static/js/html10n.js"></script>
<script type="text/javascript" src="static/js/l10n.js"></script>