ep_fileupload
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -56,4 +56,9 @@ /** | ||
if (err) throw err; | ||
// FIXME: Calculate URL for real, with path prefix and with https handling | ||
res.send(eejs.require("ep_fileupload/templates/fileUploaded.ejs", {upload: 'http://' + req.headers.host + "/up/" + name}, module)); | ||
var regex = /^(https?:\/\/[^\/]+)\//; | ||
var urlBase = 'http://' + req.headers.host; | ||
var matches = regex.exec(req.headers['referer']); | ||
if(typeof req.headers['referer'] != "undefined" && typeof matches[1] != "undefined"){ | ||
urlBase = matches[1]; | ||
} | ||
res.send(eejs.require("ep_fileupload/templates/fileUploaded.ejs", {upload: urlBase + "/up/" + name}, module)); | ||
}); | ||
@@ -60,0 +65,0 @@ }); |
{ | ||
"name": "ep_fileupload", | ||
"description": "File upload", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"author": "RedHog (Egil Moeller) <egil.moller@freecode.no>", | ||
@@ -6,0 +6,0 @@ "contributors": ["johnyma22 (John McLear) <john@mclear.co.uk>"], |
$(function(){ | ||
var info = { | ||
action: '/fileUpload/', | ||
name: 'uploadfile', | ||
onSubmit: function(file, ext){ | ||
action: '../fileUpload/', | ||
name: 'uploadfile', | ||
onSubmit: function(file, ext){ // On submit we do nothing, it'd be nice to do something but mheh.. | ||
//console.log('Starting...'); | ||
}, | ||
onComplete: function(file, response){ | ||
// Require the editor.. | ||
var padeditor = require('ep_etherpad-lite/static/js/pad_editor').padeditor; | ||
padeditor.ace.replaceRange(undefined, undefined, " " + response.replace(/^\s+|\s+$/g, '') + " "); | ||
// result i.e. "/up/c79133b2c8a97533cc397f8d325ce17a.jpg", trimmed whitespace | ||
var filePath = response.slice(response.indexOf("/up")).trim(); | ||
// "http://example.com/subfolder/p/padID" -> "http://example.com/subfolder" | ||
var etherpadRoot = document.location.href.slice(0, document.location.href.indexOf("/p/")); | ||
// "http://example.com/subfolder/up/c79133b2c8a97533cc397f8d325ce17a.jpg" | ||
var fileUri = etherpadRoot + filePath; | ||
// Puts the actual URL in the pad.. | ||
padeditor.ace.replaceRange(undefined, undefined, " " + fileUri + " "); | ||
// Put the caret back into the pad | ||
padeditor.ace.focus(); | ||
} | ||
} | ||
}; | ||
new AjaxUpload($('#uploadFileSubmit'), info); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36630
17
1104
3