From 9c5fa5fc5e9332bdf22d1ac4de4b525e975c1f5f Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Tue, 21 May 2013 13:44:53 -0400 Subject: [PATCH] signature work --- public/css/style.less | 11 +++++++++-- public/templates/accountedit.tpl | 15 +++++++++++++-- src/posts.js | 2 +- src/routes/user.js | 6 +++--- src/user.js | 19 +++++++++++++------ 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/public/css/style.less b/public/css/style.less index eb510f70ef..5d406dd732 100644 --- a/public/css/style.less +++ b/public/css/style.less @@ -713,6 +713,13 @@ body .navbar .nodebb-inline-block { } .post-signature { - color:#666; - font-size:12px; + color: #666; + font-size: 12px; + border-top: 1px solid #ddd; + display: inline-block; + + img { + max-width:200px; + max-height:60px; + } } \ No newline at end of file diff --git a/public/templates/accountedit.tpl b/public/templates/accountedit.tpl index 77902659f1..c4c270eef5 100644 --- a/public/templates/accountedit.tpl +++ b/public/templates/accountedit.tpl @@ -120,7 +120,7 @@
- +
@@ -248,7 +248,18 @@ $(document).ready(function() { $.post('/users/doedit', userData, 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', type: 'success', title: 'Profile Updated', diff --git a/src/posts.js b/src/posts.js index a4e2580d4e..6b787a0498 100644 --- a/src/posts.js +++ b/src/posts.js @@ -45,7 +45,7 @@ marked.setOptions({ 'username' : user_data[uid].username || 'anonymous', 'user_rep' : user_data[uid].reputation || 0, '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', 'display_moderator_tools': (uid == current_user || privileges.editable) ? 'show' : 'none', 'edited-class': post_data.editor[i] !== null ? '' : 'none', diff --git a/src/routes/user.js b/src/routes/user.js index 6e74a88653..24cbca0306 100644 --- a/src/routes/user.js +++ b/src/routes/user.js @@ -82,9 +82,9 @@ var user = require('./../user.js'), return res.redirect('/'); } - user.updateProfile(req.user.uid, req.body); - - res.send({}); + user.updateProfile(req.user.uid, req.body, function(data) { + res.send(data); + }); }); app.post('/users/uploadpicture', function(req, res) { diff --git a/src/user.js b/src/user.js index 9449fd8cf9..9f9faec16c 100644 --- a/src/user.js +++ b/src/user.js @@ -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 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