New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

wiki-plugin-assets

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wiki-plugin-assets - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

40

client/assets.js

@@ -50,3 +50,3 @@ (function() {

emit = function($item, item) {
$item.append("<p style=\"background-color:#eee;padding:15px;\">\n fetching asset list\n</p>");
$item.append("<div style=\"background-color:#eee;padding:15px;\">\n <p>fetching asset list</p>\n <center><button>upload</button></center>\n</div>\n<input style=\"display: none;\" type=\"file\" name=\"uploads[]\" multiple=\"multiple\">");
return fetch($item, item);

@@ -56,5 +56,41 @@ };

bind = function($item, item) {
return $item.dblclick(function() {
var $button, $input, assets;
assets = item.text.match(/([\w\/-]*)/)[1];
$item.dblclick(function() {
return wiki.textEditor($item, item);
});
$button = $item.find('button');
$input = $item.find('input');
$button.click(function(e) {
return $input.click();
});
return $input.on('change', function(e) {
var file, files, form, i, len;
files = $(this).get(0).files;
console.log('upload', files);
if (!files.length) {
return console.log('cancel upload');
}
form = new FormData();
form.append('assets', assets);
for (i = 0, len = files.length; i < len; i++) {
file = files[i];
form.append('uploads[]', file, file.name);
}
return $.ajax({
url: '/plugin/assets/upload',
type: 'POST',
data: form,
processData: false,
contentType: false,
success: function() {
$item.empty();
emit($item, item);
return bind($item, item);
},
error: function() {
return console.log('upload error');
}
});
});
};

@@ -61,0 +97,0 @@

5

package.json
{
"name": "wiki-plugin-assets",
"version": "0.1.3",
"version": "0.1.4",
"description": "Federated Wiki - Assets Plugin",

@@ -41,4 +41,5 @@ "keywords": [

"dependencies": {
"async": "^2.6.0"
"async": "^2.6.0",
"formidable": "^1.1.1"
}
}
(function() {
var async, fs, startServer;
var async, formidable, fs, startServer;

@@ -8,2 +8,4 @@ fs = require('fs');

formidable = require('formidable');
startServer = function(params) {

@@ -41,2 +43,24 @@ var app, argv;

});
app.post('/plugin/assets/upload', function(req, res) {
var form;
form = new formidable.IncomingForm;
form.multiples = true;
form.uploadDir = "" + argv.assets;
form.on('field', function(name, value) {
if (name === 'assets') {
return form.uploadDir = argv.assets + "/" + value;
}
});
form.on('file', function(field, file) {
return fs.rename(file.path, form.uploadDir + "/" + file.name);
});
form.on('error', function(err) {
console.log("upload error: " + err);
return res.status(500).send("upload error: " + err);
});
form.on('end', function() {
return res.end('success');
});
return form.parse(req);
});
return app.get('/plugin/assets/:thing', function(req, res) {

@@ -43,0 +67,0 @@ var thing;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc