plugins - filter:header.build allows plugins to add custom navigation to header

v1.18.x
psychobunny 12 years ago
parent 13d8f51f6a
commit a63732027f

@ -59,9 +59,11 @@
<li class="visible-xs"> <li class="visible-xs">
<a href="/search">[[global:header.search]]</a> <a href="/search">[[global:header.search]]</a>
</li> </li>
<li> <!-- BEGIN navigation -->
<a href="/"></a> <li class="{navigation.class}">
<a href="{navigation.route}">{navigation.text}</a>
</li> </li>
<!-- END navigation -->
</ul> </ul>
<form id="search-form" class="navbar-form navbar-right hidden-xs" role="search" method="GET" action=""> <form id="search-form" class="navbar-form navbar-right hidden-xs" role="search" method="GET" action="">

@ -44,36 +44,44 @@ var express = require('express'),
* accepts: metaTags * accepts: metaTags
*/ */
app.build_header = function (options, callback) { app.build_header = function (options, callback) {
var defaultMetaTags = [{ var custom_header = {
name: 'viewport', 'navigation': []
content: 'width=device-width, initial-scale=1.0, user-scalable=no' };
}, {
name: 'content-type', plugins.fireHook('filter:header.build', custom_header, function(err, custom_header) {
content: 'text/html; charset=UTF-8' console.log(custom_header);
}, { var defaultMetaTags = [{
name: 'apple-mobile-web-app-capable', name: 'viewport',
content: 'yes' content: 'width=device-width, initial-scale=1.0, user-scalable=no'
}, { }, {
property: 'og:site_name', name: 'content-type',
content: meta.config.title || 'NodeBB' content: 'text/html; charset=UTF-8'
}, { }, {
property: 'keywords', name: 'apple-mobile-web-app-capable',
content: meta.config['keywords'] || '' content: 'yes'
}], }, {
metaString = utils.buildMetaTags(defaultMetaTags.concat(options.metaTags || [])), property: 'og:site_name',
templateValues = { content: meta.config.title || 'NodeBB'
cssSrc: meta.config['theme:src'] || nconf.get('relative_path') + '/vendor/bootstrap/css/bootstrap.min.css', }, {
pluginCSS: plugins.cssFiles.map(function(file) { return { path: file } }), property: 'keywords',
title: meta.config.title || 'NodeBB', content: meta.config['keywords'] || ''
browserTitle: meta.config.title || 'NodeBB', }],
csrf: options.res.locals.csrf_token, metaString = utils.buildMetaTags(defaultMetaTags.concat(options.metaTags || [])),
relative_path: nconf.get('relative_path'), templateValues = {
meta_tags: metaString, cssSrc: meta.config['theme:src'] || nconf.get('relative_path') + '/vendor/bootstrap/css/bootstrap.min.css',
clientScripts: clientScripts pluginCSS: plugins.cssFiles.map(function(file) { return { path: file } }),
}; title: meta.config.title || 'NodeBB',
browserTitle: meta.config.title || 'NodeBB',
translator.translate(templates.header.parse(templateValues), function(template) { csrf: options.res.locals.csrf_token,
callback(null, template); relative_path: nconf.get('relative_path'),
meta_tags: metaString,
clientScripts: clientScripts,
navigation: custom_header.navigation
};
translator.translate(templates.header.parse(templateValues), function(template) {
callback(null, template);
});
}); });
}; };

Loading…
Cancel
Save