diff --git a/public/src/client/home.js b/public/src/client/categories.js similarity index 70% rename from public/src/client/home.js rename to public/src/client/categories.js index 9b1a1862cb..6840f69e89 100644 --- a/public/src/client/home.js +++ b/public/src/client/categories.js @@ -2,35 +2,34 @@ /* globals define, socket, app, templates, translator, ajaxify*/ -define('forum/home', function() { - var home = {}; +define('forum/categories', function() { + var categories = {}; $(window).on('action:ajaxify.start', function(ev, data) { - if (data.tpl_url !== 'home') { - socket.removeListener('event:new_post', home.onNewPost); + if (data.tpl_url !== 'categories') { + socket.removeListener('event:new_post', categories.onNewPost); } }); + categories.init = function() { + app.enterRoom('categories'); - home.init = function() { - app.enterRoom('home'); + socket.removeListener('event:new_post', categories.onNewPost); + socket.on('event:new_post', categories.onNewPost); - socket.removeListener('event:new_post', home.onNewPost); - socket.on('event:new_post', home.onNewPost); - - $('.home .category-header').tooltip({ + $('.category-header').tooltip({ placement: 'bottom' }); }; - home.onNewPost = function(data) { + categories.onNewPost = function(data) { if (data && data.posts && data.posts.length && data.posts[0].topic) { renderNewPost(data.posts[0].topic.cid, data.posts[0]); } }; function renderNewPost(cid, post) { - var category = $('.home .category-item[data-cid="' + cid + '"]'); + var category = $('.category-item[data-cid="' + cid + '"]'); if (!category.length) { return; } @@ -64,7 +63,7 @@ define('forum/home', function() { } function parseAndTranslate(posts, callback) { - templates.parse('home', 'posts', {categories: {posts: posts}}, function(html) { + templates.parse('categories', 'posts', {categories: {posts: posts}}, function(html) { translator.translate(html, function(translatedHTML) { translatedHTML = $(translatedHTML); translatedHTML.find('img').addClass('img-responsive'); @@ -74,5 +73,5 @@ define('forum/home', function() { }); } - return home; + return categories; }); diff --git a/src/controllers/categories.js b/src/controllers/categories.js index 9ef288272c..187653268d 100644 --- a/src/controllers/categories.js +++ b/src/controllers/categories.js @@ -154,8 +154,8 @@ categoriesController.list = function(req, res, next) { if (err) { return next(err); } - // TODO: template should be called categories.tpl - res.render('home', data); + + res.render('categories', data); }); }; diff --git a/src/controllers/index.js b/src/controllers/index.js index 805ba52d20..c8511c7c61 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -30,13 +30,15 @@ var Controllers = { Controllers.home = function(req, res, next) { - var route = meta.config.homePageRoute || 'home'; - if (route === 'home') { + var route = meta.config.homePageRoute || 'categories'; + if (route === 'categories') { return Controllers.categories.list(req, res, next); } else if (route === 'recent') { Controllers.categories.recent(req, res, next); } else if (route === 'popular') { Controllers.categories.popular(req, res, next); + } else { + next(); } }; diff --git a/src/controllers/templates.js b/src/controllers/templates.js index 0d686a1455..7cbe6728e9 100644 --- a/src/controllers/templates.js +++ b/src/controllers/templates.js @@ -24,7 +24,8 @@ templatesController.getTemplatesListing = function(req, res, next) { readConfigFile(next); }, function(config, next) { - config.custom_mapping['^/?$'] = meta.config.homePageRoute || 'home'; + console.log(meta.config.homePageRoute); + config.custom_mapping['^/?$'] = meta.config.homePageRoute || 'categories'; plugins.fireHook('filter:templates.get_config', config, next); } diff --git a/src/views/admin/settings/general.tpl b/src/views/admin/settings/general.tpl index 66a27dee61..b403835994 100644 --- a/src/views/admin/settings/general.tpl +++ b/src/views/admin/settings/general.tpl @@ -34,7 +34,7 @@