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.1 to 0.4.0-rc.0

59

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,6 +156,5 @@ file = files[i];

}
return results;
}().join("<br>"));
$report.find('button.copy').click(function (e) {
$report.find('button.copy').on('click', function (e) {
var href;

@@ -192,3 +166,3 @@ href = $(e.target).parent().find('a').attr('href');

});
return $report.find('button.delete').click(function (e) {
return $report.find('button.delete').on('click', function (e) {
var href;

@@ -199,7 +173,5 @@ href = $(e.target).parent().find('a').attr('href');

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

@@ -215,6 +187,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() {

@@ -224,18 +194,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++) {

@@ -246,16 +211,14 @@ site = ref[i];

}
return results;
};
bind = function bind($item, item) {
var $button, $input, assets, upload;
assets = item.text.match(/([\w\/-]*)/)[1];
$item.dblclick(function () {
$item.on('dblclick', function () {
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');
$input = $item.find('input');
$button.click(function (e) {
$button.on('click', function (e) {
return $input.click();

@@ -275,10 +238,7 @@ });

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 = {

4

package.json
{
"name": "wiki-plugin-assets",
"version": "0.3.1",
"version": "0.4.0-rc.0",
"description": "Federated Wiki - Assets Plugin",

@@ -29,3 +29,3 @@ "keywords": [

"grunt-mocha-test": "^0.13.2",
"mocha": "^6.1.4"
"mocha": "^10.1.0"
},

@@ -32,0 +32,0 @@ "license": "MIT",

@@ -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) {

@@ -67,12 +58,6 @@ return res.json({

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");
}
var form;
if (!app.securityhandler.isAuthorized(req)) {
return res.status(401).send("must be owner");
return res.status(401).send("must be logged in owner");
}
form = new formidable.IncomingForm();

@@ -84,7 +69,5 @@ form.multiples = true;

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

@@ -112,7 +95,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 || '');

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

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

@@ -131,3 +111,2 @@ });

};
module.exports = {

@@ -134,0 +113,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