diff --git a/public/css/admin.less b/public/css/admin.less
index cd322ba809..c56eeb74ce 100644
--- a/public/css/admin.less
+++ b/public/css/admin.less
@@ -6,15 +6,6 @@
margin-bottom: 10px;
padding: 10px;
cursor: move;
- width: 800px;
- }
-
- .entry-row {
- border-radius: 10px;
- margin-bottom: 10px;
- padding: 10px;
- cursor: move;
- width: 695px;
}
input.description {
diff --git a/public/src/forum/admin/categories.js b/public/src/forum/admin/categories.js
index f8e0ce65ab..b7f77c8dbb 100644
--- a/public/src/forum/admin/categories.js
+++ b/public/src/forum/admin/categories.js
@@ -74,6 +74,30 @@ jQuery('.blockclass').each(function() {
jQuery('.category_name, .category_description, .blockclass').on('change', function(ev) {
modified(ev.target);
});
+
+ jQuery('.entry-row button').each(function(index, element) {
+ var disabled = $(element).attr('data-disabled');
+ if(disabled == "0" || disabled == "")
+ $(element).html('Disable');
+ else
+ $(element).html('Enable');
+
+ });
+
+ jQuery('.entry-row button').on('click', function(ev) {
+ var btn = jQuery(this);
+ var categoryRow = btn.parents('li');
+ var cid = categoryRow.attr('data-cid');
+
+ var disabled = btn.html() == "Disable" ? "1":"0";
+ categoryRow.remove();
+ modified_categories[cid] = modified_categories[cid] || {};
+ modified_categories[cid]['disabled'] = disabled;
+
+ save();
+ return false;
+ });
+
});
}());
\ No newline at end of file
diff --git a/public/src/forum/search.js b/public/src/forum/search.js
index 9412915cc7..c21baec1e6 100644
--- a/public/src/forum/search.js
+++ b/public/src/forum/search.js
@@ -3,7 +3,7 @@
$(document).ready(function() {
var searchQuery = $('#topics-container').attr('data-search-query');
- $('.search-result-text').each(function(){
+ $('.search-result-text').each(function() {
var text = $(this).html();
var regex = new RegExp(searchQuery, 'gi');
text = text.replace(regex, ''+searchQuery+'');
diff --git a/public/templates/admin/categories.tpl b/public/templates/admin/categories.tpl
index fac56816a2..06366a5bb3 100644
--- a/public/templates/admin/categories.tpl
+++ b/public/templates/admin/categories.tpl
@@ -27,6 +27,7 @@
+
diff --git a/public/templates/admin/header.tpl b/public/templates/admin/header.tpl
index b6b4b7c299..381cde4a25 100644
--- a/public/templates/admin/header.tpl
+++ b/public/templates/admin/header.tpl
@@ -70,7 +70,7 @@
- Home
- - Categories
+ - Categories
- Users
- Topics
- Themes
diff --git a/public/templates/search.tpl b/public/templates/search.tpl
index c08f82e7c5..7dec88da87 100644
--- a/public/templates/search.tpl
+++ b/public/templates/search.tpl
@@ -13,6 +13,21 @@
+
+
+ -
+
+
+
+

+
{topics.teaser_username}:
{topics.title}
+
+
+
+
+
+
+
-
diff --git a/src/admin/categories.js b/src/admin/categories.js
index 21d13aacac..c48fdc1a41 100644
--- a/src/admin/categories.js
+++ b/src/admin/categories.js
@@ -18,7 +18,8 @@ var RDB = require('./../redis.js'),
icon: data.icon,
blockclass: data.blockclass,
slug: slug,
- topic_count: 0
+ topic_count: 0,
+ disabled: 0
});
RDB.set('categoryslug:' + slug + ':cid', cid);
diff --git a/src/postTools.js b/src/postTools.js
index 0f826ec995..9d4418607f 100644
--- a/src/postTools.js
+++ b/src/postTools.js
@@ -8,7 +8,8 @@ var RDB = require('./redis.js'),
utils = require('../public/src/utils'),
plugins = require('./plugins'),
reds = require('reds'),
- search = reds.createSearch('nodebbsearch');
+ postSearch = reds.createSearch('nodebbpostsearch'),
+ topicSearch = reds.createSearch('nodebbtopicsearch');
(function(PostTools) {
PostTools.isMain = function(pid, tid, callback) {
@@ -58,14 +59,18 @@ var RDB = require('./redis.js'),
posts.setPostField(pid, 'edited', Date.now());
posts.setPostField(pid, 'editor', uid);
- search.remove(pid, function() {
- search.index(content, pid);
+ postSearch.remove(pid, function() {
+ postSearch.index(content, pid);
});
posts.getPostField(pid, 'tid', function(tid) {
PostTools.isMain(pid, tid, function(isMainPost) {
- if (isMainPost)
+ if (isMainPost) {
topics.setTopicField(tid, 'title', title);
+ topicSearch.remove(tid, function() {
+ topicSearch.index(title, tid);
+ });
+ }
io.sockets.in('topic_' + tid).emit('event:post_edited', {
pid: pid,
@@ -90,7 +95,7 @@ var RDB = require('./redis.js'),
var success = function() {
posts.setPostField(pid, 'deleted', 1);
- search.remove(pid);
+ postSearch.remove(pid);
posts.getPostFields(pid, ['tid', 'uid'], function(postData) {
@@ -140,7 +145,7 @@ var RDB = require('./redis.js'),
});
});
- search.index(postData.content, pid);
+ postSearch.index(postData.content, pid);
});
};
diff --git a/src/posts.js b/src/posts.js
index 8219a39363..583ab16236 100644
--- a/src/posts.js
+++ b/src/posts.js
@@ -10,7 +10,7 @@ var RDB = require('./redis.js'),
async = require('async'),
plugins = require('./plugins'),
reds = require('reds'),
- search = reds.createSearch('nodebbsearch');
+ postSearch = reds.createSearch('nodebbpostsearch');
(function(Posts) {
@@ -337,7 +337,7 @@ var RDB = require('./redis.js'),
plugins.fireHook('action:save_post_content', [pid, content]);
- search.index(content, pid);
+ postSearch.index(content, pid);
});
});
} else {
@@ -417,10 +417,10 @@ var RDB = require('./redis.js'),
function reIndex(pid, callback) {
Posts.getPostField(pid, 'content', function(content) {
- search.remove(pid, function() {
+ postSearch.remove(pid, function() {
if(content && content.length) {
- search.index(content, pid);
+ postSearch.index(content, pid);
}
callback(null);
});
diff --git a/src/routes/admin.js b/src/routes/admin.js
index da9e92af71..75afd05c66 100644
--- a/src/routes/admin.js
+++ b/src/routes/admin.js
@@ -25,7 +25,7 @@ var user = require('./../user.js'),
(function() {
var routes = [
- 'categories', 'users', 'topics', 'settings', 'themes',
+ 'categories/active', 'categories/disabled', 'users', 'topics', 'settings', 'themes',
'twitter', 'facebook', 'gplus', 'redis', 'motd',
'users/latest', 'users/sort-posts', 'users/sort-reputation',
'users/search', 'plugins'
@@ -106,8 +106,22 @@ var user = require('./../user.js'),
});
});
+ app.get('/api/admin/categories/active', function(req, res) {
+ categories.getAllCategories(function(data) {
+ data.categories = data.categories.filter(function(category) {
+ return (!category.disabled || category.disabled === "0");
+ });
+ res.json(data);
+ });
+ });
+
app.get('/api/admin/categories/disabled', function(req, res) {
- res.json({categories: []});
+ categories.getAllCategories(function(data) {
+ data.categories = data.categories.filter(function(category) {
+ return category.disabled === "1";
+ });
+ res.json(data);
+ });
});
app.get('/api/admin/topics', function(req, res) {
diff --git a/src/routes/api.js b/src/routes/api.js
index bb64ce1ba7..246265b1f9 100644
--- a/src/routes/api.js
+++ b/src/routes/api.js
@@ -17,7 +17,11 @@ var user = require('./../user.js'),
app.get('/api/home', function(req, res) {
var uid = (req.user) ? req.user.uid : 0;
categories.getAllCategories(function(data) {
-
+
+ data.categories = data.categories.filter(function(category) {
+ return (!category.disabled || category.disabled === "0");
+ });
+
function iterator(category, callback) {
categories.getRecentReplies(category.cid, 2, function(posts) {
category["posts"] = posts;
@@ -158,24 +162,48 @@ var user = require('./../user.js'),
app.get('/api/search/:term', function(req, res, next) {
var reds = require('reds');
- var search = reds.createSearch('nodebbsearch');
-
- search
- .query(query = req.params.term).type('or')
- .end(function(err, ids) {
- if (err)
- return next();
-
-
- posts.getPostSummaryByPids(ids, function(posts) {
- res.json(200, {
- show_no_results:ids.length?'hide':'show',
- search_query:req.params.term,
- posts:posts
- });
+ var postSearch = reds.createSearch('nodebbpostsearch');
+ var topicSearch = reds.createSearch('nodebbtopicsearch');
+
+ function search(searchObj, callback) {
+ searchObj
+ .query(query = req.params.term).type('or')
+ .end(callback);
+ }
+
+ function searchPosts(callback) {
+ search(postSearch, function(err, pids) {
+ if(err)
+ return callback(err, null);
+
+ posts.getPostSummaryByPids(pids, function(posts) {
+ callback(null, posts);
});
-
+ })
+ }
+
+ function searchTopics(callback) {
+ search(topicSearch, function(err, tids) {
+ if(err)
+ return callback(err, null);
+ console.log(tids);
+ topics.getTopicsByTids(tids, 0, function(topics) {
+ callback(null, topics);
+ }, 0);
});
+ }
+
+ async.parallel([searchPosts, searchTopics], function(err, results) {
+ if (err)
+ return next();
+ var noresults = !results[0].length && !results[1].length;
+ return res.json({
+ show_no_results: noresults?'show':'hide',
+ search_query:req.params.term,
+ posts:results[0],
+ topics:results[1]
+ });
+ });
});
app.get('/api/404', function(req, res) {
diff --git a/src/threadTools.js b/src/threadTools.js
index 6083741846..2d2068574a 100644
--- a/src/threadTools.js
+++ b/src/threadTools.js
@@ -4,7 +4,9 @@ var RDB = require('./redis.js'),
user = require('./user.js'),
async = require('async'),
notifications = require('./notifications.js'),
- posts = require('./posts');
+ posts = require('./posts'),
+ reds = require('reds'),
+ topicSearch = reds.createSearch('nodebbtopicsearch');
(function(ThreadTools) {
@@ -88,6 +90,8 @@ var RDB = require('./redis.js'),
topics.setTopicField(tid, 'deleted', 1);
ThreadTools.lock(tid, uid);
+ topicSearch.remove(tid);
+
io.sockets.in('topic_' + tid).emit('event:topic_deleted', {
tid: tid,
status: 'ok'
@@ -116,6 +120,10 @@ var RDB = require('./redis.js'),
tid: tid
});
}
+
+ topics.getTopicField(tid, 'title', function(title) {
+ topicSearch.index(title, tid);
+ });
}
});
}
diff --git a/src/topics.js b/src/topics.js
index bbbf812751..5e37392556 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -10,7 +10,9 @@ var RDB = require('./redis.js')
postTools = require('./postTools'),
async = require('async'),
feed = require('./feed.js'),
- favourites = require('./favourites.js');
+ favourites = require('./favourites.js'),
+ reds = require('reds'),
+ topicSearch = reds.createSearch('nodebbtopicsearch');
marked.setOptions({
breaks: true
@@ -574,7 +576,7 @@ marked.setOptions({
// Global Topics
if (uid == null) uid = 0;
if (uid !== null) {
- RDB.sadd('topics:tid', tid);
+ RDB.sadd('topics:tid', tid);
} else {
// need to add some unique key sent by client so we can update this with the real uid later
RDB.lpush(schema.topics().queued_tids, tid);
@@ -597,6 +599,7 @@ marked.setOptions({
'pinned': 0
});
+ topicSearch.index(title, tid);
RDB.set('topicslug:' + slug + ':tid', tid);
posts.create(uid, tid, content, images, function(postData) {