v1.18.x
Julian Lam 10 years ago
parent c26f274392
commit a72501f3b4

@ -1,12 +1,14 @@
var nconf = require('nconf'), var nconf = require('nconf'),
validator = require('validator'), validator = require('validator'),
async = require('async'),
plugins = require('../plugins'); plugins = require('../plugins');
module.exports = function(Meta) { module.exports = function(Meta) {
Meta.tags = {}; Meta.tags = {};
Meta.tags.parse = function(meta, link, callback) { Meta.tags.parse = function(meta, link, callback) {
var defaultMetaTags = [{ async.parallel([
async.apply(plugins.fireHook, 'filter:meta.getMetaTags', [{
name: 'viewport', name: 'viewport',
content: 'width=device-width, initial-scale=1.0, user-scalable=no' content: 'width=device-width, initial-scale=1.0, user-scalable=no'
}, { }, {
@ -27,32 +29,33 @@ module.exports = function(Meta) {
}, { }, {
name: 'msapplication-square150x150logo', name: 'msapplication-square150x150logo',
content: Meta.config['brand:logo'] || '' content: Meta.config['brand:logo'] || ''
}], }]),
defaultLinkTags = [{ async.apply(plugins.fireHook, 'filter:meta.getLinkTags', [{
rel: 'apple-touch-icon', rel: 'apple-touch-icon',
href: nconf.get('relative_path') + '/apple-touch-icon' href: nconf.get('relative_path') + '/apple-touch-icon'
}]; }])
], function(err, tags) {
meta = tags[0].concat(meta || []).map(function(tag) {
if(!tag || typeof tag.content !== 'string') {
winston.warn('Invalid meta tag. ', tag);
return tag;
}
meta = defaultMetaTags.concat(meta || []).map(function(tag) { tag.content = validator.escape(tag.content);
if(!tag || typeof tag.content !== 'string') {
winston.warn('Invalid meta tag. ', tag);
return tag; return tag;
} });
tag.content = validator.escape(tag.content); link = tags[1].concat(link || []);
return tag; link.unshift({
}); rel: "icon",
type: "image/x-icon",
link = defaultLinkTags.concat(link || []); href: nconf.get('relative_path') + '/favicon.ico'
link.unshift({ });
rel: "icon",
type: "image/x-icon",
href: nconf.get('relative_path') + '/favicon.ico'
});
callback(null, { callback(null, {
meta: meta, meta: meta,
link: link link: link
});
}); });
}; };
}; };
Loading…
Cancel
Save