diff --git a/app.js b/app.js
index d9ac0296e5..2c56822907 100644
--- a/app.js
+++ b/app.js
@@ -109,11 +109,11 @@
var customTemplates = meta.config['theme:templates'] ? path.join(__dirname, 'node_modules', meta.config['theme:id'], meta.config['theme:templates']) : false;
-
+
utils.walk(path.join(__dirname, 'public/templates'), function (err, tplsToLoad) {
templates.init(tplsToLoad, customTemplates);
});
-
+
plugins.ready(function() {
templates.ready(webserver.init);
});
diff --git a/public/language/en/user.json b/public/language/en/user.json
index caa4a59b57..10e7772796 100644
--- a/public/language/en/user.json
+++ b/public/language/en/user.json
@@ -7,6 +7,7 @@
"location": "Location",
"age": "Age",
"joined": "Joined",
+ "lastonline": "Last Online",
"profile_views": "Profile views",
"reputation": "Reputation",
"posts": "Posts",
diff --git a/public/src/modules/composer.js b/public/src/modules/composer.js
index 077a7c3a01..192a707142 100644
--- a/public/src/modules/composer.js
+++ b/public/src/modules/composer.js
@@ -48,7 +48,6 @@ define(['taskbar'], function(taskbar) {
socket.emit('api:composer.push', {
pid: pid
}, function(threadData) {
- console.log(threadData);
push({
pid: pid,
title: threadData.title,
@@ -202,7 +201,7 @@ define(['taskbar'], function(taskbar) {
}
});
- postContainer.on('click', '.formatting-bar span .fa-picture-o', function() {
+ postContainer.on('click', '.formatting-bar span .fa-picture-o, .formatting-bar span .fa-upload', function() {
$('#files').click();
});
@@ -213,6 +212,7 @@ define(['taskbar'], function(taskbar) {
loadFile(post_uuid, files[i]);
}
}
+ $('#fileForm')[0].reset();
});
@@ -317,7 +317,12 @@ define(['taskbar'], function(taskbar) {
}
if(config.imgurClientIDSet) {
- postContainer.find('.upload-instructions').removeClass('hide')
+ postContainer.find('.upload-instructions').removeClass('hide');
+ postContainer.find('.img-upload-btn').removeClass('hide');
+ }
+
+ if(config.allowFileUploads) {
+ postContainer.find('.file-upload-btn').removeClass('hide');
}
postContainer.css('visibility', 'visible');
@@ -469,36 +474,41 @@ define(['taskbar'], function(taskbar) {
}
function loadFile(post_uuid, file) {
-
- if (!file.type.match('image.*')) {
- return;
- }
-
var reader = new FileReader(),
dropDiv = $('#cmp-uuid-' + post_uuid).find('.imagedrop');
$(reader).on('loadend', function(e) {
- var bin = this.result.split(',')[1];
+ var regex = /^data:.*;base64,(.*)$/;
+ console.log(file);
+ var matches = this.result.match(regex);
- var img = {
+ var fileData = {
name: file.name,
- data: bin
+ data: matches[1]
};
- createImagePlaceholder(post_uuid, img);
-
dropDiv.hide();
+
+ if(file.type.match('image.*')) {
+ uploadFile('api:posts.uploadImage', post_uuid, fileData);
+ } else {
+ if(file.size > parseInt(config.maximumFileSize, 10) * 1024) {
+ return composerAlert('File too big', 'Maximum allowed file size is ' + config.maximumFileSize + 'kbs');
+ }
+ uploadFile('api:posts.uploadFile', post_uuid, fileData);
+ }
});
reader.readAsDataURL(file);
}
- function createImagePlaceholder(post_uuid, img) {
- var postContainer = $('#cmp-uuid-' + post_uuid),
+ function uploadFile(method, post_uuid, img) {
+ var linkStart = method === 'api:posts.uploadImage' ? '!' : '',
+ postContainer = $('#cmp-uuid-' + post_uuid),
textarea = postContainer.find('textarea'),
text = textarea.val(),
- imgText = "![" + img.name + "](uploading...)";
+ imgText = linkStart + '[' + img.name + '](uploading...)';
text += imgText;
textarea.val(text + " ");
@@ -509,18 +519,17 @@ define(['taskbar'], function(taskbar) {
composer.posts[post_uuid].uploadsInProgress.push(1);
- socket.emit("api:posts.uploadImage", img, function(err, data) {
+ socket.emit(method, img, function(err, data) {
+
+ var currentText = textarea.val();
+
if(err) {
+ textarea.val(currentText.replace(imgText, linkStart + '[' + img.name + '](upload error)'));
return app.alertError(err.message);
}
- var currentText = textarea.val();
- imgText = "![" + data.name + "](uploading...)";
- if(!err) {
- textarea.val(currentText.replace(imgText, "![" + data.name + "](" + data.url + ")"));
- } else {
- textarea.val(currentText.replace(imgText, "![" + data.name + "](upload error)"));
- }
+ textarea.val(currentText.replace(imgText, linkStart + '[' + data.name + '](' + data.url + ')'));
+
composer.posts[post_uuid].uploadsInProgress.pop();
});
}
diff --git a/public/templates/account.tpl b/public/templates/account.tpl
index f54b52cb95..e1ddded78a 100644
--- a/public/templates/account.tpl
+++ b/public/templates/account.tpl
@@ -70,6 +70,10 @@
+ [[user:lastonline]]
+
+
+
[[user:profile_views]]
{profileviews}
diff --git a/public/templates/admin/settings.tpl b/public/templates/admin/settings.tpl
index c2e7463410..5f334cad02 100644
--- a/public/templates/admin/settings.tpl
+++ b/public/templates/admin/settings.tpl
@@ -121,6 +121,17 @@
Use Outgoing Links Warning Page
+