Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ep_adminpads2

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ep_adminpads2 - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

95

index.js

@@ -1,12 +0,11 @@

const eejs = require("ep_etherpad-lite/node/eejs");
const padManager = require("ep_etherpad-lite/node/db/PadManager");
const api = require("ep_etherpad-lite/node/db/API");
const eejs = require('ep_etherpad-lite/node/eejs');
const padManager = require('ep_etherpad-lite/node/db/PadManager');
const api = require('ep_etherpad-lite/node/db/API');
const queryLimit = 12;
RegExp.quote = function (x) {
return x.toString().replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&")
return x.toString().replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
};
const isNumeric = function (arg) {
return typeof (arg) == "number" || (typeof (arg) == "string" && parseInt(arg));
return typeof arg == 'number' || (typeof arg == 'string' && parseInt(arg));
};

@@ -22,17 +21,15 @@

let data = {
progress: 1
, message: "Search done."
, query: query
, total: pads.length
}
, maxResult = 0
, result = []
;
if (query["pattern"] != null && query["pattern"] !== "") {
let pattern = "*" + query.pattern + "*";
progress: 1,
message: 'Search done.',
query: query,
total: pads.length,
},
maxResult = 0,
result = [];
if (query['pattern'] != null && query['pattern'] !== '') {
let pattern = '*' + query.pattern + '*';
pattern = RegExp.quote(pattern);
pattern = pattern.replace(/(\\\*)+/g, ".*");
pattern = "^" + pattern + "$";
let regex = new RegExp(pattern, "i");
pattern = pattern.replace(/(\\\*)+/g, '.*');
pattern = '^' + pattern + '$';
let regex = new RegExp(pattern, 'i');
pads.forEach(function (padID) {

@@ -72,26 +69,32 @@ if (regex.test(padID)) {

rs.forEach(function (value) {
entrySet = {padName: value, lastEdited: "", userCount: 0};
entrySet = {padName: value, lastEdited: '', userCount: 0};
data.results.push(entrySet);
});
let getEdited = [];
if (data.results.length > 0) {
data.results.forEach(function (value) {
let resultObject = api.getLastEdited(value.padName);
value.lastEdited = resultObject.lastEdited;
resultObject = api.padUsersCount(value.padName);
value.userCount = resultObject.padUsersCount;
getEdited.push(
api.getLastEdited(value.padName)
.then((resultObject) => {
value.lastEdited = resultObject.lastEdited;
resultObject = api.padUsersCount(value.padName);
value.userCount = resultObject.padUsersCount;
}));
});
} else {
data.message = "No results";
data.message = 'No results';
}
await Promise.all(getEdited);
return data;
}
},
};
exports.registerRoute = async function (hook_name, args) {
args.app.get("/admin/pads", function (req, res) {
args.app.get('/admin/pads', function (req, res) {
let render_args = {
errors: []
errors: [],
};
res.send(eejs.require("ep_adminpads2/templates/admin/pads.html", render_args));
res.send(eejs.require('ep_adminpads2/templates/admin/pads.html', render_args));
});

@@ -103,15 +106,15 @@ };

exports.socketio = function (hook_name, args) {
io = args.io.of("/pluginfw/admin/pads");
io.on("connection", function (socket) {
socket.on("load", async function (query) {
let result = await pads.search({pattern: "", offset: 0, limit: queryLimit});
socket.emit("search-result", result);
io = args.io.of('/pluginfw/admin/pads');
io.on('connection', function (socket) {
socket.on('load', async function (query) {
let result = await pads.search({pattern: '', offset: 0, limit: queryLimit});
socket.emit('search-result', result);
});
socket.on("search", async function (query) {
socket.on('search', async function (query) {
let result = await pads.search(query);
socket.emit("search-result", result);
socket.emit('search-result', result);
});
socket.on("delete", async function (padId) {
socket.on('delete', async function (padId) {
let padExists = await padManager.doesPadExists(padId);

@@ -122,3 +125,3 @@ if (padExists) {

await pad.remove();
socket.emit("progress", {progress: 1});
socket.emit('progress', {progress: 1});
}

@@ -130,13 +133,11 @@ });

exports.updatePads = async function (hook_name, args) {
io.emit("progress", {progress: 1});
io.emit('progress', {progress: 1});
};
exports.eejsBlock_adminMenu = async function (hook_name, args) {
let hasAdminUrlPrefix = (args.content.indexOf("<a href=\"admin/") !== -1)
, hasOneDirDown = (args.content.indexOf("<a href=\"../") !== -1)
, hasTwoDirDown = (args.content.indexOf("<a href=\"../../") !== -1)
, urlPrefix = hasAdminUrlPrefix ? "admin/" : hasTwoDirDown ? "../../" : hasOneDirDown ? "../" : ""
;
args.content = args.content + "<li><a href=\"" + urlPrefix + "pads\">Manage pads</a></li>";
let hasAdminUrlPrefix = args.content.indexOf('<a href="admin"') !== -1,
hasOneDirDown = args.content.indexOf('<a href="../') !== -1,
hasTwoDirDown = args.content.indexOf('<a href="../../') !== -1,
urlPrefix = hasAdminUrlPrefix ? 'admin/' : hasTwoDirDown ? '../../' : hasOneDirDown ? '../' : '';
args.content = args.content + '<li><a href="' + urlPrefix + 'pads">Manage pads</a></li>';
};
{
"name": "ep_adminpads2",
"version": "0.0.4",
"version": "0.0.5",
"description": "Etherpad plugin to list and delete pads in /admin.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/rhansen/ep_adminpads2",

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