aboutsummaryrefslogtreecommitdiffstats
path: root/etherpad
diff options
context:
space:
mode:
authorEgil Moeller <egil.moller@freecode.no>2010-04-10 02:36:17 +0200
committerEgil Moeller <egil.moller@freecode.no>2010-04-10 02:36:17 +0200
commit0043a41b5465f19ca8ecaae6b85b92ea089c3535 (patch)
tree4f96284f3bf73959d419a1de07454bd073f779f9 /etherpad
parent8fb886cc2df636fd42cb075254f986c500e3e50f (diff)
downloadetherpad-0043a41b5465f19ca8ecaae6b85b92ea089c3535.tar.gz
etherpad-0043a41b5465f19ca8ecaae6b85b92ea089c3535.tar.xz
etherpad-0043a41b5465f19ca8ecaae6b85b92ea089c3535.zip
Template fallback from plugin to /templates
Diffstat (limited to 'etherpad')
-rw-r--r--etherpad/src/etherpad/utils.js19
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) {