signature work

v1.18.x
Baris Soner Usakli 12 years ago
parent 47d491b266
commit 9c5fa5fc5e

@ -713,6 +713,13 @@ body .navbar .nodebb-inline-block {
} }
.post-signature { .post-signature {
color:#666; color: #666;
font-size:12px; font-size: 12px;
border-top: 1px solid #ddd;
display: inline-block;
img {
max-width:200px;
max-height:60px;
}
} }

@ -120,7 +120,7 @@
<div class="control-group"> <div class="control-group">
<label class="control-label" for="inputSignature">Signature</label> <label class="control-label" for="inputSignature">Signature</label>
<div class="controls"> <div class="controls">
<textarea id="inputSignature" placeholder="your signature" rows="5">{signature}</textarea> <textarea id="inputSignature" placeholder="max 150 chars" rows="5">{signature}</textarea>
</div> </div>
</div> </div>
@ -248,7 +248,18 @@ $(document).ready(function() {
$.post('/users/doedit', $.post('/users/doedit',
userData, userData,
function(data) { function(data) {
app.alert({ if(data.error) {
app.alert({
'alert_id': 'user_profile_updated',
type: 'error',
title: 'Profile Update Error',
message: data.error,
timeout: 2000
});
return;
}
app.alert({
'alert_id': 'user_profile_updated', 'alert_id': 'user_profile_updated',
type: 'success', type: 'success',
title: 'Profile Updated', title: 'Profile Updated',

@ -45,7 +45,7 @@ marked.setOptions({
'username' : user_data[uid].username || 'anonymous', 'username' : user_data[uid].username || 'anonymous',
'user_rep' : user_data[uid].reputation || 0, 'user_rep' : user_data[uid].reputation || 0,
'gravatar' : user_data[uid].picture || 'http://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e', 'gravatar' : user_data[uid].picture || 'http://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e',
'signature' : user_data[uid].signature, 'signature' : marked(utils.strip_tags(user_data[uid].signature || '')),
'fav_star_class' : vote_data[pid] ? 'icon-star' : 'icon-star-empty', 'fav_star_class' : vote_data[pid] ? 'icon-star' : 'icon-star-empty',
'display_moderator_tools': (uid == current_user || privileges.editable) ? 'show' : 'none', 'display_moderator_tools': (uid == current_user || privileges.editable) ? 'show' : 'none',
'edited-class': post_data.editor[i] !== null ? '' : 'none', 'edited-class': post_data.editor[i] !== null ? '' : 'none',

@ -82,9 +82,9 @@ var user = require('./../user.js'),
return res.redirect('/'); return res.redirect('/');
} }
user.updateProfile(req.user.uid, req.body); user.updateProfile(req.user.uid, req.body, function(data) {
res.send(data);
res.send({}); });
}); });
app.post('/users/uploadpicture', function(req, res) { app.post('/users/uploadpicture', function(req, res) {

@ -79,11 +79,18 @@ var config = require('../config.js'),
}); });
} }
User.updateProfile = function(uid, data) { User.updateProfile = function(uid, data, callback) {
var fields = ['email', 'fullname', 'website', 'location', 'birthday', 'signature']; var fields = ['email', 'fullname', 'website', 'location', 'birthday', 'signature'];
var key = ''; var key = '';
if(data['signature'] !== undefined && data['signature'].length > 150)
{
callback({error:'Signature can\'t be longer than 150 characters!'});
return;
}
for(var i=0,ii=fields.length; i<ii; ++i) { for(var i=0,ii=fields.length; i<ii; ++i) {
key = fields[i]; key = fields[i];
@ -93,16 +100,16 @@ var config = require('../config.js'),
User.setUserField(uid, 'gravatarpicture', User.createGravatarURLFromEmail(data[key])); User.setUserField(uid, 'gravatarpicture', User.createGravatarURLFromEmail(data[key]));
RDB.set('email:' + data['email'] +':uid', uid); RDB.set('email:' + data['email'] +':uid', uid);
} }
else if(key === 'signature') {
//sanitize sig plx - baris
//data[key] = marked(data[key]);
}
User.setUserField(uid, key, data[key]); User.setUserField(uid, key, data[key]);
} }
} }
callback({});
} }
User.setUserField = function(uid, field, value) { User.setUserField = function(uid, field, value) {
RDB.hset('user:'+uid, field, value); RDB.hset('user:'+uid, field, value);
} }

Loading…
Cancel
Save