v1.18.x
Barış Soner Uşaklı 10 years ago
parent fe1f4f84ec
commit bd553eb05d

@ -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;
});

@ -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);
});
};

@ -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();
}
};

@ -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);
}

@ -34,7 +34,7 @@
<form>
<label>Home Page Route</label>
<select class="form-control" data-field="homePageRoute">
<option value="home">Categories</option>
<option value="categories">Categories</option>
<option value="recent">Recent</option>
<option value="popular">Popular</option>
</select>

@ -1,6 +1,6 @@
{
"custom_mapping": {
"^\/?$": "home",
"^\/?$": "categories",
"^admin?$": "admin/general/dashboard",
"^users/sort-posts": "users",
"^users/latest": "users",

Loading…
Cancel
Save