mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
Merge branch 'master' of github.com:psychobunny/node-forum
This commit is contained in:
@@ -142,7 +142,9 @@ footer.footer {
|
|||||||
|
|
||||||
.profile-image-block {
|
.profile-image-block {
|
||||||
background: white;
|
background: white;
|
||||||
|
display: inline-block;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
li {
|
li {
|
||||||
padding-bottom: 15px;
|
padding-bottom: 15px;
|
||||||
@@ -170,16 +172,12 @@ footer.footer {
|
|||||||
padding: 5px;
|
padding: 5px;
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
}
|
}
|
||||||
|
.post-content {
|
||||||
|
min-height: 50px;
|
||||||
|
padding: 2px 5px 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
.post-block {
|
.post-block {
|
||||||
|
|
||||||
.caret {
|
|
||||||
margin-top: -10px;
|
|
||||||
margin-left: -18px;
|
|
||||||
display: block;
|
|
||||||
border-width: 8px 8px 8px 0;
|
|
||||||
border-color: transparent #ddd transparent;
|
|
||||||
}
|
|
||||||
.post-buttons {
|
.post-buttons {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
float: right;
|
float: right;
|
||||||
@@ -199,9 +197,6 @@ footer.footer {
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
li:last-child {
|
|
||||||
border-bottom: 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#user_label {
|
#user_label {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ var templates = {};
|
|||||||
|
|
||||||
templates.ready = function(callback) {
|
templates.ready = function(callback) {
|
||||||
//quick implementation because introducing a lib to handle several async callbacks
|
//quick implementation because introducing a lib to handle several async callbacks
|
||||||
if (callback == null) ready_callback();
|
if (callback == null && ready_callback) ready_callback();
|
||||||
else ready_callback = callback;
|
else ready_callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
18
public/templates/account.tpl
Normal file
18
public/templates/account.tpl
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<h1>Account Settings</h1>
|
||||||
|
<div class="well">
|
||||||
|
<div class="alert" id="message" style="display:none">
|
||||||
|
<button type="button" class="close" data-dismiss="message">×</button>
|
||||||
|
<strong></strong>
|
||||||
|
<p></p>
|
||||||
|
</div>
|
||||||
|
<label for="email">Email Address</label><input type="text" placeholder="Enter Email Address" id="email" /><br />
|
||||||
|
<button class="btn btn-primary" id="reset" type="submit">Reset Password</button>
|
||||||
|
<p>
|
||||||
|
If you see this, you are logged in.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
(function() {
|
||||||
|
// ...
|
||||||
|
}());
|
||||||
|
</script>
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
<li class="active"><a href="/">Forum</a></li>
|
<li class="active"><a href="/">Forum</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="nav pull-right" id="right-menu">
|
<ul class="nav pull-right" id="right-menu">
|
||||||
<li><a href="#" id="user_label"></a></li>
|
<li><a href="/account" id="user_label"></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<!-- BEGIN topics -->
|
<!-- BEGIN topics -->
|
||||||
<a href="topic/{topics.slug}"><li class="topic-row">
|
<a href="topic/{topics.slug}"><li class="topic-row">
|
||||||
<h4>{topics.title}</h4>
|
<h4>{topics.title}</h4>
|
||||||
<p>Posted {topics.relativeTime} by <span class="username">{topics.uid}</span>. {topics.post_count} posts.</p>
|
<p>Posted {topics.relativeTime} by <span class="username">{topics.username}</span>. {topics.post_count} posts.</p>
|
||||||
</li></a>
|
</li></a>
|
||||||
<!-- END topics -->
|
<!-- END topics -->
|
||||||
</ul>
|
</ul>
|
||||||
@@ -14,20 +14,6 @@ new_post.onclick = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
jQuery('document').ready(function() {
|
jQuery('document').ready(function() {
|
||||||
jQuery('.username').each(function() {
|
|
||||||
var userId = this.innerHTML;
|
|
||||||
|
|
||||||
(function(span){
|
|
||||||
socket.on('api:user.getNameByUid', function(username) {
|
|
||||||
span.innerHTML = username;
|
|
||||||
});
|
|
||||||
})(this);
|
|
||||||
|
|
||||||
socket.emit('api:user.getNameByUid', { fields: [ 'username' ], 'uid': userId });
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<ul class="breadcrumb">
|
<ul class="breadcrumb">
|
||||||
<li><a href="/">Home</a> <span class="divider">/</span></li>
|
<li><a href="/">Home</a> <span class="divider">/</span></li>
|
||||||
<li class="active">{TOPIC_NAME}</li>
|
<li class="active">{topic_name}</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -9,20 +9,18 @@
|
|||||||
<!-- BEGIN posts -->
|
<!-- BEGIN posts -->
|
||||||
<li class="row">
|
<li class="row">
|
||||||
<div class="span1 profile-image-block">
|
<div class="span1 profile-image-block">
|
||||||
|
<!--<i class="icon-spinner icon-spin icon-2x pull-left"></i>-->
|
||||||
<img src="https://en.gravatar.com/userimage/18452752/f59e713c717466d2f5ad2a6970769f32.png" align="left" />
|
<img src="https://en.gravatar.com/userimage/18452752/f59e713c717466d2f5ad2a6970769f32.png" align="left" />
|
||||||
|
<i class="icon-star"></i>2432
|
||||||
</div>
|
</div>
|
||||||
<div class="span11">
|
<div class="span11">
|
||||||
<div class="post-block">
|
<div class="post-block">
|
||||||
|
<div id="content_{posts.pid}" class="post-content">{posts.content}</div>
|
||||||
|
|
||||||
<p>{posts.content}</p>
|
|
||||||
<!--<p>Posted {posts.relativeTime} by user {posts.uid}.</p>-->
|
<!--<p>Posted {posts.relativeTime} by user {posts.uid}.</p>-->
|
||||||
<div class="profile-block">
|
<div class="profile-block">
|
||||||
posted by <strong>psychobunny</strong> {posts.relativeTime}
|
posted by <strong>{posts.userName}</strong> {posts.relativeTime}
|
||||||
<span class="post-buttons">
|
<span class="post-buttons">
|
||||||
<div class="quote"><i class="icon-quote-left"></i></div>
|
<div id="quote_{posts.pid}" class="quote"><i class="icon-quote-left"></i></div>
|
||||||
<div class="favourite"><i class="icon-star-empty"></i></div>
|
<div class="favourite"><i class="icon-star-empty"></i></div>
|
||||||
<div class="post_reply">Reply <i class="icon-reply"></i></div>
|
<div class="post_reply">Reply <i class="icon-reply"></i></div>
|
||||||
</span>
|
</span>
|
||||||
@@ -38,11 +36,14 @@
|
|||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery('.post_reply').click(function() {
|
jQuery('.post_reply').click(function() {
|
||||||
app.open_post_window('reply', "{TOPIC_ID}", "{TOPIC_NAME}");
|
app.open_post_window('reply', "{topic_id}", "{topic_name}");
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery('.quote').click(function() {
|
jQuery('.quote').click(function() {
|
||||||
app.open_post_window('quote', "{TOPIC_ID}", "{TOPIC_NAME}");
|
app.open_post_window('quote', "{topic_id}", "{topic_name}");
|
||||||
|
|
||||||
|
// this needs to be looked at, obviously. only single line quotes work well I think maybe replace all \r\n with > ?
|
||||||
|
document.getElementById('post_content').innerHTML = '> ' + document.getElementById('content_' + this.id.replace('quote_', '')).innerHTML;
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery('.favourite').click(function() {
|
jQuery('.favourite').click(function() {
|
||||||
|
|||||||
13
src/posts.js
13
src/posts.js
@@ -1,6 +1,7 @@
|
|||||||
var RDB = require('./redis.js'),
|
var RDB = require('./redis.js'),
|
||||||
utils = require('./utils.js'),
|
utils = require('./utils.js'),
|
||||||
marked = require('marked');
|
marked = require('marked'),
|
||||||
|
user = require('./user.js');
|
||||||
|
|
||||||
(function(Posts) {
|
(function(Posts) {
|
||||||
//data structure
|
//data structure
|
||||||
@@ -21,12 +22,14 @@ var RDB = require('./redis.js'),
|
|||||||
RDB.lrange('tid:' + tid + ':posts', start, end, function(pids) {
|
RDB.lrange('tid:' + tid + ':posts', start, end, function(pids) {
|
||||||
var content = [],
|
var content = [],
|
||||||
uid = [],
|
uid = [],
|
||||||
timestamp = [];
|
timestamp = [],
|
||||||
|
pid = [];
|
||||||
|
|
||||||
for (var i=0, ii=pids.length; i<ii; i++) {
|
for (var i=0, ii=pids.length; i<ii; i++) {
|
||||||
content.push('pid:' + pids[i] + ':content');
|
content.push('pid:' + pids[i] + ':content');
|
||||||
uid.push('pid:' + pids[i] + ':uid');
|
uid.push('pid:' + pids[i] + ':uid');
|
||||||
timestamp.push('pid:' + pids[i] + ':timestamp');
|
timestamp.push('pid:' + pids[i] + ':timestamp');
|
||||||
|
pid.push(pids[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pids.length > 0) {
|
if (pids.length > 0) {
|
||||||
@@ -39,17 +42,21 @@ var RDB = require('./redis.js'),
|
|||||||
uid = replies[1];
|
uid = replies[1];
|
||||||
timestamp = replies[2];
|
timestamp = replies[2];
|
||||||
|
|
||||||
|
user.get_usernames_by_uids(uid, function(userNames) {
|
||||||
var posts = [];
|
var posts = [];
|
||||||
for (var i=0, ii=content.length; i<ii; i++) {
|
for (var i=0, ii=content.length; i<ii; i++) {
|
||||||
posts.push({
|
posts.push({
|
||||||
|
'pid' : pid[i],
|
||||||
'content' : marked(content[i]),
|
'content' : marked(content[i]),
|
||||||
'uid' : uid[i],
|
'uid' : uid[i],
|
||||||
|
'userName' : userNames[i] || 'anonymous',
|
||||||
'timestamp' : timestamp[i],
|
'timestamp' : timestamp[i],
|
||||||
'relativeTime': utils.relativeTime(timestamp[i])
|
'relativeTime': utils.relativeTime(timestamp[i])
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
callback({'TOPIC_NAME':topic_name, 'TOPIC_ID': tid, 'posts': posts});
|
callback({'topic_name':topic_name, 'topic_id': tid, 'posts': posts});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
callback({});
|
callback({});
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
Templates.init = function() {
|
Templates.init = function() {
|
||||||
loadTemplates([
|
loadTemplates([
|
||||||
'header', 'footer', 'register', 'home', 'topic',
|
'header', 'footer', 'register', 'home', 'topic', 'account',
|
||||||
'login', 'reset', 'reset_code', 'logout',
|
'login', 'reset', 'reset_code', 'logout',
|
||||||
'403',
|
'403',
|
||||||
'emails/reset', 'emails/reset_plaintext'
|
'emails/reset', 'emails/reset_plaintext'
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
var RDB = require('./redis.js'),
|
var RDB = require('./redis.js'),
|
||||||
posts = require('./posts.js'),
|
posts = require('./posts.js'),
|
||||||
utils = require('./utils.js');
|
utils = require('./utils.js'),
|
||||||
|
user = require('./user.js');
|
||||||
|
|
||||||
(function(Topics) {
|
(function(Topics) {
|
||||||
//data structure
|
//data structure
|
||||||
@@ -68,17 +69,22 @@ var RDB = require('./redis.js'),
|
|||||||
.mget(slug)
|
.mget(slug)
|
||||||
.mget(postcount)
|
.mget(postcount)
|
||||||
.exec(function(err, replies) {
|
.exec(function(err, replies) {
|
||||||
|
|
||||||
title = replies[0];
|
title = replies[0];
|
||||||
uid = replies[1];
|
uid = replies[1];
|
||||||
timestamp = replies[2];
|
timestamp = replies[2];
|
||||||
slug = replies[3];
|
slug = replies[3];
|
||||||
postcount = replies[4];
|
postcount = replies[4];
|
||||||
|
|
||||||
|
user.get_usernames_by_uids(uid, function(userNames) {
|
||||||
var topics = [];
|
var topics = [];
|
||||||
|
|
||||||
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],
|
||||||
'uid' : uid[i],
|
'uid' : uid[i],
|
||||||
|
'username': userNames[i],
|
||||||
'timestamp' : timestamp[i],
|
'timestamp' : timestamp[i],
|
||||||
'relativeTime': utils.relativeTime(timestamp[i]),
|
'relativeTime': utils.relativeTime(timestamp[i]),
|
||||||
'slug' : slug[i],
|
'slug' : slug[i],
|
||||||
@@ -87,6 +93,9 @@ var RDB = require('./redis.js'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
callback({'topics': topics});
|
callback({'topics': topics});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else callback([]);
|
} else callback([]);
|
||||||
|
|||||||
11
src/user.js
11
src/user.js
@@ -264,6 +264,17 @@ var config = require('../config.js'),
|
|||||||
RDB.get('uid:' + uid+ ':username', callback);
|
RDB.get('uid:' + uid+ ':username', callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
User.get_usernames_by_uids = function(uids, callback) {
|
||||||
|
var userIds = [];
|
||||||
|
for(var i=0, ii=uids.length; i<ii; i++) {
|
||||||
|
userIds.push('uid:' + uids[i] + ':username');
|
||||||
|
}
|
||||||
|
|
||||||
|
RDB.mget(userIds, function(data) {
|
||||||
|
callback(data);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
User.get_uid_by_email = function(email, callback) {
|
User.get_uid_by_email = function(email, callback) {
|
||||||
RDB.get('email:' + email, callback)
|
RDB.get('email:' + email, callback)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -78,14 +78,6 @@ passport.deserializeUser(function(uid, done) {
|
|||||||
(function(app) {
|
(function(app) {
|
||||||
var templates = global.templates;
|
var templates = global.templates;
|
||||||
|
|
||||||
function refreshTemplates() {
|
|
||||||
//need a better solution than copying this code on every call. is there an "onconnect" event?
|
|
||||||
if (DEVELOPMENT === true) {
|
|
||||||
// refreshing templates
|
|
||||||
modules.templates.init();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Middlewares
|
// Middlewares
|
||||||
app.use(express.favicon()); // 2 args: string path and object options (i.e. expire time etc)
|
app.use(express.favicon()); // 2 args: string path and object options (i.e. expire time etc)
|
||||||
app.use(require('less-middleware')({ src: path.join(__dirname, '../', '/public') }));
|
app.use(require('less-middleware')({ src: path.join(__dirname, '../', '/public') }));
|
||||||
@@ -259,8 +251,11 @@ passport.deserializeUser(function(uid, done) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.get('/account', function(req, res) {
|
app.get('/account', function(req, res) {
|
||||||
refreshTemplates();
|
|
||||||
res.send(templates['header'] + templates['account_settings'] + templates['footer']);
|
if (req.user === undefined)
|
||||||
|
return res.redirect('/403');
|
||||||
|
|
||||||
|
res.send(templates['header'] + templates['account'] + templates['footer']);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/users', function(req, res) {
|
app.get('/users', function(req, res) {
|
||||||
|
|||||||
Reference in New Issue
Block a user