From 0ac64400c89d61c2c79f41c42c7506d27a81f273 Mon Sep 17 00:00:00 2001 From: Egil Moeller Date: Sat, 13 Mar 2010 00:04:13 +0100 Subject: Added static file serving for plugins --- trunk/etherpad/src/etherpad/control/static_control.js | 15 +++++++++++++-- trunk/etherpad/src/plugins/testplugin/static/js/test.js | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 trunk/etherpad/src/plugins/testplugin/static/js/test.js diff --git a/trunk/etherpad/src/etherpad/control/static_control.js b/trunk/etherpad/src/etherpad/control/static_control.js index 5c087b6..ba509d8 100644 --- a/trunk/etherpad/src/etherpad/control/static_control.js +++ b/trunk/etherpad/src/etherpad/control/static_control.js @@ -19,12 +19,25 @@ import("dispatch.{Dispatcher,PrefixMatcher,forward}"); import("etherpad.utils.*"); import("etherpad.globals.*"); +import("etherpad.admin.plugins"); function onRequest() { var staticBase = '/static'; var opts = {cache: isProduction()}; + var disp = new Dispatcher(); + + /* FIXME: Is there a more effective way to do this? */ + for (plugin in plugins.plugins) { + disp.addLocations([ + [PrefixMatcher('/static/js/'+plugin+'/'), faststatic.directoryServer('/plugins/' + plugin + '/static/js/', opts)], + [PrefixMatcher('/static/css/'+plugin+'/'), faststatic.directoryServer('/plugins/' + plugin + '/static/css/', opts)], + [PrefixMatcher('/static/swf/'+plugin+'/'), faststatic.directoryServer('/plugins/' + plugin + '/static/swf/', opts)], + [PrefixMatcher('/static/html/'+plugin+'/'), faststatic.directoryServer('/plugins/' + plugin + '/static/html/', opts)], + [PrefixMatcher('/static/zip/'+plugin+'/'), faststatic.directoryServer('/plugins/' + plugin + '/static/zip/', opts)]]); + } + var serveFavicon = faststatic.singleFileServer(staticBase + '/favicon.ico', opts); var serveCrossDomain = faststatic.singleFileServer(staticBase + '/crossdomain.xml', opts); var serveStaticDir = faststatic.directoryServer(staticBase, opts); @@ -35,8 +48,6 @@ function onRequest() { var serveHtml = faststatic.directoryServer(staticBase+'/html/', opts); var serveZip = faststatic.directoryServer(staticBase+'/zip/', opts); - var disp = new Dispatcher(); - disp.addLocations([ ['/favicon.ico', serveFavicon], ['/robots.txt', serveRobotsTxt], diff --git a/trunk/etherpad/src/plugins/testplugin/static/js/test.js b/trunk/etherpad/src/plugins/testplugin/static/js/test.js new file mode 100644 index 0000000..2899720 --- /dev/null +++ b/trunk/etherpad/src/plugins/testplugin/static/js/test.js @@ -0,0 +1 @@ +kafoo -- cgit v1.2.3-1-g7c22