Skip to content

Node.js based forum software built for the modern web

fixed users page so that all reps and post counts are comma delimited, some image upload fixes

Baris Soner Usakli5785b16ae91f
diff --git a/public/templates/accountedit.tpl b/public/templates/accountedit.tpl
index e75bcf12b6..4909ae4d5b 100644
--- a/public/templates/accountedit.tpl
+++ b/public/templates/accountedit.tpl
@@ -140,7 +140,12 @@ $(document).ready(function() {
$('#uploadForm').submit(function() {
status('uploading the file ...');
-
+
+ if(!$('#userPhotoInput').val()) {
+ error('select an image to upload!');
+ return false;
+ }
+
$(this).ajaxSubmit({
error: function(xhr) {
@@ -248,15 +253,19 @@ $(document).ready(function() {
var gravatarPicture = $('#user-data-gravatarpicture').html();
var uploadedPicture = $('#user-data-uploadedpicture').html();
- if(gravatarPicture)
+ if(gravatarPicture) {
$('#user-gravatar-picture').attr('src', gravatarPicture);
+ $('#gravatar-box').show();
+ }
else
- $('#user-gravatar-picture').addClass('hide');
+ $('#gravatar-box').hide();
- if(uploadedPicture)
+ if(uploadedPicture) {
$('#user-uploaded-picture').attr('src', uploadedPicture);
+ $('#uploaded-box').show();
+ }
else
- $('#user-uploaded-picture').addClass('hide');
+ $('#uploaded-box').hide();
if(currentPicture == gravatarPicture)
diff --git a/public/templates/users.tpl b/public/templates/users.tpl
index 85862bf432..f22d55675c 100644
--- a/public/templates/users.tpl
+++ b/public/templates/users.tpl
@@ -11,11 +11,11 @@
<a href="/users/{users.username}">{users.username}</a>
<br/>
<div title="reputation">
- <span id='reputation'>{users.reputation}</span>
+ <span class='reputation'>{users.reputation}</span>
<i class='icon-star'></i>
</div>
<div title="post count">
- <span id='postcount'>{users.postcount}</span>
+ <span class='postcount'>{users.postcount}</span>
<i class='icon-pencil'></i>
</div>
@@ -32,11 +32,14 @@
}
$(document).ready(function() {
- var rep = $('#reputation');
- rep.html(addCommas(rep.html()));
- var postcount = $('#postcount');
- postcount.html(addCommas(postcount.html()));
+ $('.reputation').each(function(index, element) {
+ $(element).html(addCommas($(element).html()));
+ })
+
+ $('.postcount').each(function(index, element) {
+ $(element).html(addCommas($(element).html()));
+ })
});
diff --git a/src/webserver.js b/src/webserver.js
index f1127cf014..afa17cf6fa 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -233,6 +233,14 @@ var express = require('express'),
});
function uploadUserPicture(uid, filename, tempPath, res) {
+
+ if(!filename){
+ res.send({
+ error: 'Error uploading file! Error : Invalid file name!'
+ });
+ return;
+ }
+
var uploadPath = config['upload_path'] + uid + '-' + filename;
fs.rename(