mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-24 00:09:41 +01:00
Merge branch 'master' of github.com:designcreateplay/NodeBB
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}());
|
||||
@@ -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, '<span class="label label-success">'+searchQuery+'</span>');
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
<option value="category-orange">category-orange</option>
|
||||
</select>
|
||||
<input data-name="description" placeholder="Category Description" value="{categories.description}" class="category_description input-medium description"></input>
|
||||
<button type="submit" class="btn" data-disabled="{categories.disabled}">Disable</button>
|
||||
</form>
|
||||
</li>
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
<ul class="nav nav-list">
|
||||
<li class="nav-header">NodeBB</li>
|
||||
<li class='active'><a href='{relative_path}/admin/index'><i class='icon-home'></i> Home</a></li>
|
||||
<li class=''><a href='{relative_path}/admin/categories'><i class='icon-folder-close-alt'></i> Categories</a></li>
|
||||
<li class=''><a href='{relative_path}/admin/categories/active'><i class='icon-folder-close-alt'></i> Categories</a></li>
|
||||
<li class=''><a href='{relative_path}/admin/users/latest'><i class='icon-user'></i> Users</a></li>
|
||||
<li class=''><a href='{relative_path}/admin/topics'><i class='icon-book'></i> Topics</a></li>
|
||||
<li class=''><a href='{relative_path}/admin/themes'><i class='icon-th'></i> Themes</a></li>
|
||||
|
||||
@@ -13,6 +13,21 @@
|
||||
<div class="category row">
|
||||
<div class="span12">
|
||||
<ul id="topics-container" data-search-query="{search_query}">
|
||||
<!-- BEGIN topics -->
|
||||
<a href="../../topic/{topics.slug}" id="tid-{topics.tid}">
|
||||
<li class="category-item">
|
||||
<div class="row-fluid">
|
||||
<div class="span12 img-polaroid">
|
||||
<div class="search-result-post">
|
||||
<img src="{topics.teaser_userpicture}" />
|
||||
<strong>{topics.teaser_username}</strong>: <span class="search-result-text">{topics.title}</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</a>
|
||||
<!-- END topics -->
|
||||
<!-- BEGIN posts -->
|
||||
<a href="../../topic/{posts.topicSlug}#{posts.pid}" id="tid-{posts.tid}">
|
||||
<li class="category-item">
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user