Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to latest nodebb #6

Merged
merged 4 commits into from
Feb 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
_.mixin(_.str.exports()); // Mix in non-conflict functions to Underscore namespace
var Beep = {
banned_words: undefined,
init: function (app, middleware, controllers, callback) {
init: function (params, callback) {
var router = params.router;
var middleware = params.middleware;

function render(req, res, next) {
res.render('admin/plugins/beep', {});
}
app.get('/admin/plugins/beep', middleware.admin.buildHeader, render);
app.get('/api/admin/plugins/beep', render);
app.get('/api/plugins/beep', function (req, res) {
router.get('/admin/plugins/beep', middleware.admin.buildHeader, render);
router.get('/api/admin/plugins/beep', render);
router.get('/api/plugins/beep', function (req, res) {
if (Beep.banned_words) {
res.send(200, Beep.banned_words);
} else {
Expand All @@ -42,7 +45,11 @@
Beep.loadList();
}
},
parse: function (postContent, callback) {
parse: function (data, callback) {
if (!data || !data.postData || !data.postData.content) {
return callback(null, data);
}
var postContent = data.postData.content;
var badwords = Beep.banned_words.split(',');
badwords = _.map(badwords, function(word) { return _.trim(word); });
for (var w in badwords) {
Expand All @@ -55,10 +62,10 @@
if (postContent.match(re)) {
var match = postContent.match(re);
var hashword = match[0].replace(re2, hidesting);
postContent = postContent.replace(re, hashword);
data.postData.content = postContent.replace(re, hashword);
}
}
callback(null, postContent);
callback(null, data);
},
admin: {
menu: function (custom_header, callback) {
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"templates":"public/templates",
"hooks": [
{ "hook": "static:app.load", "method": "init" },
{ "hook": "filter:post.parse", "method": "parse", "priority": 5 },
{ "hook": "filter:parse.post", "method": "parse", "priority": 5 },
{ "hook": "action:settings.set", "method": "onListChange" },
{ "hook": "filter:admin.header.build", "method": "admin.menu" }
],
Expand Down