mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
Merge branch 'master' of github.com:psychobunny/NodeBB
This commit is contained in:
@@ -122,49 +122,95 @@ footer.footer {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.category {
|
||||
.block {
|
||||
strong {
|
||||
margin-bottom: 10px;
|
||||
display: block
|
||||
.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;
|
||||
|
||||
}
|
||||
border: 1px solid #eee;
|
||||
background: white;
|
||||
.block-content {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
border-radius: 5px;
|
||||
background: white;
|
||||
padding: 0;
|
||||
margin-bottom: 20px;
|
||||
|
||||
.img-polaroid {
|
||||
margin-top: 2px;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.category {
|
||||
a {
|
||||
li {
|
||||
list-style: none;
|
||||
border-bottom: 1px solid #eee;
|
||||
margin-bottom: 10px;
|
||||
padding-bottom: 10px;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@media (max-width: 767px)
|
||||
{
|
||||
.topic-row-icon {
|
||||
border-radius: 5px 5px 0 0;
|
||||
&:last-child li {
|
||||
border-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.top-posters {
|
||||
color: #333;
|
||||
&:hover {
|
||||
color: #333
|
||||
}
|
||||
}
|
||||
|
||||
ul {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
|
||||
.topic-row {
|
||||
border-radius: 5px;
|
||||
width: 100%;
|
||||
padding-left: 20px;
|
||||
|
||||
h3 {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
margin-top: 4px;
|
||||
line-height: 30px;
|
||||
color: rgb(0, 136, 204);
|
||||
|
||||
small {
|
||||
vertical-align: 2px;
|
||||
strong {
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.latest-post {
|
||||
float: right;
|
||||
padding-top: 2px;
|
||||
margin-right: 30px;
|
||||
width: 50%;
|
||||
|
||||
div.latest-post {
|
||||
.pull-right {
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
line-height: 16px;
|
||||
margin-left: 1px;
|
||||
padding: 5px;
|
||||
border-left: 1px solid #bbb;
|
||||
padding-left: 20px;
|
||||
|
||||
img {
|
||||
display: block;
|
||||
float: left;
|
||||
@@ -172,34 +218,16 @@ footer.footer {
|
||||
p {
|
||||
display: block;
|
||||
float: left;
|
||||
width: 400px;
|
||||
width: 70%;
|
||||
margin-left: 10px;
|
||||
overflow: hidden;
|
||||
height: 50px;
|
||||
}
|
||||
}
|
||||
.latest-post {
|
||||
margin-left: 1px;
|
||||
border: 1px solid rgba(0,0,0,0.05);
|
||||
padding: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.topic-row {
|
||||
width: 100%;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.topic-row h3 {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
margin-top: 4px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
.topic-row h3 small {
|
||||
vertical-align: 3px;
|
||||
}
|
||||
|
||||
.post-container {
|
||||
list-style-type: none;
|
||||
|
||||
@@ -12,10 +12,16 @@
|
||||
<span id="editLink" class="pull-right"><a href="/users/{username}/edit">edit</a></span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span3" style="text-align: center; margin-bottom:20px;">
|
||||
<div class="account-picture-block">
|
||||
<img src="{picture}" class="user-profile-picture"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="span9">
|
||||
<div class="inline-block">
|
||||
<div class="account-bio-block">
|
||||
<span class="account-bio-label">email</span>
|
||||
<span>{email}</span>
|
||||
@@ -48,25 +54,32 @@
|
||||
<span class="account-bio-label">posts</span>
|
||||
<span id='postcount'>{postcount}</span>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- END user -->
|
||||
|
||||
|
||||
|
||||
</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>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var yourid = '{yourid}';
|
||||
var theirid = '{theirid}';
|
||||
|
||||
|
||||
|
||||
(function() {
|
||||
|
||||
|
||||
|
||||
function addCommas(text) {
|
||||
return text.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var rep = $('#reputation');
|
||||
rep.html(addCommas(rep.html()));
|
||||
|
||||
@@ -74,8 +87,31 @@ var theirid = '{theirid}';
|
||||
postcount.html(addCommas(postcount.html()));
|
||||
|
||||
var editLink = $('#editLink');
|
||||
if( yourid !== theirid)
|
||||
editLink.addClass('hidden');
|
||||
var addFriendBtn = $('#add-friend-btn');
|
||||
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;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -136,6 +136,8 @@ var uploadedPicture = '{uploadedpicture}';
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
|
||||
$('#uploadForm').submit(function() {
|
||||
status('uploading the file ...');
|
||||
|
||||
|
||||
@@ -6,40 +6,24 @@
|
||||
</ul>
|
||||
</div>
|
||||
<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">
|
||||
<ul class="topic-container">
|
||||
<ul>
|
||||
<!-- BEGIN topics -->
|
||||
<a href="../../topic/{topics.slug}"><li>
|
||||
<div class="row-fluid">
|
||||
<div class="span12 topic-row img-polaroid">
|
||||
<div class="top-posters">
|
||||
<i class="{topics.pin-icon}"></i><i class="{topics.lock-icon}"></i>
|
||||
<!--<img src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=50" class="img-polaroid" />
|
||||
<img src="http://www.gravatar.com/avatar/07c9c7170c3ac676c2561e3eeaee063c?s=50" class="img-polaroid" />
|
||||
<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 class="latest-post visible-desktop">
|
||||
<div class="pull-right">
|
||||
<img src="{topics.recent_picture}?s=50" />
|
||||
<p><strong>{topics.recent_author}</strong>: {topics.recent_post}</p>
|
||||
</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
|
||||
<span class="username">{topics.username}</span>.</small></h3>
|
||||
<h3><span class="badge {topics.badgeclass}">{topics.post_count}</span> {topics.title} <small>24<i class="icon-star"></i><br />
|
||||
<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>
|
||||
@@ -47,6 +31,40 @@
|
||||
<!-- END topics -->
|
||||
</ul>
|
||||
</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>
|
||||
|
||||
|
||||
|
||||
@@ -37,6 +37,9 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="/active">Active</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/users">Users</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav pull-right" id="right-menu">
|
||||
|
||||
@@ -223,6 +223,14 @@ marked.setOptions({
|
||||
|
||||
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
|
||||
RDB.lpush('uid:' + uid + ':posts', pid);
|
||||
|
||||
|
||||
@@ -183,9 +183,35 @@ var user = require('./../user.js'),
|
||||
res.send({});
|
||||
});
|
||||
|
||||
app.post('/users/addfriend', function(req, res){
|
||||
if(!req.user)
|
||||
return res.redirect('/403');
|
||||
|
||||
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;
|
||||
|
||||
if (!req.params.section && !req.params.username) {
|
||||
@@ -195,6 +221,9 @@ var user = require('./../user.js'),
|
||||
res.send(JSON.stringify({users:data}));
|
||||
|
||||
});
|
||||
}
|
||||
else if(String(req.params.section).toLowerCase() === 'friends') {
|
||||
|
||||
}
|
||||
else if (String(req.params.section).toLowerCase() === 'edit') {
|
||||
getUserDataByUserName(req.params.username, callerUID, function(userData) {
|
||||
@@ -210,6 +239,8 @@ var user = require('./../user.js'),
|
||||
|
||||
app.get('/api/users/:username?/:section?', api_method);
|
||||
|
||||
|
||||
|
||||
function getUserDataByUserName(username, callerUID, callback) {
|
||||
|
||||
user.get_uid_by_username(username, function(uid) {
|
||||
|
||||
@@ -27,7 +27,10 @@ var RDB = require('./redis.js'),
|
||||
postcount = [],
|
||||
locked = [],
|
||||
deleted = [],
|
||||
pinned = [];
|
||||
pinned = [],
|
||||
recent_post = [],
|
||||
recent_author = [],
|
||||
recent_picture = [];
|
||||
|
||||
for (var i=0, ii=tids.length; i<ii; i++) {
|
||||
title.push('tid:' + tids[i] + ':title');
|
||||
@@ -38,6 +41,9 @@ var RDB = require('./redis.js'),
|
||||
locked.push('tid:' + tids[i] + ':locked');
|
||||
deleted.push('tid:' + tids[i] + ':deleted');
|
||||
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()
|
||||
@@ -53,6 +59,9 @@ var RDB = require('./redis.js'),
|
||||
.mget(locked)
|
||||
.mget(deleted)
|
||||
.mget(pinned)
|
||||
.mget(recent_post)
|
||||
.mget(recent_author)
|
||||
.mget(recent_picture)
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +78,9 @@ var RDB = require('./redis.js'),
|
||||
locked = replies[6];
|
||||
deleted = replies[7];
|
||||
pinned = replies[8];
|
||||
recent_post = replies[9];
|
||||
recent_author = replies[10];
|
||||
recent_picture = replies[11];
|
||||
|
||||
var usernames,
|
||||
has_read;
|
||||
@@ -76,6 +88,7 @@ var RDB = require('./redis.js'),
|
||||
function generate_topic() {
|
||||
if (!usernames || !has_read) return;
|
||||
|
||||
|
||||
for (var i=0, ii=title.length; i<ii; i++) {
|
||||
topics.push({
|
||||
'title' : title[i],
|
||||
@@ -89,7 +102,10 @@ var RDB = require('./redis.js'),
|
||||
'deleted': deleted[i],
|
||||
'pinned': parseInt(pinned[i] || 0), // For sorting purposes
|
||||
'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]
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
24
src/user.js
24
src/user.js
@@ -102,8 +102,12 @@ var config = require('../config.js'),
|
||||
|
||||
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) {
|
||||
|
||||
if(userdata && userdata.password)
|
||||
@@ -115,7 +119,6 @@ var config = require('../config.js'),
|
||||
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.get_uid_by_username(username, function(exists) {
|
||||
|
||||
Reference in New Issue
Block a user