mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-31 19:15:58 +01:00
added additional_profile_info footer in posts view; plugins - filter:posts.custom_profile_info hook lets you add info to post block footer
also fixed app.alert - if title is not set then do not show title.
This commit is contained in:
1
app.js
1
app.js
@@ -86,6 +86,7 @@
|
|||||||
webserver = require('./src/webserver.js'),
|
webserver = require('./src/webserver.js'),
|
||||||
SocketIO = require('socket.io').listen(global.server, { log: false, transports: ['websocket', 'xhr-polling', 'jsonp-polling', 'flashsocket']}),
|
SocketIO = require('socket.io').listen(global.server, { log: false, transports: ['websocket', 'xhr-polling', 'jsonp-polling', 'flashsocket']}),
|
||||||
websockets = require('./src/websockets.js'),
|
websockets = require('./src/websockets.js'),
|
||||||
|
posts = require('./src/posts.js'),
|
||||||
plugins = require('./src/plugins'); // Don't remove this - plugins initializes itself
|
plugins = require('./src/plugins'); // Don't remove this - plugins initializes itself
|
||||||
|
|
||||||
websockets.init(SocketIO);
|
websockets.init(SocketIO);
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ var socket,
|
|||||||
var alert_id = 'alert_button_' + ((params.alert_id) ? params.alert_id : new Date().getTime());
|
var alert_id = 'alert_button_' + ((params.alert_id) ? params.alert_id : new Date().getTime());
|
||||||
|
|
||||||
var alert = $('#' + alert_id);
|
var alert = $('#' + alert_id);
|
||||||
|
var title = params.title || '';
|
||||||
|
|
||||||
function startTimeout(div, timeout) {
|
function startTimeout(div, timeout) {
|
||||||
var timeoutId = setTimeout(function () {
|
var timeoutId = setTimeout(function () {
|
||||||
@@ -148,7 +149,7 @@ var socket,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (alert.length > 0) {
|
if (alert.length > 0) {
|
||||||
alert.find('strong').html(params.title);
|
alert.find('strong').html(title);
|
||||||
alert.find('p').html(params.message);
|
alert.find('p').html(params.message);
|
||||||
alert.attr('class', "alert toaster-alert " + "alert-" + params.type);
|
alert.attr('class', "alert toaster-alert " + "alert-" + params.type);
|
||||||
|
|
||||||
@@ -161,7 +162,7 @@ var socket,
|
|||||||
p = document.createElement('p');
|
p = document.createElement('p');
|
||||||
|
|
||||||
p.innerHTML = params.message;
|
p.innerHTML = params.message;
|
||||||
strong.innerHTML = params.title;
|
strong.innerHTML = title;
|
||||||
|
|
||||||
div.className = "alert toaster-alert " + "alert-" + params.type;
|
div.className = "alert toaster-alert " + "alert-" + params.type;
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,9 @@
|
|||||||
<div id="content_{main_posts.pid}" class="post-content" itemprop="articleBody">{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-signature">{main_posts.signature}</div>
|
||||||
<div class="post-info">
|
<div class="post-info">
|
||||||
|
<span class="pull-left">
|
||||||
|
{main_posts.additional_profile_info}
|
||||||
|
</span>
|
||||||
<span class="pull-right">
|
<span class="pull-right">
|
||||||
posted <span class="relativeTimeAgo timeago" title="{main_posts.relativeTime}"></span>
|
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>
|
<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 id="content_{posts.pid}" class="post-content" itemprop="text">{posts.content}</div>
|
||||||
<div class="post-signature">{posts.signature}</div>
|
<div class="post-signature">{posts.signature}</div>
|
||||||
<div class="post-info">
|
<div class="post-info">
|
||||||
|
<span class="pull-left">
|
||||||
|
{posts.additional_profile_info}
|
||||||
|
</span>
|
||||||
<span class="pull-right">
|
<span class="pull-right">
|
||||||
posted <span class="relativeTimeAgo timeago" title="{posts.relativeTime}"></span>
|
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>
|
<span class="{posts.edited-class}">| last edited by <strong><a href="/user/{posts.editorslug}">{posts.editorname}</a></strong></span>
|
||||||
|
|||||||
31
src/posts.js
31
src/posts.js
@@ -16,6 +16,7 @@ var RDB = require('./redis.js'),
|
|||||||
winston = require('winston');
|
winston = require('winston');
|
||||||
|
|
||||||
(function(Posts) {
|
(function(Posts) {
|
||||||
|
var customUserInfo = {};
|
||||||
|
|
||||||
Posts.getPostsByTid = function(tid, start, end, callback) {
|
Posts.getPostsByTid = function(tid, start, end, callback) {
|
||||||
RDB.lrange('tid:' + tid + ':posts', start, end, function(err, pids) {
|
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.picture = userData.picture || require('gravatar').url('', {}, https = nconf.get('https'));
|
||||||
post.signature = signature;
|
post.signature = signature;
|
||||||
|
|
||||||
if (post.editor !== '') {
|
for (var info in customUserInfo) {
|
||||||
user.getUserFields(post.editor, ['username', 'userslug'], function(err, editorData) {
|
if (customUserInfo.hasOwnProperty(info)) {
|
||||||
if (err) return callback();
|
post[info] = userData[info] || customUserInfo[info];
|
||||||
|
}
|
||||||
post.editorname = editorData.username;
|
|
||||||
post.editorslug = editorData.userslug;
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
callback();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user