Merge branch 'master' of github.com:psychobunny/NodeBB

v1.18.x
Julian Lam 12 years ago
commit 98193ecb29

@ -122,84 +122,112 @@ footer.footer {
.sidebar-block {
.block-header {
padding: 8px;
padding-left: 13px;
display: block;
background: rgb(245,245,245);
color: #676;
font-weight: 400;
font-size: 14px;
border-radius: 5px 5px 0 0;
border-bottom: 1px solid #ddd;
}
.block-content {
padding: 10px;
}
border-radius: 5px;
background: white;
padding: 0;
margin-bottom: 20px;
.img-polaroid {
margin-top: 2px;
}
}
.category { .category {
.block { a {
strong { li {
list-style: none;
border-bottom: 1px solid #eee;
margin-bottom: 10px; margin-bottom: 10px;
display: block padding-bottom: 10px;
} }
border: 1px solid #eee;
background: white;
padding: 10px;
.img-polaroid {
margin-top: 2px;
&:last-child li {
border-bottom: 0;
} }
}
li { color: #333;
list-style: none; &:hover {
border-bottom: 1px solid #eee; color: #333
margin-bottom: 10px; }
padding-bottom: 10px;
} }
}
@media (max-width: 767px) ul {
{ margin-left: 0;
.topic-row-icon {
border-radius: 5px 5px 0 0;
} }
}
.top-posters {
float: right;
padding-top: 2px;
margin-right: 30px;
div.latest-post { .topic-row {
border-radius: 5px;
width: 100%; width: 100%;
height: 50px; padding-left: 20px;
line-height: 16px;
img { h3 {
display: block; padding: 0;
float: left; margin: 0;
} margin-top: 4px;
p { line-height: 30px;
display: block; color: rgb(0, 136, 204);
float: left;
width: 400px; small {
margin-left: 10px; vertical-align: 2px;
overflow: hidden; strong {
height: 50px; color: #666;
}
}
} }
} }
.latest-post { .latest-post {
margin-left: 1px; float: right;
border: 1px solid rgba(0,0,0,0.05); padding-top: 2px;
padding: 5px; margin-right: 30px;
} width: 50%;
}
.topic-row { .pull-right {
width: 100%; width: 100%;
padding-left: 20px; height: 50px;
line-height: 16px;
margin-left: 1px;
padding: 5px;
border-left: 1px solid #bbb;
padding-left: 20px;
img {
display: block;
float: left;
}
p {
display: block;
float: left;
width: 70%;
margin-left: 10px;
overflow: hidden;
height: 50px;
}
}
}
} }
.topic-row h3 {
padding: 0;
margin: 0;
margin-top: 4px;
line-height: 30px;
}
.topic-row h3 small {
vertical-align: 3px;
}
.post-container { .post-container {
list-style-type: none; list-style-type: none;

@ -12,61 +12,74 @@
<span id="editLink" class="pull-right"><a href="/users/{username}/edit">edit</a></span> <span id="editLink" class="pull-right"><a href="/users/{username}/edit">edit</a></span>
</div> </div>
<div class="account-picture-block">
<img src="{picture}" class="user-profile-picture"/>
</div>
<div class="account-bio-block">
<span class="account-bio-label">email</span>
<span>{email}</span>
<br/>
<span class="account-bio-label">full name</span>
<span>{fullname}</span>
<br/>
<span class="account-bio-label">website</span>
<span><a href="{website}">{website}</a></span>
<br/>
<span class="account-bio-label">location</span>
<span>{location}</span>
<br/>
<span class="account-bio-label">age</span> <div class="row-fluid">
<span>{age}</span> <div class="span3" style="text-align: center; margin-bottom:20px;">
<br/> <div class="account-picture-block">
<img src="{picture}" class="user-profile-picture"/>
<span class="account-bio-label">member for</span> </div>
<span>{joindate}</span> </div>
<br/>
<div class="span9">
<span class="account-bio-label">reputation</span> <div class="inline-block">
<span id='reputation'>{reputation}</span> <div class="account-bio-block">
<br/> <span class="account-bio-label">email</span>
<span>{email}</span>
<span class="account-bio-label">posts</span> <br/>
<span id='postcount'>{postcount}</span>
<span class="account-bio-label">full name</span>
<span>{fullname}</span>
<br/>
<span class="account-bio-label">website</span>
<span><a href="{website}">{website}</a></span>
<br/>
<span class="account-bio-label">location</span>
<span>{location}</span>
<br/>
<span class="account-bio-label">age</span>
<span>{age}</span>
<br/>
<span class="account-bio-label">member for</span>
<span>{joindate}</span>
<br/>
<span class="account-bio-label">reputation</span>
<span id='reputation'>{reputation}</span>
<br/>
<span class="account-bio-label">posts</span>
<span id='postcount'>{postcount}</span>
</div>
</div>
</div>
</div>
<div id="user-actions" class="container">
<a id="add-friend-btn" href="#" class="btn">Add Friend</a>
<a id="send-message-btn" href="#" class="btn">Send Message</a>
</div> </div>
<!-- END user -->
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
var yourid = '{yourid}'; var yourid = '{yourid}';
var theirid = '{theirid}'; var theirid = '{theirid}';
(function() { (function() {
function addCommas(text) { function addCommas(text) {
return text.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,"); return text.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
} }
$(document).ready(function() { $(document).ready(function() {
var rep = $('#reputation'); var rep = $('#reputation');
rep.html(addCommas(rep.html())); rep.html(addCommas(rep.html()));
@ -74,8 +87,31 @@ var theirid = '{theirid}';
postcount.html(addCommas(postcount.html())); postcount.html(addCommas(postcount.html()));
var editLink = $('#editLink'); var editLink = $('#editLink');
if( yourid !== theirid) var addFriendBtn = $('#add-friend-btn');
editLink.addClass('hidden'); var sendMessageBtn = $('#send-message-btn');
if( yourid !== theirid) {
editLink.hide();
addFriendBtn.show();
sendMessageBtn.show();
}
else {
addFriendBtn.hide();
sendMessageBtn.hide();
}
addFriendBtn.on('click', function() {
$.post('/users/addfriend', {uid: theirid},
function(data) {
}
);
return false;
});
sendMessageBtn.on('click', function() {
return false;
});
}); });

@ -80,7 +80,7 @@
<div class="span9"> <div class="span9">
<div class="inline-block"> <div class="inline-block">
<form class='form-horizontal'> <form class='form-horizontal'>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="inputEmail">Email</label> <label class="control-label" for="inputEmail">Email</label>
<div class="controls"> <div class="controls">
<input type="text" id="inputEmail" placeholder="Email" value="{email}"> <input type="text" id="inputEmail" placeholder="Email" value="{email}">
@ -120,7 +120,7 @@
<div class="form-actions"> <div class="form-actions">
<a id="submitBtn" href="" class="btn btn-primary">Save changes</a> <a id="submitBtn" href="" class="btn btn-primary">Save changes</a>
<a href="/users/{username}" class="btn">Cancel</a> <a href="/users/{username}" class="btn">Cancel</a>
</div> </div>
</form> </form>
</div> </div>
@ -136,6 +136,8 @@ var uploadedPicture = '{uploadedpicture}';
$(document).ready(function() { $(document).ready(function() {
$('#uploadForm').submit(function() { $('#uploadForm').submit(function() {
status('uploading the file ...'); status('uploading the file ...');

@ -6,40 +6,24 @@
</ul> </ul>
</div> </div>
<div class="category row"> <div class="category row">
<div class="span3">
<div class="block">
<strong>Top posters in {category_name}</strong>
<img src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/07c9c7170c3ac676c2561e3eeaee063c?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/91050ce0072697b53380c6a03a1bc12a?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/07c9c7170c3ac676c2561e3eeaee063c?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/91050ce0072697b53380c6a03a1bc12a?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/07c9c7170c3ac676c2561e3eeaee063c?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/91050ce0072697b53380c6a03a1bc12a?s=48" class="img-polaroid" />
</div>
</div>
<div class="span9"> <div class="span9">
<ul class="topic-container"> <ul>
<!-- BEGIN topics --> <!-- BEGIN topics -->
<a href="../../topic/{topics.slug}"><li> <a href="../../topic/{topics.slug}"><li>
<div class="row-fluid"> <div class="row-fluid">
<div class="span12 topic-row img-polaroid"> <div class="span12 topic-row img-polaroid">
<div class="top-posters"> <div class="latest-post visible-desktop">
<i class="{topics.pin-icon}"></i><i class="{topics.lock-icon}"></i> <div class="pull-right">
<!--<img src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=50" class="img-polaroid" /> <img src="{topics.recent_picture}?s=50" />
<img src="http://www.gravatar.com/avatar/07c9c7170c3ac676c2561e3eeaee063c?s=50" class="img-polaroid" /> <p><strong>{topics.recent_author}</strong>: {topics.recent_post}</p>
<img src="http://www.gravatar.com/avatar/91050ce0072697b53380c6a03a1bc12a?s=50" class="img-polaroid" />-->
<div class="latest-post pull-right">
<img src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=50" />
<p><strong>psychobunny</strong>: Some post content goes here, the latest posts of course blah blahposts of course blah blahposts of course blah blahposts of course blah blah</p>
</div> </div>
</div> </div>
<div> <div>
<h3><span class="badge {topics.badgeclass}">{topics.post_count}</span> {topics.title} <small>24<i class="icon-star"></i><br />Posted {topics.relativeTime} ago by <h3><span class="badge {topics.badgeclass}">{topics.post_count}</span> {topics.title} <small>24<i class="icon-star"></i><br />
<span class="username">{topics.username}</span>.</small></h3> <strong><i class="{topics.pin-icon}"></i><i class="{topics.lock-icon}"></i></strong>
Posted {topics.relativeTime} ago by
<strong>{topics.username}</strong>.</small></h3>
</div> </div>
</div> </div>
</div> </div>
@ -47,6 +31,40 @@
<!-- END topics --> <!-- END topics -->
</ul> </ul>
</div> </div>
<div class="span3">
<div class="sidebar-block img-polaroid">
<div class="block-header">
Recent Replies
</div>
<div class="block-content">
<img src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/07c9c7170c3ac676c2561e3eeaee063c?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/91050ce0072697b53380c6a03a1bc12a?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/07c9c7170c3ac676c2561e3eeaee063c?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/91050ce0072697b53380c6a03a1bc12a?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/07c9c7170c3ac676c2561e3eeaee063c?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/91050ce0072697b53380c6a03a1bc12a?s=48" class="img-polaroid" />
</div>
</div>
<div class="sidebar-block img-polaroid">
<div class="block-header">
Top posters
</div>
<div class="block-content">
<img src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/07c9c7170c3ac676c2561e3eeaee063c?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/91050ce0072697b53380c6a03a1bc12a?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/07c9c7170c3ac676c2561e3eeaee063c?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/91050ce0072697b53380c6a03a1bc12a?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/07c9c7170c3ac676c2561e3eeaee063c?s=48" class="img-polaroid" />
<img src="http://www.gravatar.com/avatar/91050ce0072697b53380c6a03a1bc12a?s=48" class="img-polaroid" />
</div>
</div>
</div>
</div> </div>

@ -37,6 +37,9 @@
</li> </li>
<li> <li>
<a href="/active">Active</a> <a href="/active">Active</a>
</li>
<li>
<a href="/users">Users</a>
</li> </li>
</ul> </ul>
<ul class="nav pull-right" id="right-menu"> <ul class="nav pull-right" id="right-menu">

@ -223,6 +223,14 @@ marked.setOptions({
RDB.incr('tid:' + tid + ':postcount'); RDB.incr('tid:' + tid + ':postcount');
user.getUserFields(uid, ['username','picture'], function(data){
RDB.set('tid:' + tid + ':recent:post', content);
RDB.set('tid:' + tid + ':recent:author', data.username);
RDB.set('tid:' + tid + ':recent:picture', data.picture);
});
// User Details - move this out later // User Details - move this out later
RDB.lpush('uid:' + uid + ':posts', pid); RDB.lpush('uid:' + uid + ':posts', pid);

@ -183,9 +183,35 @@ var user = require('./../user.js'),
res.send({}); res.send({});
}); });
app.post('/users/addfriend', function(req, res){
if(!req.user)
return res.redirect('/403');
function api_method(req, res) { if(req.user.uid == req.body.uid)
return res.redirect('/');
user.addFriend(req.user.uid, req.body.uid, function(err, data) {
if(err)
res.send({error:err});
else
res.send(data);
});
});
app.get('/users/:username/friends', function(req, res){
if(!req.user)
return res.redirect('/403');
user.get_uid_by_username(req.params.username, function(uid) {
user.getFriends(uid, function(data) {
res.send(JSON.stringify(data, null, 0));
});
});
});
function api_method(req, res) {
console.log("fail "+req.params.section);
var callerUID = req.user?req.user.uid : 0; var callerUID = req.user?req.user.uid : 0;
if (!req.params.section && !req.params.username) { if (!req.params.section && !req.params.username) {
@ -195,6 +221,9 @@ var user = require('./../user.js'),
res.send(JSON.stringify({users:data})); res.send(JSON.stringify({users:data}));
}); });
}
else if(String(req.params.section).toLowerCase() === 'friends') {
} }
else if (String(req.params.section).toLowerCase() === 'edit') { else if (String(req.params.section).toLowerCase() === 'edit') {
getUserDataByUserName(req.params.username, callerUID, function(userData) { getUserDataByUserName(req.params.username, callerUID, function(userData) {
@ -210,6 +239,8 @@ var user = require('./../user.js'),
app.get('/api/users/:username?/:section?', api_method); app.get('/api/users/:username?/:section?', api_method);
function getUserDataByUserName(username, callerUID, callback) { function getUserDataByUserName(username, callerUID, callback) {
user.get_uid_by_username(username, function(uid) { user.get_uid_by_username(username, function(uid) {

@ -27,7 +27,10 @@ var RDB = require('./redis.js'),
postcount = [], postcount = [],
locked = [], locked = [],
deleted = [], deleted = [],
pinned = []; pinned = [],
recent_post = [],
recent_author = [],
recent_picture = [];
for (var i=0, ii=tids.length; i<ii; i++) { for (var i=0, ii=tids.length; i<ii; i++) {
title.push('tid:' + tids[i] + ':title'); title.push('tid:' + tids[i] + ':title');
@ -38,6 +41,9 @@ var RDB = require('./redis.js'),
locked.push('tid:' + tids[i] + ':locked'); locked.push('tid:' + tids[i] + ':locked');
deleted.push('tid:' + tids[i] + ':deleted'); deleted.push('tid:' + tids[i] + ':deleted');
pinned.push('tid:' + tids[i] + ':pinned'); pinned.push('tid:' + tids[i] + ':pinned');
recent_post.push('tid:' + tids[i] + ':recent:post');
recent_author.push('tid:' + tids[i] + ':recent:author');
recent_picture.push('tid:' + tids[i] + ':recent:picture');
} }
var multi = RDB.multi() var multi = RDB.multi()
@ -53,6 +59,9 @@ var RDB = require('./redis.js'),
.mget(locked) .mget(locked)
.mget(deleted) .mget(deleted)
.mget(pinned) .mget(pinned)
.mget(recent_post)
.mget(recent_author)
.mget(recent_picture)
} }
@ -69,6 +78,9 @@ var RDB = require('./redis.js'),
locked = replies[6]; locked = replies[6];
deleted = replies[7]; deleted = replies[7];
pinned = replies[8]; pinned = replies[8];
recent_post = replies[9];
recent_author = replies[10];
recent_picture = replies[11];
var usernames, var usernames,
has_read; has_read;
@ -76,6 +88,7 @@ var RDB = require('./redis.js'),
function generate_topic() { function generate_topic() {
if (!usernames || !has_read) return; if (!usernames || !has_read) return;
for (var i=0, ii=title.length; i<ii; i++) { for (var i=0, ii=title.length; i<ii; i++) {
topics.push({ topics.push({
'title' : title[i], 'title' : title[i],
@ -89,7 +102,10 @@ var RDB = require('./redis.js'),
'deleted': deleted[i], 'deleted': deleted[i],
'pinned': parseInt(pinned[i] || 0), // For sorting purposes 'pinned': parseInt(pinned[i] || 0), // For sorting purposes
'pin-icon': pinned[i] === '1' ? 'icon-pushpin' : 'none', 'pin-icon': pinned[i] === '1' ? 'icon-pushpin' : 'none',
'badgeclass' : (has_read[i] && current_user !=0) ? '' : 'badge-important' 'badgeclass' : (has_read[i] && current_user !=0) ? '' : 'badge-important',
'recent_post' : recent_post[i],
'recent_author' : recent_author[i],
'recent_picture' : recent_picture[i]
}); });
} }

@ -102,8 +102,12 @@ var config = require('../config.js'),
RDB.keys('user:*', function(err, userkeys){ RDB.keys('user:*', function(err, userkeys){
for(var i=0,ii=userkeys.length; i<ii; ++i) { var anonUserIndex = userkeys.indexOf("user:0");
if(anonUserIndex !== -1) {
userkeys.splice(anonUserIndex, 1);
}
for(var i=0,ii=userkeys.length; i<ii; ++i) {
RDB.hgetall(userkeys[i], function(err, userdata) { RDB.hgetall(userkeys[i], function(err, userdata) {
if(userdata && userdata.password) if(userdata && userdata.password)
@ -115,7 +119,6 @@ var config = require('../config.js'),
callback(data); callback(data);
}); });
} }
}); });
} }
@ -351,6 +354,23 @@ var config = require('../config.js'),
}); });
} }
User.addFriend = function(uid, friendid, callback) {
RDB.sadd('user:'+uid+':friends', friendid, function(err, data){
if(err === null)
callback(data);
else
console.log(err);
})
}
User.getFriends = function(uid, callback) {
RDB.smembers('user:'+uid+':friends', function(err, data){
if(err === null)
callback(data);
else
console.log(err);
});
}
User.exists = function(username, callback) { User.exists = function(username, callback) {
User.get_uid_by_username(username, function(exists) { User.get_uid_by_username(username, function(exists) {

Loading…
Cancel
Save