|
|
@ -1,19 +1,17 @@
|
|
|
|
'use strict';
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
var nconf = require('nconf');
|
|
|
|
const nconf = require('nconf');
|
|
|
|
var async = require('async');
|
|
|
|
const winston = require('winston');
|
|
|
|
var winston = require('winston');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var plugins = require('../plugins');
|
|
|
|
const plugins = require('../plugins');
|
|
|
|
var Meta = require('../meta');
|
|
|
|
const Meta = require('../meta');
|
|
|
|
var utils = require('../utils');
|
|
|
|
const utils = require('../utils');
|
|
|
|
|
|
|
|
|
|
|
|
var Tags = module.exports;
|
|
|
|
const Tags = module.exports;
|
|
|
|
|
|
|
|
|
|
|
|
Tags.parse = function (req, data, meta, link, callback) {
|
|
|
|
Tags.parse = async (req, data, meta, link) => {
|
|
|
|
async.parallel({
|
|
|
|
// Meta tags
|
|
|
|
tags: function (next) {
|
|
|
|
const defaultTags = [{
|
|
|
|
var defaultTags = [{
|
|
|
|
|
|
|
|
name: 'viewport',
|
|
|
|
name: 'viewport',
|
|
|
|
content: 'width=device-width, initial-scale=1.0',
|
|
|
|
content: 'width=device-width, initial-scale=1.0',
|
|
|
|
}, {
|
|
|
|
}, {
|
|
|
@ -50,9 +48,7 @@ Tags.parse = function (req, data, meta, link, callback) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
plugins.fireHook('filter:meta.getMetaTags', { req: req, data: data, tags: defaultTags }, next);
|
|
|
|
// Link Tags
|
|
|
|
},
|
|
|
|
|
|
|
|
links: function (next) {
|
|
|
|
|
|
|
|
var defaultLinks = [{
|
|
|
|
var defaultLinks = [{
|
|
|
|
rel: 'icon',
|
|
|
|
rel: 'icon',
|
|
|
|
type: 'image/x-icon',
|
|
|
|
type: 'image/x-icon',
|
|
|
@ -102,12 +98,11 @@ Tags.parse = function (req, data, meta, link, callback) {
|
|
|
|
href: nconf.get('relative_path') + nconf.get('upload_url') + '/system/touchicon-192.png',
|
|
|
|
href: nconf.get('relative_path') + nconf.get('upload_url') + '/system/touchicon-192.png',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
plugins.fireHook('filter:meta.getLinkTags', { req: req, data: data, links: defaultLinks }, next);
|
|
|
|
|
|
|
|
},
|
|
|
|
const results = await utils.promiseParallel({
|
|
|
|
}, async function (err, results) {
|
|
|
|
tags: plugins.fireHook('filter:meta.getMetaTags', { req: req, data: data, tags: defaultTags }),
|
|
|
|
if (err) {
|
|
|
|
links: plugins.fireHook('filter:meta.getLinkTags', { req: req, data: data, links: defaultLinks }),
|
|
|
|
return callback(err);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
meta = results.tags.tags.concat(meta || []).map(function (tag) {
|
|
|
|
meta = results.tags.tags.concat(meta || []).map(function (tag) {
|
|
|
|
if (!tag || typeof tag.content !== 'string') {
|
|
|
|
if (!tag || typeof tag.content !== 'string') {
|
|
|
@ -132,11 +127,10 @@ Tags.parse = function (req, data, meta, link, callback) {
|
|
|
|
|
|
|
|
|
|
|
|
link = results.links.links.concat(link || []);
|
|
|
|
link = results.links.links.concat(link || []);
|
|
|
|
|
|
|
|
|
|
|
|
callback(null, {
|
|
|
|
return {
|
|
|
|
meta: meta,
|
|
|
|
meta: meta,
|
|
|
|
link: link,
|
|
|
|
link: link,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function addIfNotExists(meta, keyName, tagName, value) {
|
|
|
|
function addIfNotExists(meta, keyName, tagName, value) {
|
|
|
|