summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/generate/plugin.js70
-rw-r--r--lib/generate/site/index.js23
2 files changed, 58 insertions, 35 deletions
diff --git a/lib/generate/plugin.js b/lib/generate/plugin.js
index b51d1ff..77bbee5 100644
--- a/lib/generate/plugin.js
+++ b/lib/generate/plugin.js
@@ -80,6 +80,35 @@ Plugin.prototype.callHook = function(name, args) {
});
};
+// Normalize a list of plugin name to use
+Plugin.normalizeNames = function(names) {
+ // Normalize list to an array
+ names = _.isString(names) ? names.split(":") : (names || []);
+
+ // List plugins to remove
+ var toremove = _.chain(names)
+ .filter(function(name) {
+ return name.length > 0 && name[0] == "-";
+ })
+ .map(function(name) {
+ return name.slice(1)
+ })
+ .value();
+
+ // Merge with defaults
+ names = _.chain(names)
+ .concat(Plugin.defaults)
+ .uniq()
+ .value();
+
+ // Remove plugins starting with
+ names = _.filter(names, function(name) {
+ return !_.contains(toremove, name) && !(name.length > 0 && name[0] == "-");
+ });
+
+ return names;
+};
+
// Extract data from a list of plugin
Plugin.fromList = function(names) {
var failed = [];
@@ -118,40 +147,19 @@ Plugin.fromList = function(names) {
return plugin.callHook(name, args);
})
}, Q());
- }
+ },
+ 'template': function(name) {
+ var withTpl = _.find(plugins, function(plugin) {
+ return (plugin.infos.templates
+ && plugin.infos.templates[name]);
+ });
+
+ if (!withTpl) return null;
+ return withTpl.resolveFile(withTpl.infos.templates[name]);
+ }
});
};
-
-// Normalize a list of plugin name to use
-Plugin.normalizeNames = function(names) {
- // Normalize list to an array
- names = _.isString(names) ? names.split(":") : (names || []);
-
- // List plugins to remove
- var toremove = _.chain(names)
- .filter(function(name) {
- return name.length > 0 && name[0] == "-";
- })
- .map(function(name) {
- return name.slice(1)
- })
- .value();
-
- // Merge with defaults
- names = _.chain(names)
- .concat(Plugin.defaults)
- .uniq()
- .value();
-
- // Remove plugins starting with
- names = _.filter(names, function(name) {
- return !_.contains(toremove, name) && !(name.length > 0 && name[0] == "-");
- });
-
- return names;
-};
-
// Default plugins
Plugin.defaults = [
"mixpanel"
diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js
index 9d738be..eaba6ee 100644
--- a/lib/generate/site/index.js
+++ b/lib/generate/site/index.js
@@ -30,13 +30,28 @@ var Generator = function() {
this.revision = Date.now();
this.indexer = indexer();
-
- // Load base template
- this.template = swig.compileFile(path.resolve(this.options.theme, 'templates/site.html'));
- this.langsTemplate = swig.compileFile(path.resolve(this.options.theme, 'templates/langs.html'));
};
util.inherits(Generator, BaseGenerator);
+// Load all templates
+Generator.prototype.loadTemplates = function() {
+ this.template = swig.compileFile(
+ this.plugins.template("site") || path.resolve(this.options.theme, 'templates/site.html')
+ );
+ this.langsTemplate = swig.compileFile(
+ this.plugins.template("langs") || path.resolve(this.options.theme, 'templates/langs.html')
+ );
+};
+
+// Load plugins
+Generator.prototype.loadPlugins = function() {
+ var that = this;
+
+ return BaseGenerator.prototype.loadPlugins.apply(this)
+ .then(function() {
+ return that.loadTemplates();
+ });
+};
// Generate a template
Generator.prototype._writeTemplate = function(tpl, options, output) {