mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-06 15:42:52 +01:00
file upload with spaces / general file upload fix wrt ajaxiy
This commit is contained in:
@@ -25,6 +25,8 @@ $(document).ready(function() {
|
||||
ajaxify.go = function (url, callback, quiet) {
|
||||
if (ajaxify.handleACPRedirect(url)) {
|
||||
return true;
|
||||
} else if (ajaxify.handleNonAPIRoutes(url)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
app.enterRoom('');
|
||||
@@ -71,6 +73,15 @@ $(document).ready(function() {
|
||||
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) {
|
||||
url = ajaxify.removeRelativePath(url.replace(/\/$/, ''));
|
||||
var hash = window.location.hash;
|
||||
|
||||
13
src/file.js
13
src/file.js
@@ -8,11 +8,20 @@ var fs = require('fs'),
|
||||
Magic = mmmagic.Magic,
|
||||
mime = require('mime'),
|
||||
|
||||
meta= require('./meta');
|
||||
meta = require('./meta'),
|
||||
utils = require('../public/src/utils');
|
||||
|
||||
var file = {};
|
||||
|
||||
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);
|
||||
|
||||
@@ -23,7 +32,7 @@ file.saveFileToLocal = function(filename, folder, tempPath, callback) {
|
||||
|
||||
is.on('end', function () {
|
||||
callback(null, {
|
||||
url: nconf.get('upload_url') + folder + '/' + encodeURIComponent(filename)
|
||||
url: nconf.get('upload_url') + folder + '/' + filename
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user