From 0043a41b5465f19ca8ecaae6b85b92ea089c3535 Mon Sep 17 00:00:00 2001 From: Egil Moeller Date: Sat, 10 Apr 2010 02:36:17 +0200 Subject: Template fallback from plugin to /templates --- etherpad/src/etherpad/utils.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'etherpad') diff --git a/etherpad/src/etherpad/utils.js b/etherpad/src/etherpad/utils.js index 57ca5de..734aaf5 100644 --- a/etherpad/src/etherpad/utils.js +++ b/etherpad/src/etherpad/utils.js @@ -40,6 +40,8 @@ import("etherpad.admin.plugins"); jimport("java.lang.System.out.print"); jimport("java.lang.System.out.println"); +jimport("java.io.File"); + //---------------------------------------------------------------- // utilities //---------------------------------------------------------------- @@ -57,11 +59,22 @@ function randomUniquePadId() { // template rendering //---------------------------------------------------------------- +function findExistsingFile(files) { + for (var i = 0; i < files.length; i++) { + var f = new File('./src' + files[i]); + if (f.exists()) + return files[i]; + } +} + function findTemplate(filename, plugin) { + var files = []; + if (plugin != undefined) - return '/plugins/' + plugin + '/templates/' + filename; - else - return '/templates/' + filename; + files.push('/plugins/' + plugin + '/templates/' + filename); + files.push('/templates/' + filename); + + return findExistsingFile(files); } function Template(params, plugin) { -- cgit v1.2.3-1-g7c22