From 1758c3e3f2e3f42fe859c4bcd8091b420931b25d Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Sat, 7 Sep 2013 11:51:37 -0400 Subject: [PATCH] fix for admin templates --- public/src/templates.js | 1 + public/src/utils.js | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/src/templates.js b/public/src/templates.js index 5a1bde3378..19ac1e8c07 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -89,6 +89,7 @@ jQuery.when(jQuery.getJSON(RELATIVE_PATH + '/templates/config.json'), jQuery.getJSON(RELATIVE_PATH + '/api/get_templates_listing')).done(function(config_data, templates_data) { config = config_data[0]; available_templates = templates_data[0]; + console.log(config, available_templates); templates.ready(); }); diff --git a/public/src/utils.js b/public/src/utils.js index 0deda43610..8d42ab595d 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -18,7 +18,9 @@ //Adapted from http://stackoverflow.com/questions/5827612/node-js-fs-readdir-recursive-directory-search walk: function(dir, done) { var results = [], - templateExtract = /\/([\w\d\-_]+)\.tpl$/; + path = require('path'), + main_dir = path.join(__dirname, '..', 'templates'); + fs.readdir(dir, function(err, list) { if (err) return done(err); var pending = list.length; @@ -32,10 +34,7 @@ if (!--pending) done(null, results); }); } else { - var templateMatch = file.match(templateExtract); - - if (templateMatch) results.push(templateMatch[1]); - // results.push(file.replace(main_dir, '').replace('.tpl', '')); + results.push(file.replace(main_dir + '/', '').replace('.tpl', '')); if (!--pending) done(null, results); } });