mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-13 21:21:58 +02:00
derp conflicts
Merge branch 'master' of https://github.com/psychobunny/NodeBB Conflicts: public/src/templates.js
This commit is contained in:
@@ -48,6 +48,7 @@ marked.setOptions({
|
||||
'username' : user_data[uid].username || 'anonymous',
|
||||
'user_rep' : user_data[uid].reputation || 0,
|
||||
'gravatar' : user_data[uid].picture || 'http://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e',
|
||||
'signature' : user_data[uid].signature,
|
||||
'fav_star_class' : vote_data[pid] ? 'icon-star' : 'icon-star-empty',
|
||||
'display_moderator_tools': (uid == current_user || manage_content || viewer_data.isModerator) ? 'show' : 'none',
|
||||
'edited-class': post_data.editor[i] !== null ? '' : 'none',
|
||||
@@ -147,7 +148,7 @@ marked.setOptions({
|
||||
}
|
||||
}
|
||||
|
||||
user.getMultipleUserFields(post_data.uid, ['username','reputation','picture'], function(user_details){
|
||||
user.getMultipleUserFields(post_data.uid, ['username','reputation','picture', 'signature'], function(user_details){
|
||||
user_data = user_details;
|
||||
generateThread();
|
||||
});
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
|
||||
var user = require('./../user.js'),
|
||||
topics = require('./../topics.js');
|
||||
topics = require('./../topics.js'),
|
||||
RDB = require('./../redis.js');
|
||||
|
||||
(function(Admin) {
|
||||
Admin.create_routes = function(app) {
|
||||
|
||||
(function() {
|
||||
var routes = ['categories', 'users', 'topics', 'settings', 'themes', 'twitter', 'facebook', 'gplus'];
|
||||
var routes = ['categories', 'users', 'topics', 'settings', 'themes', 'twitter', 'facebook', 'gplus', 'redis'];
|
||||
|
||||
for (var i=0, ii=routes.length; i<ii; i++) {
|
||||
(function(route) {
|
||||
app.get('/admin/' + route, function(req, res) {
|
||||
console.log("derp " +route);
|
||||
res.send(templates['admin/header'] + app.create_route('admin/' + route) + templates['admin/footer']);
|
||||
});
|
||||
}(routes[i]));
|
||||
@@ -52,6 +54,31 @@ var user = require('./../user.js'),
|
||||
res.send(JSON.stringify(data));
|
||||
});
|
||||
break;
|
||||
case 'redis':
|
||||
console.log('going into redis');
|
||||
RDB.info(function(err, data) {
|
||||
data = data.split("\r\n");
|
||||
var finalData = {};
|
||||
|
||||
for(var i in data) {
|
||||
|
||||
try {
|
||||
data[i] = data[i].replace(/:/,"\":\"");
|
||||
var json = "{\"" + data[i] + "\"}";
|
||||
|
||||
var jsonObject = JSON.parse(json);
|
||||
for(var key in jsonObject) {
|
||||
finalData[key] = jsonObject[key];
|
||||
}
|
||||
}catch(err){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
console.log(finalData);
|
||||
res.send(JSON.stringify(finalData));
|
||||
});
|
||||
break;
|
||||
default :
|
||||
res.send('{}');
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ var RDB = require('./redis.js'),
|
||||
user = require('./user.js'),
|
||||
configs = require('../config.js'),
|
||||
categories = require('./categories.js'),
|
||||
marked = require('marked')
|
||||
marked = require('marked'),
|
||||
async = require('async');
|
||||
|
||||
marked.setOptions({
|
||||
@@ -169,6 +169,59 @@ marked.setOptions({
|
||||
});
|
||||
}
|
||||
|
||||
Topics.get_topic = function(tid, uid, callback) {
|
||||
var topicData = {};
|
||||
|
||||
async.parallel([
|
||||
function(next) {
|
||||
RDB.mget([
|
||||
'tid:' + tid + ':title',
|
||||
'tid:' + tid + ':uid',
|
||||
'tid:' + tid + ':timestamp',
|
||||
'tid:' + tid + ':slug',
|
||||
'tid:' + tid + ':postcount',
|
||||
'tid:' + tid + ':locked',
|
||||
'tid:' + tid + ':pinned',
|
||||
'tid:' + tid + ':deleted'
|
||||
], function(err, topic) {
|
||||
topicData.title = topic[0];
|
||||
topicData.uid = topic[1];
|
||||
topicData.timestamp = topic[2];
|
||||
topicData.relativeTime = utils.relativeTime(topic[2]),
|
||||
topicData.slug = topic[3];
|
||||
topicData.post_count = topic[4];
|
||||
topicData.locked = topic[5];
|
||||
topicData.pinned = topic[6];
|
||||
topicData.deleted = topic[7];
|
||||
|
||||
user.getUserField(topic[1], 'username', function(username) {
|
||||
topicData.username = username;
|
||||
next(null);
|
||||
})
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
if (uid && parseInt(uid) > 0) {
|
||||
RDB.sismember('tid:' + tid + ':read_by_uid', uid, function(err, read) {
|
||||
topicData.badgeclass = read ? '' : 'badge-important';
|
||||
next(null);
|
||||
});
|
||||
} else next(null);
|
||||
},
|
||||
function(next) {
|
||||
Topics.get_teaser(tid, function(teaser) {
|
||||
topicData.teaser_text = teaser.text;
|
||||
topicData.teaser_username = teaser.username;
|
||||
next(null);
|
||||
});
|
||||
}
|
||||
], function(err) {
|
||||
if (!err) {
|
||||
callback(topicData);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Topics.get_cid_by_tid = function(tid, callback) {
|
||||
RDB.get('tid:' + pid + ':cid', function(err, cid) {
|
||||
if (cid && parseInt(cid) > 0) callback(cid);
|
||||
@@ -218,8 +271,11 @@ marked.setOptions({
|
||||
'pid:' + pid + ':uid'
|
||||
], function(err, content) {
|
||||
user.getUserField(content[1], 'username', function(username) {
|
||||
var stripped = content[0];
|
||||
if(content[0])
|
||||
stripped = utils.strip_tags(marked(content[0]));
|
||||
callback({
|
||||
"text": utils.strip_tags(marked(content[0])),
|
||||
"text": stripped,
|
||||
"username": username
|
||||
});
|
||||
});
|
||||
@@ -269,7 +325,14 @@ marked.setOptions({
|
||||
|
||||
// Posts
|
||||
posts.create(uid, tid, content, function(pid) {
|
||||
if (pid > 0) RDB.lpush('tid:' + tid + ':posts', pid);
|
||||
if (pid > 0) {
|
||||
RDB.lpush('tid:' + tid + ':posts', pid);
|
||||
|
||||
// Notify any users looking at the category that a new post has arrived
|
||||
Topics.get_topic(tid, uid, function(topicData) {
|
||||
io.sockets.in('category_' + category_id).emit('event:new_topic', topicData);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Topics.markAsRead(tid, uid);
|
||||
@@ -284,7 +347,6 @@ marked.setOptions({
|
||||
timeout: 2000
|
||||
});
|
||||
|
||||
|
||||
// in future it may be possible to add topics to several categories, so leaving the door open here.
|
||||
RDB.sadd('categories:' + category_id + ':tid', tid);
|
||||
RDB.set('tid:' + tid + ':cid', category_id);
|
||||
|
||||
18
src/user.js
18
src/user.js
@@ -6,7 +6,9 @@ var config = require('../config.js'),
|
||||
crypto = require('crypto'),
|
||||
emailjs = require('emailjs'),
|
||||
emailjsServer = emailjs.server.connect(config.mailer),
|
||||
bcrypt = require('bcrypt');
|
||||
bcrypt = require('bcrypt'),
|
||||
marked = require('marked');
|
||||
|
||||
|
||||
(function(User) {
|
||||
|
||||
@@ -79,19 +81,24 @@ var config = require('../config.js'),
|
||||
|
||||
User.updateProfile = function(uid, data) {
|
||||
|
||||
var fields = ['email', 'fullname', 'website', 'location', 'birthday'];
|
||||
var fields = ['email', 'fullname', 'website', 'location', 'birthday', 'signature'];
|
||||
var key = '';
|
||||
|
||||
for(var i=0,ii=fields.length; i<ii; ++i) {
|
||||
key = fields[i];
|
||||
if(data[key] !== undefined) {
|
||||
|
||||
User.setUserField(uid, key, data[key]);
|
||||
if(data[key] !== undefined) {
|
||||
|
||||
if(key === 'email') {
|
||||
User.setUserField(uid, 'gravatarpicture', User.createGravatarURLFromEmail(data[key]));
|
||||
RDB.set('email:' + email +':uid', uid);
|
||||
RDB.set('email:' + data['email'] +':uid', uid);
|
||||
}
|
||||
else if(key === 'signature') {
|
||||
//sanitize sig plx - baris
|
||||
//data[key] = marked(data[key]);
|
||||
}
|
||||
|
||||
User.setUserField(uid, key, data[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -268,6 +275,7 @@ var config = require('../config.js'),
|
||||
'birthday':'',
|
||||
'website':'',
|
||||
'email' : email,
|
||||
'signature':'',
|
||||
'joindate' : new Date().getTime(),
|
||||
'picture': gravatar,
|
||||
'gravatarpicture' : gravatar,
|
||||
|
||||
@@ -237,8 +237,8 @@ var express = require('express'),
|
||||
app.get('/api/:method/:id*', api_method);
|
||||
|
||||
app.get('/test', function(req, res) {
|
||||
topics.get_teasers([1, 2, 3], function(teasers) {
|
||||
res.send(JSON.stringify(teasers));
|
||||
topics.get_topic(3, 1, function(data) {
|
||||
res.send(JSON.stringify(data));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user