mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 06:55:46 +01:00
Merge remote-tracking branch 'origin'
This commit is contained in:
@@ -324,6 +324,7 @@ footer.footer {
|
||||
|
||||
.account-username-box{
|
||||
border-bottom:1px solid #e3e3e3;
|
||||
margin-bottom:10px;
|
||||
}
|
||||
|
||||
.account-username{
|
||||
@@ -334,6 +335,7 @@ footer.footer {
|
||||
.account-picture-block{
|
||||
display:inline-block;
|
||||
margin-right:20px;
|
||||
vertical-align:top;
|
||||
}
|
||||
|
||||
.account-bio-block{
|
||||
@@ -347,7 +349,6 @@ footer.footer {
|
||||
}
|
||||
|
||||
|
||||
|
||||
.category-icon {
|
||||
width: 100%;
|
||||
height: 90px;
|
||||
|
||||
@@ -31,8 +31,12 @@ var ajaxify = {};
|
||||
app.enter_room('global');
|
||||
|
||||
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]) {
|
||||
window.history.pushState({}, url, "/" + url);
|
||||
|
||||
@@ -5,7 +5,14 @@ var templates = {};
|
||||
config = {};
|
||||
|
||||
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) {
|
||||
@@ -58,7 +65,7 @@ var templates = {};
|
||||
|
||||
function init() {
|
||||
loadTemplates([
|
||||
'header', 'footer', 'register', 'home', 'topic','account', 'category', 'users',
|
||||
'header', 'footer', 'register', 'home', 'topic','account', 'category', 'users', 'accountedit',
|
||||
'login', 'reset', 'reset_code', 'account',
|
||||
'confirm',
|
||||
'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;
|
||||
|
||||
})(data, "", template);
|
||||
@@ -156,18 +168,15 @@ function load_template(callback, custom_tpl) {
|
||||
|
||||
|
||||
jQuery.get(API_URL + url, function(data) {
|
||||
|
||||
var splits = url.split('/');
|
||||
var tpl = url;
|
||||
|
||||
if(splits.length) {
|
||||
tpl = splits[0];
|
||||
tpl = templates.get_custom_map(tpl);
|
||||
var tpl = templates.get_custom_map(url);
|
||||
if (tpl == false) {
|
||||
tpl = url.split('/')[0];
|
||||
}
|
||||
|
||||
if (custom_tpl && custom_tpl != "undefined")
|
||||
tpl = custom_tpl;
|
||||
|
||||
|
||||
document.getElementById('content').innerHTML = templates[tpl].parse(JSON.parse(data));
|
||||
if (callback) callback();
|
||||
});
|
||||
|
||||
@@ -9,10 +9,9 @@
|
||||
<!-- BEGIN user -->
|
||||
|
||||
<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>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
<div class="account-picture-block">
|
||||
<img src="{user.picture}?s=128" />
|
||||
@@ -21,6 +20,22 @@
|
||||
<div class="account-bio-block">
|
||||
<span class="account-bio-label">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/>
|
||||
|
||||
<span class="account-bio-label">member for</span>
|
||||
@@ -28,18 +43,14 @@
|
||||
<br/>
|
||||
|
||||
<span class="account-bio-label">reputation</span>
|
||||
<span>{user.reputation}</span>
|
||||
<span id='reputation'>{user.reputation}</span>
|
||||
<br/>
|
||||
|
||||
<span class="account-bio-label">posts</span>
|
||||
<span>{user.postcount}</span>
|
||||
<span id='postcount'>{user.postcount}</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>
|
||||
|
||||
|
||||
<!-- END user -->
|
||||
|
||||
|
||||
@@ -47,6 +58,20 @@
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
(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>
|
||||
@@ -8,12 +8,62 @@
|
||||
|
||||
<!-- 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 -->
|
||||
|
||||
|
||||
@@ -21,6 +71,27 @@
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
(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>
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"custom_mapping": {
|
||||
"users[^]*edit": "accountedit",
|
||||
"users": "account",
|
||||
"latest": "category",
|
||||
"popular": "category",
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
<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>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
<a href="/users/{users.username}">{users.username}</a>
|
||||
<br/>
|
||||
<div title="reputation">
|
||||
<span>{users.reputation}</span>
|
||||
<span id='reputation'>{users.reputation}</span>
|
||||
<i class='icon-star'></i>
|
||||
</div>
|
||||
<div title="post count">
|
||||
<span>{users.postcount}</span>
|
||||
<span id='postcount'>{users.postcount}</span>
|
||||
<i class='icon-pencil'></i>
|
||||
</div>
|
||||
|
||||
@@ -23,3 +23,23 @@
|
||||
|
||||
<!-- END users -->
|
||||
</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({
|
||||
'category_name' : category_id ? category_name : 'Recent',
|
||||
'show_topic_button' : category_id ? 'show' : 'hidden',
|
||||
'category_id': category_id,
|
||||
'category_id': category_id || 0,
|
||||
'topics': topics
|
||||
});
|
||||
|
||||
@@ -108,7 +108,7 @@ var RDB = require('./redis.js'),
|
||||
callback({
|
||||
'category_name' : category_id ? category_name : 'Recent',
|
||||
'show_topic_button' : category_id ? 'show' : 'hidden',
|
||||
'category_id': category_id,
|
||||
'category_id': category_id || 0,
|
||||
'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) {
|
||||
RDB.db.hset('user:'+uid, field, value);
|
||||
}
|
||||
@@ -239,6 +246,10 @@ var config = require('../config.js'),
|
||||
|
||||
RDB.db.hmset('user:'+uid, {
|
||||
'username' : username,
|
||||
'fullname': '',
|
||||
'location':'',
|
||||
'birthday':'',
|
||||
'website':'',
|
||||
'email' : email,
|
||||
'joindate' : new Date().getTime(),
|
||||
'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) {
|
||||
/*user.getUserField(req.user.uid, 'email', function(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
|
||||
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;
|
||||
|
||||
user.get_uid_by_username(username, function(uid) {
|
||||
|
||||
if(uid != req.user.uid)
|
||||
requestedUserId = uid;
|
||||
|
||||
user.getUserData(requestedUserId, function(data) {
|
||||
user.getUserData(uid, function(data) {
|
||||
if(data)
|
||||
{
|
||||
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});
|
||||
}
|
||||
else
|
||||
@@ -414,9 +420,7 @@ passport.deserializeUser(function(uid, done) {
|
||||
app.get('/users/:uid/edit', function(req, res){
|
||||
|
||||
if(req.user && req.params.uid)
|
||||
{
|
||||
res.send(templates['header'] + '<script>templates.ready(function(){ajaxify.go("users/' + req.params.uid+'/edit");});</script>' + templates['footer']);
|
||||
}
|
||||
res.send(templates['header'] + create_route('users/'+req.params.uid+'/edit','accountedit') + templates['footer']);
|
||||
else
|
||||
return res.redirect('/403');
|
||||
});
|
||||
@@ -424,7 +428,6 @@ passport.deserializeUser(function(uid, done) {
|
||||
|
||||
app.get('/users/:username*', handleUserProfile);
|
||||
|
||||
|
||||
function handleUserProfile(req, res) {
|
||||
|
||||
if(!req.params.username) {
|
||||
@@ -434,12 +437,17 @@ passport.deserializeUser(function(uid, done) {
|
||||
|
||||
user.get_uid_by_username(req.params.username, function(uid) {
|
||||
|
||||
if(!uid) {
|
||||
res.redirect('/403');
|
||||
return;
|
||||
}
|
||||
|
||||
user.getUserData(uid, function(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 {
|
||||
res.send("User doesn't exist! /users/"+req.params.username);
|
||||
res.redirect('/403');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user