extend pad files so they are prefetched on each page

This commit is contained in:
John McLear 2015-06-21 11:08:10 +01:00
parent 1118cc56eb
commit 99cc915d91

View file

@ -35,6 +35,7 @@ exports.expressCreateServer = function (hook_name, args, cb) {
//serve pad.html under /p
args.app.get('/p/:pad', function(req, res, next)
{
sendPadHeaderFiles(res, function(){
// The below might break for pads being rewritten
var isReadOnly = req.url.indexOf("/p/r.") === 0;
@ -49,10 +50,12 @@ exports.expressCreateServer = function (hook_name, args, cb) {
isReadOnly: isReadOnly
}));
});
});
//serve timeslider.html under /p/$padname/timeslider
args.app.get('/p/:pad/timeslider', function(req, res, next)
{
sendPadHeaderFiles(res, function(){
hooks.callAll("padInitToolbar", {
toolbar: toolbar
});
@ -62,6 +65,7 @@ exports.expressCreateServer = function (hook_name, args, cb) {
toolbar: toolbar
}));
});
});
//serve favicon.ico from all path levels except as a pad name
args.app.get( /\/favicon.ico$/, function(req, res)
@ -81,6 +85,15 @@ 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){
res.set('Link', '<static/js/require-kernel.js>; rel=prefetch \, \
<javascripts/lib/ep_etherpad-lite/static/js/pad.js?callback=require.define>; rel=prefetch \, \