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
2
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.3.0 to 0.3.1-pre1

51

client/assets.js

@@ -5,7 +5,5 @@ "use strict";

var bind, context, delete_file, emit, expand, fetch_list, get_file, ignore, post_upload;
expand = function expand(text) {
return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
};
ignore = function ignore(e) {

@@ -15,7 +13,5 @@ e.preventDefault();

};
context = function context($item) {
var action, i, journal, len, ref, remote, sites;
sites = [location.host];
if (remote = $item.parents('.page').data('site')) {

@@ -26,9 +22,6 @@ if (remote !== location.host) {

}
journal = $item.parents('.page').data('data').journal;
ref = journal.slice(0).reverse();
for (i = 0, len = ref.length; i < len; i++) {
action = ref[i];
if (action.site != null && !sites.includes(action.site)) {

@@ -38,17 +31,12 @@ sites.push(action.site);

}
return sites;
};
post_upload = function post_upload($item, item, form) {
var $progress, tick;
$progress = $item.find('.progress-bar');
tick = function tick(e) {
var percentComplete;
if (!e.lengthComputable) {
return;
}
percentComplete = e.loaded / e.total;

@@ -59,3 +47,2 @@ percentComplete = parseInt(percentComplete * 100);

};
return $.ajax({

@@ -85,3 +72,2 @@ url: '/plugin/assets/upload',

};
get_file = function get_file($item, item, url, success) {

@@ -109,3 +95,2 @@ var assets, filename;

};
delete_file = function delete_file($item, item, url) {

@@ -131,3 +116,2 @@ var assets, file;

};
fetch_list = function fetch_list($item, item, $report, assets, remote, assetsData) {

@@ -137,3 +121,2 @@ var assetsURL, link, render, requestSite, trouble;

assetsURL = wiki.site(requestSite).getDirectURL('assets');
if (assetsURL === '') {

@@ -143,15 +126,12 @@ $report.text("site not currently reachable.");

}
link = function link(file) {
var act, href;
href = "".concat(assetsURL, "/").concat(assets === '' ? "" : assets + "/").concat(encodeURIComponent(file)); // todo: no action if not logged on
href = "".concat(assetsURL, "/").concat(assets === '' ? "" : assets + "/").concat(encodeURIComponent(file));
// todo: no action if not logged on
act = !isOwner ? '' : remote !== location.host ? '<button class="copy">⚑</button> ' : '<button class="delete">✕</button> ';
return "<span>".concat(act, "<a href=\"").concat(href, "\" target=_blank>").concat(expand(file), "</a></span>");
};
render = function render(data) {
var file, files;
assetsData[assets] || (assetsData[assets] = {});
if (data.error) {

@@ -161,17 +141,12 @@ if (data.error.code === 'ENOENT') {

}
return $report.text("plugin reports: ".concat(data.error.code));
}
files = data.files;
assetsData[assets][assetsURL] = files;
if (files.length === 0) {
return $report.text("no files");
}
$report.html(function () {
var i, len, results;
results = [];
for (i = 0, len = files.length; i < len; i++) {

@@ -181,3 +156,2 @@ file = files[i];

}
return results;

@@ -198,7 +172,5 @@ }().join("<br>"));

};
trouble = function trouble(e) {
return $report.text("plugin error: ".concat(e.statusText, " ").concat(e.responseText || ''));
};
return $.ajax({

@@ -214,6 +186,4 @@ url: wiki.site(requestSite).getURL('plugin/assets/list'),

};
emit = function emit($item, item) {
var $report, assets, assetsData, i, len, ref, results, site, uploader;
uploader = function uploader() {

@@ -223,18 +193,13 @@ if ($item.parents('.page').hasClass('remote')) {

}
return "<div style=\"background-color:#ddd;\" class=\"progress-bar\" role=\"progressbar\"></div>\n<center><button class=\"upload\">upload</button></center>\n<input style=\"display: none;\" type=\"file\" name=\"uploads[]\" multiple=\"multiple\">";
};
$item.append("<div style=\"background-color:#eee;padding:15px; margin-block-start:1em; margin-block-end:1em;\">\n <dl style=\"margin:0;color:gray\"></dl>\n ".concat(uploader(), "\n</div>"));
assetsData = {};
$item.addClass('assets-source');
$item.get(0).assetsData = function () {
return assetsData;
};
assets = item.text.match(/([\w\/-]*)/)[1];
ref = context($item);
results = [];
for (i = 0, len = ref.length; i < len; i++) {

@@ -245,6 +210,4 @@ site = ref[i];

}
return results;
};
bind = function bind($item, item) {

@@ -255,4 +218,4 @@ var $button, $input, assets, upload;

return wiki.textEditor($item, item);
}); // https://coligo.io/building-ajax-file-uploader-with-node/
});
// https://coligo.io/building-ajax-file-uploader-with-node/
$button = $item.find('.upload');

@@ -275,10 +238,7 @@ $input = $item.find('input');

var file, form, i, len;
if (!(files != null ? files.length : void 0)) {
return;
}
form = new FormData();
form.append('assets', assets);
for (i = 0, len = files.length; i < len; i++) {

@@ -288,7 +248,5 @@ file = files[i];

}
return post_upload($item, item, form);
};
};
if (typeof window !== "undefined" && window !== null) {

@@ -300,3 +258,2 @@ window.plugins.assets = {

}
if (typeof module !== "undefined" && module !== null) {

@@ -303,0 +260,0 @@ module.exports = {

2

package.json
{
"name": "wiki-plugin-assets",
"version": "0.3.0",
"version": "0.3.1-pre1",
"description": "Federated Wiki - Assets Plugin",

@@ -5,0 +5,0 @@ "keywords": [

@@ -8,5 +8,3 @@ "use strict";

fs = require('fs');
var _require = require('path');
basename = _require.basename;

@@ -16,3 +14,2 @@ mkdirp = require('mkdirp');

formidable = require('formidable');
cors = function cors(req, res, next) {

@@ -22,3 +19,2 @@ res.header('Access-Control-Allow-Origin', '*');

};
startServer = function startServer(params) {

@@ -32,3 +28,2 @@ var app, argv;

path = "".concat(argv.assets, "/").concat(assets);
isFile = function isFile(name, done) {

@@ -38,3 +33,2 @@ if (name.match(/^\./)) {

}
return fs.stat("".concat(path, "/").concat(name), function (error, stats) {

@@ -44,7 +38,5 @@ if (error) {

}
return done(null, stats.isFile());
});
};
return fs.readdir(path, function (error, names) {

@@ -56,3 +48,2 @@ if (error) {

}
return async.filter(names, isFile, function (error, files) {

@@ -66,9 +57,29 @@ return res.json({

});
app.get('/plugin/assets/index', cors, function (req, res) {
var _walk;
_walk = function walk(root) {
return fs.readdirSync("".concat(argv.assets, "/").concat(root)).flatMap(function (name) {
var path, stat;
path = "".concat(root, "/").concat(name);
stat = fs.statSync("".concat(argv.assets, "/").concat(path));
if (stat.isDirectory()) {
return _walk(path);
} else {
return {
file: path,
size: stat.size
};
}
});
};
return res.json(_walk(""));
});
app.post('/plugin/assets/upload', function (req, res) {
var form, ref, ref1, ref2, ref3;
if (!(((ref = req.session) != null ? (ref1 = ref.passport) != null ? ref1.user : void 0 : void 0) || ((ref2 = req.session) != null ? ref2.email : void 0) || ((ref3 = req.session) != null ? ref3.friend : void 0))) {
return res.status(401).send("must login");
}
if (!app.securityhandler.isAuthorized(req)) {
return res.status(401).send("must be owner");
}
form = new formidable.IncomingForm();

@@ -80,7 +91,5 @@ form.multiples = true;

var assets;
if (name !== 'assets') {
return;
}
assets = (value || '').match(/([\w\/-]*)/)[1];

@@ -108,7 +117,5 @@ form.uploadDir = "".concat(argv.assets, "/").concat(assets);

var assets, file, ref, ref1, ref2, ref3, toRemove;
if (!(((ref = req.session) != null ? (ref1 = ref.passport) != null ? ref1.user : void 0 : void 0) || ((ref2 = req.session) != null ? ref2.email : void 0) || ((ref3 = req.session) != null ? ref3.friend : void 0))) {
return res.status(401).send("must login");
}
file = basename(req.query.file || '');

@@ -121,3 +128,2 @@ assets = (req.query.assets || '').match(/([\w\/-]*)/)[1];

}
return res.status(200).send('ok');

@@ -127,3 +133,2 @@ });

};
module.exports = {

@@ -130,0 +135,0 @@ startServer: startServer

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