From 977bc014f9770b5794e2dda1b27877e77bd1154c Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 24 Sep 2014 15:11:48 -0400 Subject: [PATCH] index acp files --- src/meta/templates.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/meta/templates.js b/src/meta/templates.js index 920d60e6bd..761ce809ac 100644 --- a/src/meta/templates.js +++ b/src/meta/templates.js @@ -93,21 +93,37 @@ Templates.compile = function(callback) { } } + if (relativePath.match(/^\/admin\/[\s\S]*?/)) { + addIndex(relativePath, file); + } + mkdirp.sync(path.join(viewsPath, relativePath.split('/').slice(0, -1).join('/'))); fs.writeFile(path.join(viewsPath, relativePath), file, next); }, function(err) { if (err) { winston.error('[themes] ' + err.stack); } else { - winston.info('[themes] Successfully compiled templates.'); - emitter.emit('templates:compiled'); - if (callback) { - callback(); - } + compileIndex(viewsPath, function() { + winston.info('[themes] Successfully compiled templates.'); + emitter.emit('templates:compiled'); + if (callback) { + callback(); + } + }); } }); }); }); }; +var searchIndex = {}; + +function addIndex(path, file) { + searchIndex[path] = file; +} + +function compileIndex(viewsPath, callback) { + fs.writeFile(path.join(viewsPath, '/indexed.json'), JSON.stringify(searchIndex), callback); +} + module.exports = Templates; \ No newline at end of file