mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-09 02:37:01 +02:00
Merge branch 'master' into notifications_page
This commit is contained in:
@@ -61,9 +61,20 @@ var RDB = require('./redis.js'),
|
||||
|
||||
PostTools.edit = function(uid, pid, title, content) {
|
||||
var success = function() {
|
||||
posts.setPostField(pid, 'content', content);
|
||||
posts.setPostField(pid, 'edited', Date.now());
|
||||
posts.setPostField(pid, 'editor', uid);
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
posts.setPostField(pid, 'edited', Date.now());
|
||||
next(null);
|
||||
},
|
||||
function(next) {
|
||||
posts.setPostField(pid, 'editor', uid);
|
||||
next(null);
|
||||
},
|
||||
function(next) {
|
||||
posts.setPostField(pid, 'content', content);
|
||||
next(null);
|
||||
}
|
||||
]);
|
||||
|
||||
postSearch.remove(pid, function() {
|
||||
postSearch.index(content, pid);
|
||||
|
||||
58
src/posts.js
58
src/posts.js
@@ -24,9 +24,16 @@ var RDB = require('./redis.js'),
|
||||
RDB.handle(err);
|
||||
|
||||
if (pids.length) {
|
||||
Posts.getPostsByPids(pids, function(err, posts) {
|
||||
callback(posts);
|
||||
});
|
||||
plugins.fireHook('filter:post.getTopic', pids, function(err, posts) {
|
||||
if (!err & 0 < posts.length) {
|
||||
Posts.getPostsByPids(pids, function(err, posts) {
|
||||
plugins.fireHook('action:post.gotTopic', posts);
|
||||
callback(posts);
|
||||
});
|
||||
} else {
|
||||
callback(posts);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
callback([]);
|
||||
}
|
||||
@@ -131,6 +138,7 @@ var RDB = require('./redis.js'),
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: this function is never called except from some debug route. clean up?
|
||||
Posts.getPostData = function(pid, callback) {
|
||||
RDB.hgetall('post:' + pid, function(err, data) {
|
||||
if (err === null) {
|
||||
@@ -146,7 +154,14 @@ var RDB = require('./redis.js'),
|
||||
Posts.getPostFields = function(pid, fields, callback) {
|
||||
RDB.hmgetObject('post:' + pid, fields, function(err, data) {
|
||||
if (err === null) {
|
||||
callback(data);
|
||||
// TODO: I think the plugins system needs an optional 'parameters' paramter so I don't have to do this:
|
||||
data = data || {};
|
||||
data.pid = pid;
|
||||
data.fields = fields;
|
||||
|
||||
plugins.fireHook('filter:post.getFields', data, function(err, data) {
|
||||
callback(data);
|
||||
});
|
||||
} else {
|
||||
console.log(err);
|
||||
}
|
||||
@@ -155,15 +170,28 @@ var RDB = require('./redis.js'),
|
||||
|
||||
Posts.getPostField = function(pid, field, callback) {
|
||||
RDB.hget('post:' + pid, field, function(err, data) {
|
||||
if (err === null)
|
||||
callback(data);
|
||||
else
|
||||
if (err === null) {
|
||||
// TODO: I think the plugins system needs an optional 'parameters' paramter so I don't have to do this:
|
||||
data = data || {};
|
||||
data.pid = pid;
|
||||
data.field = field;
|
||||
|
||||
plugins.fireHook('filter:post.getField', data, function(err, data) {
|
||||
callback(data);
|
||||
});
|
||||
} else {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Posts.setPostField = function(pid, field, value) {
|
||||
Posts.setPostField = function(pid, field, value, done) {
|
||||
RDB.hset('post:' + pid, field, value);
|
||||
plugins.fireHook('action:post.setField', {
|
||||
'pid': pid,
|
||||
'field': field,
|
||||
'value': value
|
||||
}, done);
|
||||
}
|
||||
|
||||
Posts.getPostsByPids = function(pids, callback) {
|
||||
@@ -400,13 +428,17 @@ var RDB = require('./redis.js'),
|
||||
}
|
||||
|
||||
Posts.getPostsByUid = function(uid, start, end, callback) {
|
||||
|
||||
user.getPostIds(uid, start, end, function(pids) {
|
||||
|
||||
if (pids && pids.length) {
|
||||
|
||||
Posts.getPostsByPids(pids, function(err, posts) {
|
||||
callback(posts);
|
||||
plugins.fireHook('filter:post.getTopic', pids, function(err, posts) {
|
||||
if (!err & 0 < posts.length) {
|
||||
Posts.getPostsByPids(pids, function(err, posts) {
|
||||
plugins.fireHook('action:post.gotTopic', posts);
|
||||
callback(posts);
|
||||
});
|
||||
} else {
|
||||
callback(posts);
|
||||
}
|
||||
});
|
||||
} else
|
||||
callback([]);
|
||||
|
||||
@@ -303,7 +303,7 @@ var RDB = require('./redis.js'),
|
||||
|
||||
pids.reverse();
|
||||
async.detectSeries(pids, function(pid, next) {
|
||||
RDB.hget('post:' + pid, 'deleted', function(err, deleted) {
|
||||
posts.getPostField(pid, 'deleted', function(deleted) {
|
||||
if (deleted === '0') next(true);
|
||||
else next(false);
|
||||
});
|
||||
|
||||
@@ -53,30 +53,34 @@ var express = require('express'),
|
||||
|
||||
plugins.fireHook('filter:header.build', custom_header, function(err, custom_header) {
|
||||
var defaultMetaTags = [{
|
||||
name: 'viewport',
|
||||
content: 'width=device-width, initial-scale=1.0, user-scalable=no'
|
||||
}, {
|
||||
name: 'content-type',
|
||||
content: 'text/html; charset=UTF-8'
|
||||
}, {
|
||||
name: 'apple-mobile-web-app-capable',
|
||||
content: 'yes'
|
||||
}, {
|
||||
property: 'og:site_name',
|
||||
content: meta.config.title || 'NodeBB'
|
||||
}, {
|
||||
property: 'keywords',
|
||||
content: meta.config['keywords'] || ''
|
||||
}],
|
||||
name: 'viewport',
|
||||
content: 'width=device-width, initial-scale=1.0, user-scalable=no'
|
||||
}, {
|
||||
name: 'content-type',
|
||||
content: 'text/html; charset=UTF-8'
|
||||
}, {
|
||||
name: 'apple-mobile-web-app-capable',
|
||||
content: 'yes'
|
||||
}, {
|
||||
property: 'og:site_name',
|
||||
content: meta.config.title || 'NodeBB'
|
||||
}, {
|
||||
property: 'keywords',
|
||||
content: meta.config['keywords'] || ''
|
||||
}],
|
||||
metaString = utils.buildMetaTags(defaultMetaTags.concat(options.metaTags || [])),
|
||||
linkTags = utils.buildLinkTags(options.linkTags || []),
|
||||
templateValues = {
|
||||
cssSrc: meta.config['theme:src'] || nconf.get('relative_path') + '/vendor/bootstrap/css/bootstrap.min.css',
|
||||
pluginCSS: plugins.cssFiles.map(function(file) { return { path: file } }),
|
||||
title: meta.config.title || 'NodeBB',
|
||||
title: meta.config.title || '',
|
||||
'brand:logo': meta.config['brand:logo'] || '',
|
||||
'brand:logo:display': meta.config['brand:logo']?'':'hide',
|
||||
browserTitle: meta.config.title || 'NodeBB',
|
||||
csrf: options.res.locals.csrf_token,
|
||||
relative_path: nconf.get('relative_path'),
|
||||
meta_tags: metaString,
|
||||
link_tags: linkTags,
|
||||
clientScripts: clientScripts,
|
||||
navigation: custom_header.navigation
|
||||
};
|
||||
@@ -425,7 +429,18 @@ var express = require('express'),
|
||||
}, {
|
||||
property: 'article:section',
|
||||
content: topicData.category_name
|
||||
}]
|
||||
}],
|
||||
linkTags: [
|
||||
{
|
||||
rel: 'alternate',
|
||||
type: 'application/rss+xml',
|
||||
href: nconf.get('url') + 'topic/' + tid + '.rss'
|
||||
},
|
||||
{
|
||||
rel: 'up',
|
||||
href: nconf.get('url') + 'category/' + topicData.category_slug
|
||||
}
|
||||
]
|
||||
}, function (err, header) {
|
||||
next(err, {
|
||||
header: header,
|
||||
@@ -494,7 +509,18 @@ var express = require('express'),
|
||||
}, {
|
||||
property: "og:type",
|
||||
content: 'website'
|
||||
}]
|
||||
}],
|
||||
linkTags: [
|
||||
{
|
||||
rel: 'alternate',
|
||||
type: 'application/rss+xml',
|
||||
href: nconf.get('url') + 'category/' + cid + '.rss'
|
||||
},
|
||||
{
|
||||
rel: 'up',
|
||||
href: nconf.get('url')
|
||||
}
|
||||
]
|
||||
}, function (err, header) {
|
||||
next(err, {
|
||||
header: header,
|
||||
|
||||
Reference in New Issue
Block a user