strider-extension-loader
Advanced tools
Comparing version 0.4.3 to 0.4.4
@@ -26,3 +26,4 @@ | ||
function Loader(lesspaths) { | ||
function Loader(lesspaths, isNamespaced) { | ||
this.isNamespaced = isNamespaced; | ||
this.types = { | ||
@@ -33,5 +34,5 @@ 'job': job, | ||
'basic': basic | ||
} | ||
this.ids = {} | ||
this.lesspaths = lesspaths || [] | ||
}; | ||
this.ids = {}; | ||
this.lesspaths = lesspaths || []; | ||
this.extensions = { | ||
@@ -42,3 +43,3 @@ job: {}, | ||
basic: {} | ||
} | ||
}; | ||
} | ||
@@ -152,2 +153,4 @@ | ||
this.allExtensions(function (type, id, plugin, next) { | ||
var namespace = self.isNamespaced ? 'Config.' : ''; | ||
if (!plugin.config) { | ||
@@ -163,3 +166,3 @@ plugin.config = {} | ||
plugin.config = _.extend({ | ||
controller: type[0].toUpperCase() + type.slice(1) + 'Controller', | ||
controller: namespace + type[0].toUpperCase() + type.slice(1) + 'Controller', | ||
/* Defaults. If they don't exist, however, no error is thrown. | ||
@@ -214,4 +217,6 @@ template: 'config/config.html', | ||
this.allExtensions(function (type, id, plugin, next) { | ||
var name = types[type].userConfig || 'user' | ||
, config = name + 'Config' | ||
var namespace = self.isNamespaced ? 'Account.' : ''; | ||
var name = types[type].userConfig || 'user'; | ||
var config = name + 'Config'; | ||
if (!plugin[config]) return next(); | ||
@@ -225,3 +230,3 @@ if (!configs[type]) configs[type] = {} | ||
plugin[config] = _.extend({ | ||
controller: type[0].toUpperCase() + type.slice(1) + 'Controller', | ||
controller: namespace + type[0].toUpperCase() + type.slice(1) + 'Controller', | ||
/* Defaults. If they don't exist, however, no error is thrown. | ||
@@ -228,0 +233,0 @@ template: 'config/user.html', |
{ | ||
"name": "strider-extension-loader", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "Load Strider extensions", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
@@ -17,9 +17,12 @@ # Strider Extension Loader | ||
``` | ||
var Loader = require('strider-extension-loader') | ||
, loader = new Loader() | ||
var Loader = require('strider-extension-loader'); | ||
var loader = new Loader(); | ||
``` | ||
### new Loader(lesspaths) | ||
`lesspaths` is an optional list of directories that will be made | ||
available while compiling plugins' `less` style files. | ||
### new Loader(lesspaths, isNamespaced) | ||
* `lesspaths` is an optional list of directories that will be made | ||
available while compiling plugins' `less` style files. | ||
* `isNamespaced` is for backwards compatibility with older versions | ||
where the default type controllers e.g. `JobController` were not namespaced. | ||
For versions < 1.6.0 this property should NOT be set. | ||
@@ -34,3 +37,3 @@ ### .collectExtensions(dirs, done(err)) | ||
`extensions` looks like `{plugintype: {pluginid: loadedPlugin, ... }, ...}` | ||
`extensions` looks like `{ plugintype: { pluginid: loadedPlugin, ... }, ... }` | ||
@@ -47,3 +50,3 @@ The structure of the `loadedPlugin` object depend on the plugin type. | ||
Load all of the templates from all extensions. `templates` looks like | ||
`{templatename: stringtemplate, ...}`. | ||
`{ templatename: stringtemplate, ... }`. | ||
@@ -70,3 +73,3 @@ ### .initStaticDirs(app, done(err)) | ||
Configs look like `{plugintype: {pluginid: config, ...}, ...}` and | ||
Configs look like `{ plugintype: { pluginid: config, ...}, ... }` and | ||
`config` looks like: | ||
@@ -93,3 +96,3 @@ | ||
"config": { | ||
"controller": // defaults to "JobController" for job plugins, "ProviderController", etc. | ||
"controller": // defaults to "Config.JobController" for job plugins, "Config.ProviderController", etc. | ||
"script": // path where the js should be loaded from. Path defaults to "config/config.js" | ||
@@ -108,3 +111,3 @@ "style": // defaults to "config/config.less" | ||
controller for your plugin type. Take a look in | ||
[strider's public/javascript/pages/config.js](asd) for the source of | ||
[strider's `client/config/controllers` directory][config-controllers] for the source of | ||
those controllers. Basically, each controller makes available a | ||
@@ -189,3 +192,3 @@ `config` object on the scope, which is populated by the plugin's | ||
"config": { // project-specific configuration | ||
"controller": // defaults to "JobController" for job plugins, "ProviderController", etc. | ||
"controller": // defaults to "Config.JobController" for job plugins, "Config.ProviderController", etc. | ||
"script": // path where the js should be loaded from. Path defaults to "config/config.js" | ||
@@ -518,4 +521,4 @@ "style": // defaults to "config/config.less". Can be less or css | ||
- config ; main strider config | ||
- emitter ; for passing events | ||
- config -- main strider config | ||
- emitter -- for passing events | ||
- models | ||
@@ -525,3 +528,3 @@ - logger | ||
- auth | ||
- app ; the express app | ||
- app -- the express app | ||
- registerBlock | ||
@@ -532,6 +535,6 @@ | ||
```javascript | ||
ctx.registerBlock('HeaderBrand', function(context, cb){ | ||
ctx.registerBlock('HeaderBrand', function(context, cb) { | ||
// context has a lot of useful stuff on it: | ||
var email = context.currentUser.user.email | ||
var email = context.currentUser.user.email; | ||
@@ -541,4 +544,4 @@ // You can do some async processing here, but bear in mind | ||
cb(null, "<h1>FooStrider</h1>"); | ||
}) | ||
cb(null, '<h1>FooStrider</h1>'); | ||
}); | ||
``` | ||
@@ -555,4 +558,4 @@ | ||
"templates": { | ||
"HeaderBrand" : "<h1>An HTML String</h1>", | ||
"FooterTOS" : "./path/to/TOS.html" | ||
"HeaderBrand": "<h1>An HTML String</h1>", | ||
"FooterTOS": "./path/to/TOS.html" | ||
} | ||
@@ -570,1 +573,3 @@ } | ||
previous extensions. | ||
[config-controllers]: https://github.com/Strider-CD/strider/tree/master/client/config/controllers |
54736
869
563
17