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

widget-loader

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

widget-loader - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

69

lib/loader.js

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

var App = opts.App;
var AppCMS = opts.App;
var widgetDir = opts.widgetDir;
var SlimAppCopy = App.widgetAPI();
// Load apps through a psuedo sandbox

@@ -25,7 +23,7 @@ function loadWidget(widgetPath) {

var sandbox = new WidgetSandbox(opts);
return sandbox.loadWidget(widgetPath);
}
function getWidget(name) {

@@ -35,3 +33,3 @@ // Grab the app class to instantiate

var app;
// Check for an actual class, otherwise just use whatever was returned

@@ -43,18 +41,18 @@ if (_.isFunction(AppClass)) {

}
return app;
}
function getTemplate(widgetName) {
var templatePath = path.join(widgetDir, widgetName, 'template.hbs');
return fs.readFileSync(templatePath, 'utf8');
}
// loop through the widgets directory and load widgets with templates
function buildWidgets() {
var currentWidget;
function build(widgetName) {

@@ -69,3 +67,3 @@ fs.lstat(path.join(widgetDir, widgetName), function(err, stat) {

}
// loops through the widgets directory

@@ -76,26 +74,26 @@ fs.readdir(widgetDir, function(err, widgets) {

}
function matchPaths(urlPath, widgetPath) {
if (urlPath === widgetPath) {
return true;
}
var urlArr = urlPath.split('/');
var widgetArr = widgetPath.split('/');
var isMatch = false;
if (urlArr.length !== widgetArr.length) {
return false;
}
if (widgetArr[widgetArr.length - 1] === ':any') {
widgetArr[widgetArr.length - 1] = urlArr[urlArr.length - 1];
}
return urlArr.join('') === widgetArr.join('');
}
function matchRoute(routes, page) {

@@ -105,9 +103,9 @@ if (routes.length === 0 || routes.indexOf(page) > -1) {

}
var isMatch = false;
var i;
for (i = 0; i < routes.length; i++) {
isMatch = matchPaths(page, routes[i]);
if (isMatch) {

@@ -117,10 +115,10 @@ break;

}
return isMatch;
}
function sortWidgets (widgetCollection) {
var widgetPositions = _.keys(widgetCollection);
_.each(widgetPositions, function (key) {

@@ -131,7 +129,7 @@ widgetCollection[key].sort(function (obj1, obj2) {

});
return widgetCollection;
}
// load widgets before any requests can come

@@ -157,3 +155,3 @@ buildWidgets();

return function () {
return widget.exec(SlimAppCopy)
return widget.exec(AppCMS)
.then(function (collection) {

@@ -202,2 +200,1 @@

};
{
"name": "widget-loader",
"version": "0.1.0",
"version": "0.1.1",
"description": "Widget loader for WidGet CMS",

@@ -5,0 +5,0 @@ "main": "index.js",

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