summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/generate/plugin.js15
-rw-r--r--lib/generate/site/index.js1
-rwxr-xr-xtheme/templates/layout.html6
3 files changed, 22 insertions, 0 deletions
diff --git a/lib/generate/plugin.js b/lib/generate/plugin.js
index 1edb62d..19eec86 100644
--- a/lib/generate/plugin.js
+++ b/lib/generate/plugin.js
@@ -160,6 +160,16 @@ Plugin.fromList = function(names, root) {
})
.object()
.value();
+ resources.html = {}
+
+ _.each(plugins, function(plugin) {
+ var html = plugin.infos.book.html || {};
+ _.each(html, function(code, key) {
+ if (!_.isFunction(code)) code = _.constant(code);
+ if (!resources.html[key]) resources.html[key] = [];
+ resources.html[key].push(code);
+ })
+ });
return Q({
'list': plugins,
@@ -179,6 +189,11 @@ Plugin.fromList = function(names, root) {
if (!withTpl) return null;
return withTpl.resolveFile(withTpl.infos.templates[name]);
+ },
+ 'html': function(tag, context, options) {
+ return _.map(resources.html[tag] || [], function(code) {
+ return code.call(context, options);
+ }).join("\n");
}
});
};
diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js
index 6033fb4..a135cda 100644
--- a/lib/generate/site/index.js
+++ b/lib/generate/site/index.js
@@ -81,6 +81,7 @@ Generator.prototype._writeTemplate = function(tpl, options, output, interpolate)
plugins: that.plugins,
pluginsConfig: JSON.stringify(that.options.pluginsConfig),
+ htmlSnippet: _.partialRight(that.plugins.html, that, options),
options: that.options
}, options));
diff --git a/theme/templates/layout.html b/theme/templates/layout.html
index 644e993..5f76e5e 100755
--- a/theme/templates/layout.html
+++ b/theme/templates/layout.html
@@ -1,6 +1,8 @@
<!DOCTYPE HTML>
<html lang="en-US" {% block htmlTag %}{% endblock %}>
+ {{ htmlSnippet("html:start")|default("") }}
<head prefix="og: http://ogp.me/ns# book: http://ogp.me/ns/book#">
+ {{ htmlSnippet("head:start")|default("") }}
{% block head %}
<meta charset="UTF-8">
<title>{% block title %} | {{ title }}{% endblock %}</title>
@@ -33,8 +35,10 @@
<link rel="shortcut icon" href="{{ staticBase }}/images/favicon.ico" type="image/x-icon">
{% endblock %}
+ {{ htmlSnippet("head:end")|default("") }}
</head>
<body>
+ {{ htmlSnippet("body:start")|default("") }}
{% block style %}
<link rel="stylesheet" href="{{ staticBase }}/style.css">
{% endblock %}
@@ -45,5 +49,7 @@
<script src="{{ staticBase }}/jsrepl/jsrepl.js" id="jsrepl-script"></script>
<script src="{{ staticBase }}/app.js"></script>
{% endblock %}
+ {{ htmlSnippet("body:end")|default("") }}
</body>
+ {{ htmlSnippet("html:end")|default("") }}
</html>