mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
small refactor plus breadcrumbs for all ur pages
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
<div class="container">
|
||||||
|
<ul class="breadcrumb">
|
||||||
|
<li><a href="/">Home</a><span class="divider">/</span></li>
|
||||||
|
<li class="active">{category_name}</li>
|
||||||
|
<div id="category_active_users"></div>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
<button id="new_post" class="btn btn-primary btn-large {show_topic_button}">New Topic</button>
|
<button id="new_post" class="btn btn-primary btn-large {show_topic_button}">New Topic</button>
|
||||||
<ul class="topic-container">
|
<ul class="topic-container">
|
||||||
<!-- BEGIN topics -->
|
<!-- BEGIN topics -->
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<ul class="breadcrumb">
|
<ul class="breadcrumb">
|
||||||
<li><a href="/">Home</a><span class="divider">/</span></li>
|
<li><a href="/">Home</a><span class="divider">/</span></li>
|
||||||
|
<li><a href="/category/{category_slug}">{category_name}</a><span class="divider">/</span></li>
|
||||||
<li class="active">{topic_name}</li>
|
<li class="active">{topic_name}</li>
|
||||||
<div id="thread_active_users"></div>
|
<div id="thread_active_users"></div>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -25,10 +25,17 @@ var RDB = require('./redis.js'),
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Categories.edit = function(data, callback) {
|
||||||
|
// just a reminder to self that name + slugs are stored into topics data as well.
|
||||||
|
};
|
||||||
|
|
||||||
Categories.get = function(callback) {
|
Categories.get = function(callback) {
|
||||||
RDB.lrange('categories:cid', 0, -1, function(cids) {
|
RDB.lrange('categories:cid', 0, -1, function(cids) {
|
||||||
|
Categories.get_category(cids, callback);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Categories.get_category = function(cids, callback) {
|
||||||
var name = [],
|
var name = [],
|
||||||
description = [],
|
description = [],
|
||||||
icon = [],
|
icon = [],
|
||||||
@@ -78,7 +85,6 @@ var RDB = require('./redis.js'),
|
|||||||
callback({'categories': categories});
|
callback({'categories': categories});
|
||||||
});
|
});
|
||||||
} else callback({'categories' : []});
|
} else callback({'categories' : []});
|
||||||
});
|
};
|
||||||
}
|
|
||||||
|
|
||||||
}(exports));
|
}(exports));
|
||||||
14
src/posts.js
14
src/posts.js
@@ -33,12 +33,14 @@ var RDB = require('./redis.js'),
|
|||||||
'user_rep' : user_data[uid].reputation || 0,
|
'user_rep' : user_data[uid].reputation || 0,
|
||||||
'gravatar' : user_data[uid].picture,
|
'gravatar' : user_data[uid].picture,
|
||||||
'fav_star_class' : vote_data[pid] ? 'icon-star' : 'icon-star-empty',
|
'fav_star_class' : vote_data[pid] ? 'icon-star' : 'icon-star-empty',
|
||||||
'display_moderator_tools' : uid === current_user ? 'show' : 'hide'
|
'display_moderator_tools' : uid == current_user ? 'show' : 'hide'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
callback({
|
callback({
|
||||||
'topic_name':thread_data.topic_name,
|
'topic_name':thread_data.topic_name,
|
||||||
|
'category_name':thread_data.category_name,
|
||||||
|
'category_slug':thread_data.category_slug,
|
||||||
'locked': parseInt(thread_data.locked) || 0,
|
'locked': parseInt(thread_data.locked) || 0,
|
||||||
'topic_id': tid,
|
'topic_id': tid,
|
||||||
'posts': posts
|
'posts': posts
|
||||||
@@ -58,10 +60,6 @@ var RDB = require('./redis.js'),
|
|||||||
pid.push(pids[i]);
|
pid.push(pids[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
RDB.get('tid:' + tid + ':title', function(topic_name) {
|
|
||||||
thread_data = {topic_name: topic_name};
|
|
||||||
generateThread();
|
|
||||||
});
|
|
||||||
|
|
||||||
Posts.getFavouritesByPostIDs(pids, current_user, function(fav_data) {
|
Posts.getFavouritesByPostIDs(pids, current_user, function(fav_data) {
|
||||||
vote_data = fav_data;
|
vote_data = fav_data;
|
||||||
@@ -76,6 +74,8 @@ var RDB = require('./redis.js'),
|
|||||||
.mget(post_rep)
|
.mget(post_rep)
|
||||||
.get('tid:' + tid + ':title')
|
.get('tid:' + tid + ':title')
|
||||||
.get('tid:' + tid + ':locked')
|
.get('tid:' + tid + ':locked')
|
||||||
|
.get('tid:' + tid + ':category_name')
|
||||||
|
.get('tid:' + tid + ':category_slug')
|
||||||
.exec(function(err, replies) {
|
.exec(function(err, replies) {
|
||||||
post_data = {
|
post_data = {
|
||||||
pid: pids,
|
pid: pids,
|
||||||
@@ -87,7 +87,9 @@ var RDB = require('./redis.js'),
|
|||||||
|
|
||||||
thread_data = {
|
thread_data = {
|
||||||
topic_name: replies[4],
|
topic_name: replies[4],
|
||||||
locked: replies[5]
|
locked: replies[5],
|
||||||
|
category_name: replies[6],
|
||||||
|
category_slug: replies[7]
|
||||||
};
|
};
|
||||||
|
|
||||||
user.getMultipleUserFields(post_data.uid, ['username','reputation','picture'], function(user_details){
|
user.getMultipleUserFields(post_data.uid, ['username','reputation','picture'], function(user_details){
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
var RDB = require('./redis.js'),
|
var RDB = require('./redis.js'),
|
||||||
posts = require('./posts.js'),
|
posts = require('./posts.js'),
|
||||||
utils = require('./utils.js'),
|
utils = require('./utils.js'),
|
||||||
user = require('./user.js');
|
user = require('./user.js')
|
||||||
|
categories = require('./categories.js');
|
||||||
|
|
||||||
(function(Topics) {
|
(function(Topics) {
|
||||||
|
|
||||||
@@ -33,25 +34,34 @@ var RDB = require('./redis.js'),
|
|||||||
postcount.push('tid:' + tids[i] + ':postcount');
|
postcount.push('tid:' + tids[i] + ':postcount');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var multi = RDB.multi()
|
||||||
|
.get('cid:' + category_id + ':name');
|
||||||
|
|
||||||
if (tids.length > 0) {
|
if (tids.length > 0) {
|
||||||
RDB.multi()
|
multi
|
||||||
.mget(title)
|
.mget(title)
|
||||||
.mget(uid)
|
.mget(uid)
|
||||||
.mget(timestamp)
|
.mget(timestamp)
|
||||||
.mget(slug)
|
.mget(slug)
|
||||||
.mget(postcount)
|
.mget(postcount)
|
||||||
.exec(function(err, replies) {
|
}
|
||||||
|
|
||||||
|
|
||||||
|
multi.exec(function(err, replies) {
|
||||||
|
category_name = replies[0];
|
||||||
|
var topics = [];
|
||||||
|
|
||||||
|
if (tids.length > 0) {
|
||||||
|
title = replies[1];
|
||||||
|
uid = replies[2];
|
||||||
|
timestamp = replies[3];
|
||||||
|
slug = replies[4];
|
||||||
|
postcount = replies[5];
|
||||||
|
|
||||||
title = replies[0];
|
|
||||||
uid = replies[1];
|
|
||||||
timestamp = replies[2];
|
|
||||||
slug = replies[3];
|
|
||||||
postcount = replies[4];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
user.get_usernames_by_uids(uid, function(userNames) {
|
user.get_usernames_by_uids(uid, function(userNames) {
|
||||||
var topics = [];
|
|
||||||
|
|
||||||
for (var i=0, ii=title.length; i<ii; i++) {
|
for (var i=0, ii=title.length; i<ii; i++) {
|
||||||
|
|
||||||
@@ -67,20 +77,32 @@ var RDB = require('./redis.js'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
callback({
|
callback({
|
||||||
|
'category_name' : category_id ? category_name : 'Recent',
|
||||||
'show_topic_button' : category_id ? 'show' : 'hidden',
|
'show_topic_button' : category_id ? 'show' : 'hidden',
|
||||||
'category_id': category_id,
|
'category_id': category_id,
|
||||||
'topics': topics
|
'topics': topics
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
else {
|
||||||
} else callback({'category_id': category_id, 'topics': []});
|
callback({
|
||||||
|
'category_name' : category_id ? category_name : 'Recent',
|
||||||
|
'show_topic_button' : category_id ? 'show' : 'hidden',
|
||||||
|
'category_id': category_id,
|
||||||
|
'topics': []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
//} else callback({'category_id': category_id, 'topics': []});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Topics.post = function(socket, uid, title, content, category_id) {
|
Topics.post = function(socket, uid, title, content, category_id) {
|
||||||
|
if (!category_id) throw new Error('Attempted to post without a category_id');
|
||||||
|
|
||||||
if (uid === 0) {
|
if (uid === 0) {
|
||||||
socket.emit('event:alert', {
|
socket.emit('event:alert', {
|
||||||
@@ -138,6 +160,14 @@ var RDB = require('./redis.js'),
|
|||||||
type: 'notify',
|
type: 'notify',
|
||||||
timeout: 2000
|
timeout: 2000
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// in future it may be possible to add topics to several categories, so leaving the door open here.
|
||||||
|
categories.get_category([category_id], function(data) {
|
||||||
|
RDB.set('tid:' + tid + ':category_name', data.categories[0].name);
|
||||||
|
RDB.set('tid:' + tid + ':category_slug', data.categories[0].slug);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user