psychobunny 12 years ago
commit 74649f64e2

@ -20,11 +20,11 @@ global.configuration = {};
if (data.categories.length === 0) {
console.log('Setting up default categories...');
fs.readFile(config.ROOT_DIRECTORY + '/install/data/categories.json', function(err, categories) {
categories = JSON.parse(categories);
fs.readFile(config.ROOT_DIRECTORY + '/install/data/categories.json', function(err, default_categories) {
default_categories = JSON.parse(default_categories);
for (var category in categories) {
categories.create(categories[category]);
for (var category in default_categories) {
categories.create(default_categories[category]);
}
});

@ -27,7 +27,8 @@
"marked": "0.2.8",
"bcrypt": "0.7.5",
"node-gyp": "0.9.5",
"async": "0.2.8"
"async": "0.2.8",
"node-imagemagick": "0.1.8"
},
"devDependencies": {},
"optionalDependencies": {},

@ -31,10 +31,16 @@ var socket,
contentEl.value = data.post;
});
socket.on('disconnect', function(data){
$('#disconnect-modal').show();
$('#reload-button').on('click',function(){
$('#disconnect-modal').hide();
window.location.reload();
});
});
},
async: false
});
// use unique alert_id to have multiple alerts visible at a time, use the same alert_id to fade out the current instance
@ -274,7 +280,33 @@ var socket,
}, false);
// Posting
var formattingBar = document.getElementById('formatting-bar'),
postContentEl = document.getElementById('post_content');
jQuery('#post_window').slideToggle(0);
formattingBar.addEventListener('click', function(e) {
if (e.target.nodeName === 'I') {
switch(e.target.className) {
case 'icon-bold':
var cursorEnd = postContentEl.value.length;
postContentEl.value = postContentEl.value + '**bolded text**';
postContentEl.selectionStart = cursorEnd+2;
postContentEl.selectionEnd = postContentEl.value.length - 2;
break;
case 'icon-italic':
var cursorEnd = postContentEl.value.length;
postContentEl.value = postContentEl.value + '*italicised text*';
postContentEl.selectionStart = cursorEnd+1;
postContentEl.selectionEnd = postContentEl.value.length - 1;
break;
case 'icon-list':
var cursorEnd = postContentEl.value.length;
postContentEl.value = postContentEl.value + "\n\n* list item";
postContentEl.selectionStart = cursorEnd+4;
postContentEl.selectionEnd = postContentEl.value.length;
break;
}
}
}, false);
})

@ -59,7 +59,7 @@
</div>
</div>
<div id="user-actions" class="container">
<a id="add-friend-btn" href="#" class="btn">Add Friend</a>
<a id="add-friend-btn" href="#" class="btn">Follow</a>
</div>
<br/>
<div id="user-action-alert" class="alert alert-success hide"></div>
@ -72,6 +72,8 @@ var theirid = '{theirid}';
(function() {
var isFriend = {isFriend};
function addCommas(text) {
return text.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
}
@ -90,6 +92,9 @@ var theirid = '{theirid}';
if( yourid !== theirid) {
editLink.hide();
if(isFriend)
addFriendBtn.hide();
else
addFriendBtn.show();
}
else {
@ -99,16 +104,14 @@ var theirid = '{theirid}';
addFriendBtn.on('click', function() {
$.post('/users/addfriend', {uid: theirid},
function(data) {
addFriendBtn.remove();
$('#user-action-alert').html('Friend Added!').show();
}
);
return false;
});
});
}());
</script>

@ -32,7 +32,7 @@
<span class='postcount'>{friends.postcount}</span>
<i class='icon-pencil'></i>
</div>
<a id="remove-friend-btn" href="#" class="btn remove-friend-btn" friendid="{friends.uid}">Unfriend</a>
<a id="remove-friend-btn" href="#" class="btn remove-friend-btn" friendid="{friends.uid}">Unfollow</a>
</div>
<!-- END friends -->
@ -72,7 +72,7 @@ var friendCount = '{friendCount}';
$.post('/users/removefriend', {uid: friendid},
function(data) {
button.parent().remove();
removeBtn.parent().remove();
}
);
return false;

@ -61,10 +61,10 @@
<div class="container">
<div class="btn-toolbar">
<div class="btn-group">
<div class="btn-group" id="formatting-bar">
<span class="btn btn-link" tabindex="-1"><i class="icon-bold"></i></span>
<span class="btn btn-link" tabindex="-1"><i class="icon-italic"></i></span>
<span class="btn btn-link" tabindex="-1"><i class="icon-font"></i></span>
<!-- <span class="btn btn-link" tabindex="-1"><i class="icon-font"></i></span> -->
<span class="btn btn-link" tabindex="-1"><i class="icon-list"></i></span>
</div>
<div class="btn-group" style="float: right; margin-right: -12px">
@ -78,6 +78,19 @@
</div>
</div>
</div>
<div id="disconnect-modal" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<h3 id="myModalLabel">Socket Disconnect</h3>
</div>
<div class="modal-body">
<span>Looks like you disconnected, try reloading the page.</span>
</div>
<div class="modal-footer">
<a id="reload-button" href="/" class="btn btn-primary">Reload</a>
</div>
</div>
<div id="notification_window"></div>
<div class="container" id="content">

@ -91,9 +91,20 @@ var user = require('./../user.js'),
if(!req.user)
return res.redirect('/403');
if(req.files.userPhoto.size > 131072) {
if(req.files.userPhoto.size > 262144) {
res.send({
error: 'Images must be smaller than 128kb!'
error: 'Images must be smaller than 256kb!'
});
return;
}
var allowedTypes = ['image/png', 'image/jpeg', 'image/jpg', 'image/gif'];
var type = req.files.userPhoto.type;
console.log(req.files.userPhoto);
if(allowedTypes.indexOf(type) === -1) {
res.send({
error: 'Allowed image types are png, jpg and gif!'
});
return;
}
@ -152,6 +163,17 @@ var user = require('./../user.js'),
user.setUserField(uid, 'uploadedpicture', imageUrl);
user.setUserField(uid, 'picture', imageUrl);
var im = require('node-imagemagick');
im.resize({
srcPath: global.configuration['ROOT_DIRECTORY'] + uploadPath,
dstPath: global.configuration['ROOT_DIRECTORY'] + uploadPath,
width: 128
}, function(err, stdout, stderr){
if (err)
throw err;
});
});
os.on('error', function(err) {
@ -244,16 +266,17 @@ var user = require('./../user.js'),
});
} else {
getUserDataByUserName(req.params.username, callerUID, function(userData) {
user.isFriend(callerUID, userData.theirid, function(isFriend) {
userData.isFriend = isFriend;
res.send(JSON.stringify(userData));
});
});
}
}
app.get('/api/users/:username?/:section?', api_method);
function getUserDataByUserName(username, callerUID, callback) {
user.get_uid_by_username(username, function(uid) {

@ -378,7 +378,7 @@ var config = require('../config.js'),
for(var i=0, ii=data.length; i<ii; ++i) {
User.getUserData(data[i], function(userData){
friendsData.push(userData);
console.log(friendsData);
if(friendsData.length == data.length)
callback(friendsData);
});
@ -398,6 +398,16 @@ var config = require('../config.js'),
});
}
User.isFriend = function(uid, friendid, callback) {
RDB.sismember('user:'+uid+':friends', friendid, function(err, data){
if(err === null){
callback(data === 1);
}
else
console.log(err);
});
}
User.exists = function(username, callback) {
User.get_uid_by_username(username, function(exists) {
exists = !!exists;

Loading…
Cancel
Save