mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 15:05:46 +01:00
Merge remote-tracking branch 'origin'
This commit is contained in:
@@ -324,6 +324,7 @@ footer.footer {
|
|||||||
|
|
||||||
.account-username-box{
|
.account-username-box{
|
||||||
border-bottom:1px solid #e3e3e3;
|
border-bottom:1px solid #e3e3e3;
|
||||||
|
margin-bottom:10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.account-username{
|
.account-username{
|
||||||
@@ -334,6 +335,7 @@ footer.footer {
|
|||||||
.account-picture-block{
|
.account-picture-block{
|
||||||
display:inline-block;
|
display:inline-block;
|
||||||
margin-right:20px;
|
margin-right:20px;
|
||||||
|
vertical-align:top;
|
||||||
}
|
}
|
||||||
|
|
||||||
.account-bio-block{
|
.account-bio-block{
|
||||||
@@ -347,7 +349,6 @@ footer.footer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.category-icon {
|
.category-icon {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 90px;
|
height: 90px;
|
||||||
|
|||||||
@@ -31,8 +31,12 @@ var ajaxify = {};
|
|||||||
app.enter_room('global');
|
app.enter_room('global');
|
||||||
|
|
||||||
var url = url.replace(/\/$/, "");
|
var url = url.replace(/\/$/, "");
|
||||||
var tpl_url = (url === '' || url === '/') ? 'home' : url.split('/')[0];
|
|
||||||
tpl_url = templates.get_custom_map(tpl_url);
|
var tpl_url = templates.get_custom_map(url);
|
||||||
|
|
||||||
|
if (tpl_url == false) {
|
||||||
|
tpl_url = (url === '' || url === '/') ? 'home' : url.split('/')[0];
|
||||||
|
}
|
||||||
|
|
||||||
if (templates[tpl_url]) {
|
if (templates[tpl_url]) {
|
||||||
window.history.pushState({}, url, "/" + url);
|
window.history.pushState({}, url, "/" + url);
|
||||||
|
|||||||
@@ -5,7 +5,14 @@ var templates = {};
|
|||||||
config = {};
|
config = {};
|
||||||
|
|
||||||
templates.get_custom_map = function(tpl) {
|
templates.get_custom_map = function(tpl) {
|
||||||
return (config['custom_mapping'] && config['custom_mapping'][tpl]) ? config['custom_mapping'][tpl] : tpl;
|
if (config['custom_mapping'] && tpl) {
|
||||||
|
for (var pattern in config['custom_mapping']) {
|
||||||
|
if (tpl.match(pattern)) {
|
||||||
|
return (config['custom_mapping'][pattern]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
templates.ready = function(callback) {
|
templates.ready = function(callback) {
|
||||||
@@ -58,7 +65,7 @@ var templates = {};
|
|||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
loadTemplates([
|
loadTemplates([
|
||||||
'header', 'footer', 'register', 'home', 'topic','account', 'category', 'users',
|
'header', 'footer', 'register', 'home', 'topic','account', 'category', 'users', 'accountedit',
|
||||||
'login', 'reset', 'reset_code', 'account',
|
'login', 'reset', 'reset_code', 'account',
|
||||||
'confirm',
|
'confirm',
|
||||||
'emails/reset', 'emails/reset_plaintext', 'emails/email_confirm', 'emails/email_confirm_plaintext'
|
'emails/reset', 'emails/reset_plaintext', 'emails/email_confirm', 'emails/email_confirm_plaintext'
|
||||||
@@ -137,6 +144,11 @@ var templates = {};
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (namespace) {
|
||||||
|
var regex = new RegExp("{" + namespace + "[^]*?}", 'g');
|
||||||
|
template = template.replace(regex, '');
|
||||||
|
}
|
||||||
|
|
||||||
return template;
|
return template;
|
||||||
|
|
||||||
})(data, "", template);
|
})(data, "", template);
|
||||||
@@ -156,18 +168,15 @@ function load_template(callback, custom_tpl) {
|
|||||||
|
|
||||||
|
|
||||||
jQuery.get(API_URL + url, function(data) {
|
jQuery.get(API_URL + url, function(data) {
|
||||||
|
var tpl = templates.get_custom_map(url);
|
||||||
var splits = url.split('/');
|
if (tpl == false) {
|
||||||
var tpl = url;
|
tpl = url.split('/')[0];
|
||||||
|
|
||||||
if(splits.length) {
|
|
||||||
tpl = splits[0];
|
|
||||||
tpl = templates.get_custom_map(tpl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (custom_tpl && custom_tpl != "undefined")
|
if (custom_tpl && custom_tpl != "undefined")
|
||||||
tpl = custom_tpl;
|
tpl = custom_tpl;
|
||||||
|
|
||||||
|
|
||||||
document.getElementById('content').innerHTML = templates[tpl].parse(JSON.parse(data));
|
document.getElementById('content').innerHTML = templates[tpl].parse(JSON.parse(data));
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,10 +9,9 @@
|
|||||||
<!-- BEGIN user -->
|
<!-- BEGIN user -->
|
||||||
|
|
||||||
<div class="account-username-box">
|
<div class="account-username-box">
|
||||||
<span class="account-username">{user.username}</span>
|
<span class="account-username"><a href="/users/{user.username}">{user.username}</a></span>
|
||||||
<span class="pull-right"><a href="/users/{user.username}/edit">edit</a></span>
|
<span class="pull-right"><a href="/users/{user.username}/edit">edit</a></span>
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
|
||||||
|
|
||||||
<div class="account-picture-block">
|
<div class="account-picture-block">
|
||||||
<img src="{user.picture}?s=128" />
|
<img src="{user.picture}?s=128" />
|
||||||
@@ -21,6 +20,22 @@
|
|||||||
<div class="account-bio-block">
|
<div class="account-bio-block">
|
||||||
<span class="account-bio-label">email</span>
|
<span class="account-bio-label">email</span>
|
||||||
<span>{user.email}</span>
|
<span>{user.email}</span>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<span class="account-bio-label">full name</span>
|
||||||
|
<span>{user.fullname}</span>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<span class="account-bio-label">website</span>
|
||||||
|
<span><a href="{user.website}">{user.website}</a></span>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<span class="account-bio-label">location</span>
|
||||||
|
<span>{user.location}</span>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<span class="account-bio-label">age</span>
|
||||||
|
<span>{user.age}</span>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<span class="account-bio-label">member for</span>
|
<span class="account-bio-label">member for</span>
|
||||||
@@ -28,18 +43,14 @@
|
|||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<span class="account-bio-label">reputation</span>
|
<span class="account-bio-label">reputation</span>
|
||||||
<span>{user.reputation}</span>
|
<span id='reputation'>{user.reputation}</span>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<span class="account-bio-label">posts</span>
|
<span class="account-bio-label">posts</span>
|
||||||
<span>{user.postcount}</span>
|
<span id='postcount'>{user.postcount}</span>
|
||||||
</div>
|
</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>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- END user -->
|
<!-- END user -->
|
||||||
|
|
||||||
|
|
||||||
@@ -47,6 +58,20 @@
|
|||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
(function() {
|
(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()));
|
||||||
|
|
||||||
|
var postcount = $('#postcount');
|
||||||
|
postcount.html(addCommas(postcount.html()));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}());
|
}());
|
||||||
</script>
|
</script>
|
||||||
@@ -8,12 +8,62 @@
|
|||||||
|
|
||||||
<!-- BEGIN user -->
|
<!-- BEGIN user -->
|
||||||
|
|
||||||
|
<div class="account-username-box">
|
||||||
|
<span class="account-username"><a href="/users/{user.username}">{user.username}</a></span>
|
||||||
|
<span class="pull-right"><a href="/users/{user.username}/edit">edit</a></span>
|
||||||
|
</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>
|
<div class="account-picture-block">
|
||||||
|
<img src="{user.picture}?s=128" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="inline-block">
|
||||||
|
<form class='form-horizontal'>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="inputEmail">Email</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" id="inputEmail" placeholder="Email" value="{user.email}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="inputFullname">Full Name</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" id="inputFullname" placeholder="Full Name" value="{user.fullname}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="inputWebsite">Website</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" id="inputWebsite" placeholder="http://website.com" value="{user.website}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="inputLocation">Location</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" id="inputLocation" placeholder="Location" value="{user.location}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="inputBirthday">Birthday</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" id="inputBirthday" placeholder="dd/mm/yyyy" value="{user.birthday}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-actions">
|
||||||
|
<a id="submitBtn" href="" class="btn btn-primary">Save changes</a>
|
||||||
|
<a href="/users/{user.username}" class="btn">Cancel</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
<!-- END user -->
|
<!-- END user -->
|
||||||
|
|
||||||
|
|
||||||
@@ -21,6 +71,27 @@
|
|||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
(function() {
|
(function() {
|
||||||
// ...
|
$(document).ready(function(){
|
||||||
|
|
||||||
|
$('#submitBtn').on('click',function(){
|
||||||
|
|
||||||
|
var userData = {
|
||||||
|
email:$('#inputEmail').val(),
|
||||||
|
fullname:$('#inputFullname').val(),
|
||||||
|
website:$('#inputWebsite').val(),
|
||||||
|
birthday:$('#inputBirthday').val(),
|
||||||
|
location:$('#inputLocation').val()
|
||||||
|
};
|
||||||
|
|
||||||
|
$.post('/edituser',
|
||||||
|
userData,
|
||||||
|
function(data) {
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
</script>
|
</script>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"custom_mapping": {
|
"custom_mapping": {
|
||||||
|
"users[^]*edit": "accountedit",
|
||||||
"users": "account",
|
"users": "account",
|
||||||
"latest": "category",
|
"latest": "category",
|
||||||
"popular": "category",
|
"popular": "category",
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="nav pull-right" id="right-menu">
|
<ul class="nav pull-right" id="right-menu">
|
||||||
<li><i class="icon-plus icon-2x" style="color:#999;"></i></li>
|
<!--<li><i class="icon-plus icon-2x" style="color:#999;"></i></li> fail. add this back later -->
|
||||||
<li><a href="/users" id="user_label"></a></li>
|
<li><a href="/users" id="user_label"></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -11,11 +11,11 @@
|
|||||||
<a href="/users/{users.username}">{users.username}</a>
|
<a href="/users/{users.username}">{users.username}</a>
|
||||||
<br/>
|
<br/>
|
||||||
<div title="reputation">
|
<div title="reputation">
|
||||||
<span>{users.reputation}</span>
|
<span id='reputation'>{users.reputation}</span>
|
||||||
<i class='icon-star'></i>
|
<i class='icon-star'></i>
|
||||||
</div>
|
</div>
|
||||||
<div title="post count">
|
<div title="post count">
|
||||||
<span>{users.postcount}</span>
|
<span id='postcount'>{users.postcount}</span>
|
||||||
<i class='icon-pencil'></i>
|
<i class='icon-pencil'></i>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -23,3 +23,23 @@
|
|||||||
|
|
||||||
<!-- END users -->
|
<!-- END users -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(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()));
|
||||||
|
|
||||||
|
var postcount = $('#postcount');
|
||||||
|
postcount.html(addCommas(postcount.html()));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}());
|
||||||
|
</script>
|
||||||
@@ -98,7 +98,7 @@ var RDB = require('./redis.js'),
|
|||||||
callback({
|
callback({
|
||||||
'category_name' : category_id ? category_name : 'Recent',
|
'category_name' : category_id ? category_name : 'Recent',
|
||||||
'show_topic_button' : category_id ? 'show' : 'hidden',
|
'show_topic_button' : category_id ? 'show' : 'hidden',
|
||||||
'category_id': category_id,
|
'category_id': category_id || 0,
|
||||||
'topics': topics
|
'topics': topics
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ var RDB = require('./redis.js'),
|
|||||||
callback({
|
callback({
|
||||||
'category_name' : category_id ? category_name : 'Recent',
|
'category_name' : category_id ? category_name : 'Recent',
|
||||||
'show_topic_button' : category_id ? 'show' : 'hidden',
|
'show_topic_button' : category_id ? 'show' : 'hidden',
|
||||||
'category_id': category_id,
|
'category_id': category_id || 0,
|
||||||
'topics': []
|
'topics': []
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
11
src/user.js
11
src/user.js
@@ -69,6 +69,13 @@ var config = require('../config.js'),
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
User.updateUserFields = function(uid, data) {
|
||||||
|
console.log(data);
|
||||||
|
for(var key in data) {
|
||||||
|
User.setUserField(uid, key, data[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
User.setUserField = function(uid, field, value) {
|
User.setUserField = function(uid, field, value) {
|
||||||
RDB.db.hset('user:'+uid, field, value);
|
RDB.db.hset('user:'+uid, field, value);
|
||||||
}
|
}
|
||||||
@@ -239,6 +246,10 @@ var config = require('../config.js'),
|
|||||||
|
|
||||||
RDB.db.hmset('user:'+uid, {
|
RDB.db.hmset('user:'+uid, {
|
||||||
'username' : username,
|
'username' : username,
|
||||||
|
'fullname': '',
|
||||||
|
'location':'',
|
||||||
|
'birthday':'',
|
||||||
|
'website':'',
|
||||||
'email' : email,
|
'email' : email,
|
||||||
'joindate' : new Date().getTime(),
|
'joindate' : new Date().getTime(),
|
||||||
'password' : hash,
|
'password' : hash,
|
||||||
|
|||||||
@@ -332,6 +332,19 @@ passport.deserializeUser(function(uid, done) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.post('/edituser', function(req, res){
|
||||||
|
|
||||||
|
if(!req.user) {
|
||||||
|
res.redirect('/403');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
user.updateUserFields(req.user.uid, req.body);
|
||||||
|
|
||||||
|
res.redirect('/');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
app.get('/baristest', function(req, res) {
|
app.get('/baristest', function(req, res) {
|
||||||
/*user.getUserField(req.user.uid, 'email', function(data) {
|
/*user.getUserField(req.user.uid, 'email', function(data) {
|
||||||
console.log(" I GOT FIELD " +data);
|
console.log(" I GOT FIELD " +data);
|
||||||
@@ -354,23 +367,16 @@ passport.deserializeUser(function(uid, done) {
|
|||||||
//I didn't want to change too much so you should probably sort out the params etc
|
//I didn't want to change too much so you should probably sort out the params etc
|
||||||
function get_account_fn(req, res, callback) {
|
function get_account_fn(req, res, callback) {
|
||||||
|
|
||||||
if (req.user === undefined)
|
|
||||||
return res.redirect('/403');
|
|
||||||
|
|
||||||
var requestedUserId = req.user.uid;
|
|
||||||
|
|
||||||
var username = req.params.id;
|
var username = req.params.id;
|
||||||
|
|
||||||
user.get_uid_by_username(username, function(uid) {
|
user.get_uid_by_username(username, function(uid) {
|
||||||
|
|
||||||
if(uid != req.user.uid)
|
user.getUserData(uid, function(data) {
|
||||||
requestedUserId = uid;
|
|
||||||
|
|
||||||
user.getUserData(requestedUserId, function(data) {
|
|
||||||
if(data)
|
if(data)
|
||||||
{
|
{
|
||||||
data.joindate = utils.relativeTime(data.joindate);
|
data.joindate = utils.relativeTime(data.joindate);
|
||||||
data.uid = requestedUserId;
|
data.age = new Date().getFullYear() - new Date(data.birthday).getFullYear();;
|
||||||
|
data.uid = uid;
|
||||||
callback({user:data});
|
callback({user:data});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -414,9 +420,7 @@ passport.deserializeUser(function(uid, done) {
|
|||||||
app.get('/users/:uid/edit', function(req, res){
|
app.get('/users/:uid/edit', function(req, res){
|
||||||
|
|
||||||
if(req.user && req.params.uid)
|
if(req.user && req.params.uid)
|
||||||
{
|
res.send(templates['header'] + create_route('users/'+req.params.uid+'/edit','accountedit') + templates['footer']);
|
||||||
res.send(templates['header'] + '<script>templates.ready(function(){ajaxify.go("users/' + req.params.uid+'/edit");});</script>' + templates['footer']);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
return res.redirect('/403');
|
return res.redirect('/403');
|
||||||
});
|
});
|
||||||
@@ -424,7 +428,6 @@ passport.deserializeUser(function(uid, done) {
|
|||||||
|
|
||||||
app.get('/users/:username*', handleUserProfile);
|
app.get('/users/:username*', handleUserProfile);
|
||||||
|
|
||||||
|
|
||||||
function handleUserProfile(req, res) {
|
function handleUserProfile(req, res) {
|
||||||
|
|
||||||
if(!req.params.username) {
|
if(!req.params.username) {
|
||||||
@@ -434,12 +437,17 @@ passport.deserializeUser(function(uid, done) {
|
|||||||
|
|
||||||
user.get_uid_by_username(req.params.username, function(uid) {
|
user.get_uid_by_username(req.params.username, function(uid) {
|
||||||
|
|
||||||
|
if(!uid) {
|
||||||
|
res.redirect('/403');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
user.getUserData(uid, function(data) {
|
user.getUserData(uid, function(data) {
|
||||||
if(data) {
|
if(data) {
|
||||||
res.send(templates['header'] + '<script>templates.ready(function(){ajaxify.go("users/'+data.username + '");});</script>' + templates['footer']);
|
res.send(templates['header'] + create_route('users/'+data.username, 'account') + templates['footer']);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
res.send("User doesn't exist! /users/"+req.params.username);
|
res.redirect('/403');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user