Baris Soner Usakli 11 years ago
commit 5710ab47ae

@ -9,6 +9,9 @@
"url": "https://github.com/designcreateplay/NodeBB/"
},
"main": "app.js",
"scripts": {
"test": "mocha ./tests"
},
"dependencies": {
"socket.io": "~0.9.16",
"redis": "0.8.3",
@ -44,6 +47,9 @@
"optionalDependencies": {
"hiredis": "~0.1.15"
},
"devDependencies": {
"mocha": "~1.13.0"
},
"bugs": {
"url": "https://github.com/designcreateplay/NodeBB/issues"
},

@ -59,9 +59,11 @@
<li class="visible-xs">
<a href="/search">[[global:header.search]]</a>
</li>
<li>
<a href="/"></a>
<!-- BEGIN navigation -->
<li class="{navigation.class}">
<a href="{navigation.route}">{navigation.text}</a>
</li>
<!-- END navigation -->
</ul>
<form id="search-form" class="navbar-form navbar-right hidden-xs" role="search" method="GET" action="">

@ -17,18 +17,21 @@
<a id="post_anchor_{main_posts.pid}" name="{main_posts.pid}"></a>
<li class="row post-row main-post" data-pid="{main_posts.pid}" data-uid="{main_posts.uid}" data-username="{main_posts.username}" data-deleted="{main_posts.deleted}">
<div class="col-md-12">
<div class="post-block">
<div class="post-block" itemscope itemtype="http://schema.org/Article">
<meta itemprop="datePublished" content="{main_posts.relativeTime}">
<meta itemprop="datePublished" content="{main_posts.relativeEditTime}">
<meta itemprop="url" content="/topic/{slug}/">
<a class="avatar" href="/user/{main_posts.userslug}">
<img src="{main_posts.picture}" align="left" class="img-thumbnail" width=150 height=150 /><br />
<img itemprop="image" src="{main_posts.picture}" align="left" class="img-thumbnail" width=150 height=150 /><br />
</a>
<h3>
<p id="topic_title_{main_posts.pid}" class="topic-title">{topic_name}</p>
<p id="topic_title_{main_posts.pid}" class="topic-title" itemprop="name">{topic_name}</p>
</h3>
<div class="topic-buttons">
<div class="btn-group">
<button class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" type="button" title="[[topic:posted_by]] {main_posts.username}">
<span class="username-field" href="/user/{main_posts.userslug}">{main_posts.username}&nbsp;</span>
<span class="username-field" href="/user/{main_posts.userslug}" itemprop="author" itemscope itemtype="http://schema.org/Person">{main_posts.username}&nbsp;</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
@ -60,7 +63,7 @@
</div>
<div id="content_{main_posts.pid}" class="post-content">{main_posts.content}</div>
<div id="content_{main_posts.pid}" class="post-content" itemprop="articleBody">{main_posts.content}</div>
<div class="post-signature">{main_posts.signature}</div>
<div class="post-info">
<span class="pull-right">

@ -325,33 +325,40 @@ var RDB = require('./redis.js'),
return;
}
var categories = [];
// var categories = [];
function getCategory(cid, callback) {
Categories.getCategoryData(cid, function(err, categoryData) {
if (err) {
callback(err);
winston.warn('Attempted to retrieve cid ' + cid + ', but nothing was returned!');
callback(null, null);
return;
}
Categories.hasReadCategory(cid, current_user, function(hasRead) {
categoryData.badgeclass = (parseInt(categoryData.topic_count, 10) === 0 || (hasRead && current_user !== 0)) ? '' : 'badge-important';
categories.push(categoryData);
callback(null);
// categories.push(categoryData);
callback(null, categoryData);
});
});
}
async.eachSeries(cids, getCategory, function(err) {
async.map(cids, getCategory, function(err, categories) {
if (err) {
winston.err(err);
callback(null);
return;
}
categories = categories.sort(function(a, b) { return parseInt(a.order, 10) - parseInt(b.order, 10); });
categories = categories.filter(function(category) {
// Remove categories that have errored out
if (category) return true;
else return false;
}).sort(function(a, b) {
// Sort categories into their defined order
return parseInt(a.order, 10) - parseInt(b.order, 10);
});
callback({
'categories': categories

@ -155,27 +155,21 @@ var fs = require('fs'),
var hookType = hook.split(':')[0];
switch (hookType) {
case 'filter':
// Filters only take one argument, so only args[0] will be passed in
var returnVal = (Array.isArray(args) ? args[0] : args);
async.eachSeries(hookList, function(hookObj, next) {
if (hookObj[2]) {
_self.libraries[hookObj[0]][hookObj[1]](returnVal, function(err, afterVal) {
returnVal = afterVal;
next(err);
});
} else {
returnVal = _self.libraries[hookObj[0]][hookObj[1]](returnVal);
next();
async.reduce(hookList, args, function(value, hookObj, next) {
if (hookObj[2]) { // If a callback is present (asynchronous method)
_self.libraries[hookObj[0]][hookObj[1]](value, next);
} else { // Synchronous method
value = _self.libraries[hookObj[0]][hookObj[1]](value);
next(null, value);
}
}, function(err) {
}, function(err, value) {
if (err) {
if (global.env === 'development') {
winston.info('[plugins] Problem executing hook: ' + hook);
}
}
callback(err, returnVal);
callback.apply(plugins, arguments);
});
break;
case 'action':
@ -197,7 +191,7 @@ var fs = require('fs'),
}
} else {
// Otherwise, this hook contains no methods
var returnVal = (Array.isArray(args) ? args[0] : args);
var returnVal = args;
if (callback) callback(null, returnVal);
}
},

@ -44,6 +44,11 @@ var express = require('express'),
* accepts: metaTags
*/
app.build_header = function (options, callback) {
var custom_header = {
'navigation': []
};
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'
@ -69,12 +74,14 @@ var express = require('express'),
csrf: options.res.locals.csrf_token,
relative_path: nconf.get('relative_path'),
meta_tags: metaString,
clientScripts: clientScripts
clientScripts: clientScripts,
navigation: custom_header.navigation
};
translator.translate(templates.header.parse(templateValues), function(template) {
callback(null, template);
});
});
};
// Middlewares

@ -0,0 +1,54 @@
var assert = require('assert'),
RDB = require('../src/redis'),
Categories = require('../src/categories');
describe('Categories', function() {
var categoryObj;
describe('.create', function() {
it('should create a new category', function(done) {
Categories.create({
name: 'Test Category',
description: 'Test category created by testing script',
icon: 'icon-ok',
blockclass: 'category-blue',
order: '5'
}, function(err, category) {
categoryObj = category;
done.apply(this, arguments);
});
});
});
describe('.getCategoryById', function() {
it('should retrieve a newly created category by its ID', function(done) {
Categories.getCategoryById(categoryObj.cid, 0, function(err, categoryData) {
assert(categoryData);
assert.equal(categoryObj.name, categoryData.category_name);
assert.equal(categoryObj.description, categoryData.category_description);
done();
});
});
});
describe('.getCategoryTopics', function() {
it('should return a list of topics', function(done) {
Categories.getCategoryTopics(categoryObj.cid, 0, 10, 0, function(topics) {
assert(Array.isArray(topics));
assert(topics.every(function(topic) {
return topic instanceof Object;
}));
done();
});
});
});
after(function() {
RDB.multi()
.del('category:'+categoryObj.cid)
.rpop('categories:cid')
.exec();
});
});
Loading…
Cancel
Save