file upload with spaces / general file upload fix wrt ajaxiy

v1.18.x
psychobunny 10 years ago
parent 909fe660a9
commit 3ed3612047

@ -25,6 +25,8 @@ $(document).ready(function() {
ajaxify.go = function (url, callback, quiet) { ajaxify.go = function (url, callback, quiet) {
if (ajaxify.handleACPRedirect(url)) { if (ajaxify.handleACPRedirect(url)) {
return true; return true;
} else if (ajaxify.handleNonAPIRoutes(url)) {
return true;
} }
app.enterRoom(''); app.enterRoom('');
@ -71,6 +73,15 @@ $(document).ready(function() {
return false; return false;
}; };
ajaxify.handleNonAPIRoutes = function(url) {
url = ajaxify.removeRelativePath(url.replace(/\/$/, ''));
if (url.indexOf('uploads') === 0) {
window.open(RELATIVE_PATH + '/' + url, '_blank');
return true;
}
return false;
};
ajaxify.start = function(url, quiet, search) { ajaxify.start = function(url, quiet, search) {
url = ajaxify.removeRelativePath(url.replace(/\/$/, '')); url = ajaxify.removeRelativePath(url.replace(/\/$/, ''));
var hash = window.location.hash; var hash = window.location.hash;

@ -8,11 +8,20 @@ var fs = require('fs'),
Magic = mmmagic.Magic, Magic = mmmagic.Magic,
mime = require('mime'), mime = require('mime'),
meta= require('./meta'); meta = require('./meta'),
utils = require('../public/src/utils');
var file = {}; var file = {};
file.saveFileToLocal = function(filename, folder, tempPath, callback) { file.saveFileToLocal = function(filename, folder, tempPath, callback) {
/*
* remarkable doesn't allow spaces in hyperlinks, once that's fixed, remove this.
*/
filename = filename.split('.');
filename.forEach(function(name, idx) {
filename[idx] = utils.slugify(name);
});
filename = filename.join('.');
var uploadPath = path.join(nconf.get('base_dir'), nconf.get('upload_path'), folder, filename); var uploadPath = path.join(nconf.get('base_dir'), nconf.get('upload_path'), folder, filename);
@ -23,7 +32,7 @@ file.saveFileToLocal = function(filename, folder, tempPath, callback) {
is.on('end', function () { is.on('end', function () {
callback(null, { callback(null, {
url: nconf.get('upload_url') + folder + '/' + encodeURIComponent(filename) url: nconf.get('upload_url') + folder + '/' + filename
}); });
}); });

Loading…
Cancel
Save