Node.js based forum software built for the modern web
added additional_profile_info footer in posts view; plugins - filter:posts.custom_profile_info hook lets you add info to post block footer
psychobunnybf677522a93e
diff --git a/app.js b/app.jsindex 492faf9609..05ba01c22f 100644--- a/app.js+++ b/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 itselfwebsockets.init(SocketIO);diff --git a/public/src/app.js b/public/src/app.jsindex 9681e293f3..9098cce749 100644--- a/public/src/app.js+++ b/public/src/app.js@@ -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;diff --git a/public/templates/topic.tpl b/public/templates/topic.tplindex 1488af1e3a..5db4ea3fd2 100644--- a/public/templates/topic.tpl+++ b/public/templates/topic.tpl@@ -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>diff --git a/src/posts.js b/src/posts.jsindex 411610ee5e..60899e68c6 100644--- a/src/posts.js+++ b/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();+ 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;- post.editorname = editorData.username;- post.editorslug = editorData.userslug;+ 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();- });- } else {- callback();- }+ }+ });});});};