diff options
author | Egil Moeller <egil.moller@freecode.no> | 2010-04-10 02:36:17 +0200 |
---|---|---|
committer | Egil Moeller <egil.moller@freecode.no> | 2010-04-10 02:36:17 +0200 |
commit | 0043a41b5465f19ca8ecaae6b85b92ea089c3535 (patch) | |
tree | 4f96284f3bf73959d419a1de07454bd073f779f9 | |
parent | 8fb886cc2df636fd42cb075254f986c500e3e50f (diff) | |
download | etherpad-0043a41b5465f19ca8ecaae6b85b92ea089c3535.tar.gz etherpad-0043a41b5465f19ca8ecaae6b85b92ea089c3535.tar.xz etherpad-0043a41b5465f19ca8ecaae6b85b92ea089c3535.zip |
Template fallback from plugin to /templates
-rw-r--r-- | etherpad/src/etherpad/utils.js | 19 |
1 files changed, 16 insertions, 3 deletions
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) { |