diff --git a/app.js b/app.js index e09b9da4fd..75586a2e59 100644 --- a/app.js +++ b/app.js @@ -13,7 +13,7 @@ global.templates = {}; config['ROOT_DIRECTORY'] = __dirname; templates.init([ - 'header', 'footer', 'logout', + 'header', 'footer', 'logout', 'admin/header', 'admin/footer', 'admin/index', 'emails/reset', 'emails/reset_plaintext', 'emails/email_confirm', 'emails/email_confirm_plaintext' ]); diff --git a/public/src/templates.js b/public/src/templates.js index 0929f65c92..9c88fc271f 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -31,7 +31,7 @@ } templates.is_available = function(tpl) { - return !!jQuery.inArray(tpl, available_templates); + return jQuery.inArray(tpl, available_templates) !== -1; }; templates.ready = function(callback) { @@ -99,15 +99,17 @@ var api_url = (url === '' || url === '/') ? 'home' : url; - var tpl_url = templates.get_custom_map(api_url); - if (tpl_url === false) { - if (!available_templates[api_url]) { - tpl_url = api_url.split('/')[0]; - } else { - tpl_url = api_url; + var trimmed = api_url; + while (tpl_url == false && trimmed.length > 0) { + if (templates.is_available(trimmed)) { + tpl_url = trimmed; } + + trimmed = trimmed.split('/'); + trimmed.pop(); + trimmed = trimmed.join('/'); } diff --git a/public/templates/config.json b/public/templates/config.json index 33cad7eda6..5aad178dd5 100644 --- a/public/templates/config.json +++ b/public/templates/config.json @@ -5,7 +5,7 @@ "admin/users[^]*": "admin/users", "users[^]*edit": "accountedit", "users[^]*friends": "friends", - "users": "account", + "users/[^]*": "account", "latest": "category", "popular": "category", "active": "category" diff --git a/src/routes/admin.js b/src/routes/admin.js index 7528e76452..1aa72d66b0 100644 --- a/src/routes/admin.js +++ b/src/routes/admin.js @@ -1,7 +1,8 @@ var user = require('./../user.js'), topics = require('./../topics.js'), - RDB = require('./../redis.js'); + RDB = require('./../redis.js') + categories = require('./../categories.js'); (function(Admin) { Admin.create_routes = function(app) { @@ -12,7 +13,6 @@ var user = require('./../user.js'), for (var i=0, ii=routes.length; i