Node.js based forum software built for the modern web
plugins - filter:header.build allows plugins to add custom navigation to header
psychobunnya63732027f9b
diff --git a/public/templates/header.tpl b/public/templates/header.tplindex 398c99de88..d03db16b41 100644--- a/public/templates/header.tpl+++ b/public/templates/header.tpl@@ -59,9 +59,11 @@<li class="visible-xs"><a href="/search">[[global:header.search]]</a></li>- <li>- <a href="/"></a>+ <!-- BEGIN navigation -->+ <li class="{navigation.class}">+ <a href="{navigation.route}">{navigation.text}</a></li>+ <!-- END navigation --></ul><form id="search-form" class="navbar-form navbar-right hidden-xs" role="search" method="GET" action="">diff --git a/src/webserver.js b/src/webserver.jsindex 2860aedef6..74ee7f5f67 100644--- a/src/webserver.js+++ b/src/webserver.js@@ -44,36 +44,44 @@ var express = require('express'),* accepts: metaTags*/app.build_header = function (options, callback) {- var defaultMetaTags = [{- name: 'viewport',- content: 'width=device-width, initial-scale=1.0, user-scalable=no'- }, {- name: 'content-type',- content: 'text/html; charset=UTF-8'- }, {- name: 'apple-mobile-web-app-capable',- content: 'yes'- }, {- property: 'og:site_name',- content: meta.config.title || 'NodeBB'- }, {- property: 'keywords',- content: meta.config['keywords'] || ''- }],- metaString = utils.buildMetaTags(defaultMetaTags.concat(options.metaTags || [])),- templateValues = {- cssSrc: meta.config['theme:src'] || nconf.get('relative_path') + '/vendor/bootstrap/css/bootstrap.min.css',- pluginCSS: plugins.cssFiles.map(function(file) { return { path: file } }),- title: meta.config.title || 'NodeBB',- browserTitle: meta.config.title || 'NodeBB',- csrf: options.res.locals.csrf_token,- relative_path: nconf.get('relative_path'),- meta_tags: metaString,- clientScripts: clientScripts- };-- translator.translate(templates.header.parse(templateValues), function(template) {- callback(null, template);+ var custom_header = {+ 'navigation': []+ };++ plugins.fireHook('filter:header.build', custom_header, function(err, custom_header) {+ console.log(custom_header);+ var defaultMetaTags = [{+ name: 'viewport',+ content: 'width=device-width, initial-scale=1.0, user-scalable=no'+ }, {+ name: 'content-type',+ content: 'text/html; charset=UTF-8'+ }, {+ name: 'apple-mobile-web-app-capable',+ content: 'yes'+ }, {+ property: 'og:site_name',+ content: meta.config.title || 'NodeBB'+ }, {+ property: 'keywords',+ content: meta.config['keywords'] || ''+ }],+ metaString = utils.buildMetaTags(defaultMetaTags.concat(options.metaTags || [])),+ templateValues = {+ cssSrc: meta.config['theme:src'] || nconf.get('relative_path') + '/vendor/bootstrap/css/bootstrap.min.css',+ pluginCSS: plugins.cssFiles.map(function(file) { return { path: file } }),+ title: meta.config.title || 'NodeBB',+ browserTitle: meta.config.title || 'NodeBB',+ csrf: options.res.locals.csrf_token,+ 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);+ });});};