mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-06 15:42:52 +01:00
Merge branch 'master' of github.com:designcreateplay/NodeBB
This commit is contained in:
1
app.js
1
app.js
@@ -86,6 +86,7 @@
|
||||
webserver = require('./src/webserver.js'),
|
||||
SocketIO = require('socket.io').listen(global.server, { log: false, transports: ['websocket', 'xhr-polling', 'jsonp-polling', 'flashsocket']}),
|
||||
websockets = require('./src/websockets.js'),
|
||||
posts = require('./src/posts.js'),
|
||||
plugins = require('./src/plugins'); // Don't remove this - plugins initializes itself
|
||||
|
||||
websockets.init(SocketIO);
|
||||
|
||||
@@ -176,7 +176,7 @@ var ajaxify = {};
|
||||
|
||||
var scripts = [],
|
||||
script,
|
||||
children_nodes = $(body_el).children(),
|
||||
children_nodes = $(body_el).find('script'),
|
||||
child,
|
||||
i;
|
||||
|
||||
|
||||
@@ -136,6 +136,7 @@ var socket,
|
||||
var alert_id = 'alert_button_' + ((params.alert_id) ? params.alert_id : new Date().getTime());
|
||||
|
||||
var alert = $('#' + alert_id);
|
||||
var title = params.title || '';
|
||||
|
||||
function startTimeout(div, timeout) {
|
||||
var timeoutId = setTimeout(function () {
|
||||
@@ -148,7 +149,7 @@ var socket,
|
||||
}
|
||||
|
||||
if (alert.length > 0) {
|
||||
alert.find('strong').html(params.title);
|
||||
alert.find('strong').html(title);
|
||||
alert.find('p').html(params.message);
|
||||
alert.attr('class', "alert toaster-alert " + "alert-" + params.type);
|
||||
|
||||
@@ -161,7 +162,7 @@ var socket,
|
||||
p = document.createElement('p');
|
||||
|
||||
p.innerHTML = params.message;
|
||||
strong.innerHTML = params.title;
|
||||
strong.innerHTML = title;
|
||||
|
||||
div.className = "alert toaster-alert " + "alert-" + params.type;
|
||||
|
||||
|
||||
@@ -16,9 +16,7 @@ jQuery('document').ready(function() {
|
||||
});
|
||||
|
||||
socket.once('api:config.get', function(config) {
|
||||
require(['forum/admin/settings'], function(Settings) {
|
||||
Settings.config = config;
|
||||
});
|
||||
app.config = config;
|
||||
});
|
||||
|
||||
socket.emit('api:config.get');
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
define(function() {
|
||||
var Settings = {};
|
||||
|
||||
Settings.config = {};
|
||||
|
||||
Settings.init = function() {
|
||||
Settings.prepare();
|
||||
};
|
||||
|
||||
Settings.prepare = function() {
|
||||
// Come back in 500ms if the config isn't ready yet
|
||||
if (Settings.config === undefined) {
|
||||
// Come back in 125ms if the config isn't ready yet
|
||||
if (!app.config) {
|
||||
setTimeout(function() {
|
||||
Settings.prepare();
|
||||
}, 500);
|
||||
}, 125);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,21 +23,21 @@ define(function() {
|
||||
key = fields[x].getAttribute('data-field');
|
||||
inputType = fields[x].getAttribute('type');
|
||||
if (fields[x].nodeName === 'INPUT') {
|
||||
if (Settings.config[key]) {
|
||||
if (app.config[key]) {
|
||||
switch (inputType) {
|
||||
case 'text':
|
||||
case 'textarea':
|
||||
case 'number':
|
||||
fields[x].value = Settings.config[key];
|
||||
fields[x].value = app.config[key];
|
||||
break;
|
||||
|
||||
case 'checkbox':
|
||||
fields[x].checked = Settings.config[key] === '1' ? true : false;
|
||||
fields[x].checked = app.config[key] === '1' ? true : false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (fields[x].nodeName === 'TEXTAREA') {
|
||||
if (Settings.config[key]) fields[x].value = Settings.config[key];
|
||||
if (app.config[key]) fields[x].value = app.config[key];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,35 +76,52 @@
|
||||
<div class="well sidebar-nav">
|
||||
<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/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/groups"><i class="icon-group"></i> Groups</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>
|
||||
<li class=''><a href='{relative_path}/admin/plugins'><i class='icon-code-fork'></i> Plugins</a></li>
|
||||
<li class=''><a href='{relative_path}/admin/settings'><i class='icon-cogs'></i> Settings</a></li>
|
||||
<li class=''><a href='{relative_path}/admin/redis'><i class='icon-hdd'></i> Redis</a></li>
|
||||
<li class=''><a href='{relative_path}/admin/logger'><i class='icon-th'></i> Logger</a></li>
|
||||
<li class=''><a href="{relative_path}/admin/motd"><i class="icon-comment"></i> MOTD</a></li>
|
||||
|
||||
<li class='active'>
|
||||
<a href='{relative_path}/admin/index'><i class='icon-home'></i> Home</a>
|
||||
</li>
|
||||
<li><a href='{relative_path}/admin/categories/active'><i class='icon-folder-close-alt'></i> Categories</a></li>
|
||||
<li><a href='{relative_path}/admin/users/latest'><i class='icon-user'></i> Users</a></li>
|
||||
<li><a href="{relative_path}/admin/groups"><i class="icon-group"></i> Groups</a></li>
|
||||
<li><a href='{relative_path}/admin/topics'><i class='icon-book'></i> Topics</a></li>
|
||||
<li><a href='{relative_path}/admin/themes'><i class='icon-th'></i> Themes</a></li>
|
||||
<li><a href='{relative_path}/admin/plugins'><i class='icon-code-fork'></i> Plugins</a></li>
|
||||
<li><a href='{relative_path}/admin/settings'><i class='icon-cogs'></i> Settings</a></li>
|
||||
<li><a href='{relative_path}/admin/redis'><i class='icon-hdd'></i> Redis</a></li>
|
||||
<li><a href='{relative_path}/admin/logger'><i class='icon-th'></i> Logger</a></li>
|
||||
<li><a href="{relative_path}/admin/motd"><i class="icon-comment"></i> MOTD</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="well sidebar-nav">
|
||||
<ul class="nav nav-list">
|
||||
<li class="nav-header">Social Authentication</li>
|
||||
<li class=''><a href='{relative_path}/admin/twitter'><i class='icon-twitter-sign'></i> Twitter</a></li>
|
||||
<li class=''><a href='{relative_path}/admin/facebook'><i class='icon-facebook-sign'></i> Facebook</a></li>
|
||||
<li class=''><a href='{relative_path}/admin/gplus'><i class='icon-google-plus-sign'></i> Google+</a></li>
|
||||
<!--<li class="nav-header">Custom Modules</li>-->
|
||||
<!-- <li class=''><a href=''>Search</a></li> -->
|
||||
<li><a href='{relative_path}/admin/twitter'><i class='icon-twitter-sign'></i> Twitter</a></li>
|
||||
<li><a href='{relative_path}/admin/facebook'><i class='icon-facebook-sign'></i> Facebook</a></li>
|
||||
<li><a href='{relative_path}/admin/gplus'><i class='icon-google-plus-sign'></i> Google+</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="well sidebar-nav">
|
||||
<ul class="nav nav-list">
|
||||
<li class="nav-header">Plugins</li>
|
||||
<!-- BEGIN plugins -->
|
||||
<li>
|
||||
<a href='{relative_path}/admin{plugins.route}'><i class="{plugins.icon}"></i> {plugins.name}</a>
|
||||
</li>
|
||||
<!-- END plugins -->
|
||||
</ul>
|
||||
</div>
|
||||
<div class="well sidebar-nav">
|
||||
<ul class="nav nav-list">
|
||||
<li class="nav-header">Unit Tests</li>
|
||||
<ul class="nav nav-list">
|
||||
<li class=''><a href='{relative_path}/admin/testing/categories'>Categories</a></li>
|
||||
<!--<li class=''><a href='{relative_path}/admin/testing/topics'>Topics</a></li>
|
||||
<li class=''><a href='{relative_path}/admin/testing/posts'>Posts</a></li>
|
||||
<li class=''><a href='{relative_path}/admin/testing/accounts'>Accounts</a></li>
|
||||
<li class=''><a href='{relative_path}/admin/testing/chat'>Chat</a></li>
|
||||
<li class=''><a href='{relative_path}/admin/testing/notifications'>Notifications</a></li>
|
||||
<li class=''><a href='{relative_path}/admin/testing/friends'>Friends</a></li>
|
||||
<li class=''><a href='{relative_path}/admin/testing/feed'>RSS Feed</a></li>
|
||||
<li class=''><a href='{relative_path}/admin/testing/emails'>Emails</a></li>-->
|
||||
<li><a href='{relative_path}/admin/testing/categories'>Categories</a></li>
|
||||
<!--<li><a href='{relative_path}/admin/testing/topics'>Topics</a></li>
|
||||
<li><a href='{relative_path}/admin/testing/posts'>Posts</a></li>
|
||||
<li><a href='{relative_path}/admin/testing/accounts'>Accounts</a></li>
|
||||
<li><a href='{relative_path}/admin/testing/chat'>Chat</a></li>
|
||||
<li><a href='{relative_path}/admin/testing/notifications'>Notifications</a></li>
|
||||
<li><a href='{relative_path}/admin/testing/friends'>Friends</a></li>
|
||||
<li><a href='{relative_path}/admin/testing/feed'>RSS Feed</a></li>
|
||||
<li><a href='{relative_path}/admin/testing/emails'>Emails</a></li>-->
|
||||
</ul>
|
||||
</ul>
|
||||
</div><!--/.well -->
|
||||
|
||||
@@ -90,6 +90,16 @@
|
||||
<!-- END moderators -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- BEGIN sidebars -->
|
||||
<div class="sidebar-block img-thumbnail {sidebars.block_class}">
|
||||
<div class="block-header">
|
||||
{sidebars.header}
|
||||
</div>
|
||||
<div class="block-content">
|
||||
{sidebars.content}
|
||||
</div>
|
||||
</div>
|
||||
<!-- END sidebars -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -66,6 +66,9 @@
|
||||
<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-left">
|
||||
{main_posts.additional_profile_info}
|
||||
</span>
|
||||
<span class="pull-right">
|
||||
posted <span class="relativeTimeAgo timeago" title="{main_posts.relativeTime}"></span>
|
||||
<span class="{main_posts.edited-class}">| last edited by <strong><a href="/user/{main_posts.editorslug}">{main_posts.editorname}</a></strong></span>
|
||||
@@ -127,6 +130,9 @@
|
||||
<div id="content_{posts.pid}" class="post-content" itemprop="text">{posts.content}</div>
|
||||
<div class="post-signature">{posts.signature}</div>
|
||||
<div class="post-info">
|
||||
<span class="pull-left">
|
||||
{posts.additional_profile_info}
|
||||
</span>
|
||||
<span class="pull-right">
|
||||
posted <span class="relativeTimeAgo timeago" title="{posts.relativeTime}"></span>
|
||||
<span class="{posts.edited-class}">| last edited by <strong><a href="/user/{posts.editorslug}">{posts.editorname}</a></strong></span>
|
||||
|
||||
@@ -55,9 +55,16 @@ var RDB = require('./redis.js'),
|
||||
Categories.getActiveUsers(category_id, next);
|
||||
}
|
||||
|
||||
async.parallel([getTopicIds, getActiveUsers], function(err, results) {
|
||||
function getSidebars(next) {
|
||||
plugins.fireHook('filter:category.build_sidebars', [], function(err, sidebars) {
|
||||
next(err, sidebars);
|
||||
});
|
||||
}
|
||||
|
||||
async.parallel([getTopicIds, getActiveUsers, getSidebars], function(err, results) {
|
||||
var tids = results[0],
|
||||
active_users = results[1];
|
||||
active_users = results[1],
|
||||
sidebars = results[2];
|
||||
|
||||
var categoryData = {
|
||||
'category_name': category_name,
|
||||
@@ -72,7 +79,8 @@ var RDB = require('./redis.js'),
|
||||
'topics': [],
|
||||
'twitter-intent-url': 'https://twitter.com/intent/tweet?url=' + encodeURIComponent(nconf.get('url') + 'category/' + category_slug) + '&text=' + encodeURIComponent(category_name),
|
||||
'facebook-share-url': 'https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(nconf.get('url') + 'category/' + category_slug),
|
||||
'google-share-url': 'https://plus.google.com/share?url=' + encodeURIComponent(nconf.get('url') + 'category/' + category_slug)
|
||||
'google-share-url': 'https://plus.google.com/share?url=' + encodeURIComponent(nconf.get('url') + 'category/' + category_slug),
|
||||
'sidebars': sidebars
|
||||
};
|
||||
|
||||
function getTopics(next) {
|
||||
|
||||
@@ -274,7 +274,13 @@ var fs = require('fs'),
|
||||
fs.readFile(path.join(file, 'plugin.json'), next);
|
||||
},
|
||||
function(configJSON, next) {
|
||||
var config = JSON.parse(configJSON);
|
||||
try {
|
||||
var config = JSON.parse(configJSON);
|
||||
} catch (err) {
|
||||
winston.warn("Plugin: " + file + " is corrupted or invalid. Please check plugin.json for errors.")
|
||||
return next(err, null);
|
||||
}
|
||||
|
||||
_self.isActive(config.id, function(err, active) {
|
||||
if (err) next(new Error('no-active-state'));
|
||||
|
||||
|
||||
31
src/posts.js
31
src/posts.js
@@ -16,6 +16,7 @@ var RDB = require('./redis.js'),
|
||||
winston = require('winston');
|
||||
|
||||
(function(Posts) {
|
||||
var customUserInfo = {};
|
||||
|
||||
Posts.getPostsByTid = function(tid, start, end, callback) {
|
||||
RDB.lrange('tid:' + tid + ':posts', start, end, function(err, pids) {
|
||||
@@ -46,17 +47,27 @@ var RDB = require('./redis.js'),
|
||||
post.picture = userData.picture || require('gravatar').url('', {}, https = nconf.get('https'));
|
||||
post.signature = signature;
|
||||
|
||||
if (post.editor !== '') {
|
||||
user.getUserFields(post.editor, ['username', 'userslug'], function(err, editorData) {
|
||||
if (err) return callback();
|
||||
|
||||
post.editorname = editorData.username;
|
||||
post.editorslug = editorData.userslug;
|
||||
callback();
|
||||
});
|
||||
} else {
|
||||
callback();
|
||||
for (var info in customUserInfo) {
|
||||
if (customUserInfo.hasOwnProperty(info)) {
|
||||
post[info] = userData[info] || customUserInfo[info];
|
||||
}
|
||||
}
|
||||
|
||||
plugins.fireHook('filter:posts.custom_profile_info', {profile: "", uid: post.uid}, function(err, profile_info) {
|
||||
post.additional_profile_info = profile_info.profile;
|
||||
|
||||
if (post.editor !== '') {
|
||||
user.getUserFields(post.editor, ['username', 'userslug'], function(err, editorData) {
|
||||
if (err) return callback();
|
||||
|
||||
post.editorname = editorData.username;
|
||||
post.editorslug = editorData.userslug;
|
||||
callback();
|
||||
});
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -18,10 +18,17 @@ var user = require('./../user.js'),
|
||||
});
|
||||
}
|
||||
|
||||
Admin.build_header = function (res) {
|
||||
return templates['admin/header'].parse({
|
||||
csrf: res.locals.csrf_token,
|
||||
relative_path: nconf.get('relative_path')
|
||||
Admin.build_header = function (res, callback) {
|
||||
var custom_header = {
|
||||
'plugins': []
|
||||
};
|
||||
|
||||
plugins.fireHook('filter:admin.header.build', custom_header, function(err, custom_header) {
|
||||
callback(err, templates['admin/header'].parse({
|
||||
csrf: res.locals.csrf_token,
|
||||
relative_path: nconf.get('relative_path'),
|
||||
plugins: custom_header.plugins
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -38,7 +45,9 @@ var user = require('./../user.js'),
|
||||
for (var i = 0, ii = routes.length; i < ii; i++) {
|
||||
(function (route) {
|
||||
app.get('/admin/' + route, Admin.isAdmin, function (req, res) {
|
||||
res.send(Admin.build_header(res) + app.create_route('admin/' + route) + templates['admin/footer']);
|
||||
Admin.build_header(res, function(err, header) {
|
||||
res.send(header + app.create_route('admin/' + route) + templates['admin/footer']);
|
||||
});
|
||||
});
|
||||
}(routes[i]));
|
||||
}
|
||||
@@ -48,7 +57,9 @@ var user = require('./../user.js'),
|
||||
for (var i = 0, ii = unit_tests.length; i < ii; i++) {
|
||||
(function (route) {
|
||||
app.get('/admin/testing/' + route, Admin.isAdmin, function (req, res) {
|
||||
res.send(Admin.build_header(res) + app.create_route('admin/testing/' + route) + templates['admin/footer']);
|
||||
Admin.build_header(res, function(err, header) {
|
||||
res.send(header + app.create_route('admin/testing/' + route) + templates['admin/footer']);
|
||||
});
|
||||
});
|
||||
}(unit_tests[i]));
|
||||
}
|
||||
@@ -57,14 +68,42 @@ var user = require('./../user.js'),
|
||||
|
||||
app.namespace('/admin', function () {
|
||||
app.get('/', Admin.isAdmin, function (req, res) {
|
||||
res.send(Admin.build_header(res) + app.create_route('admin/index') + templates['admin/footer']);
|
||||
Admin.build_header(res, function(err, header) {
|
||||
res.send(header + app.create_route('admin/index') + templates['admin/footer']);
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/index', Admin.isAdmin, function (req, res) {
|
||||
res.send(Admin.build_header(res) + app.create_route('admin/index') + templates['admin/footer']);
|
||||
Admin.build_header(res, function(err, header) {
|
||||
res.send(header + app.create_route('admin/index') + templates['admin/footer']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
var custom_routes = {
|
||||
'routes': [],
|
||||
'api_methods': []
|
||||
};
|
||||
|
||||
plugins.ready(function() {
|
||||
plugins.fireHook('filter:admin.create_routes', custom_routes, function(err, custom_routes) {
|
||||
var routes = custom_routes.routes;
|
||||
|
||||
for (var route in routes) {
|
||||
if (routes.hasOwnProperty(route)) {
|
||||
app[routes[route].method || 'get']('/admin' + routes[route].route, function(req, res) {
|
||||
routes[route].options(req, res, function(options) {
|
||||
Admin.build_header(res, function (err, header) {
|
||||
res.send(header + options.content + templates['admin/footer']);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
app.namespace('/api/admin', function () {
|
||||
app.get('/index', function (req, res) {
|
||||
res.json({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var RDB = require('./redis.js')
|
||||
schema = require('./schema.js'),
|
||||
var RDB = require('./redis.js'),
|
||||
schema = require('./schema.js'),
|
||||
posts = require('./posts.js'),
|
||||
utils = require('./../public/src/utils.js'),
|
||||
user = require('./user.js'),
|
||||
|
||||
Reference in New Issue
Block a user