You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
805 B
JavaScript

8 years ago
'use strict';
var xml = require('xml');
var nconf = require('nconf');
var plugins = require('../plugins');
var meta = require('../meta');
module.exports = function (req, res, next) {
if (plugins.hasListeners('filter:search.query')) {
res.type('application/xml').send(generateXML());
} else {
next();
}
};
function generateXML() {
return xml([{
OpenSearchDescription: [
8 years ago
{ _attr: { xmlns: 'http://a9.com/-/spec/opensearch/1.1/' }},
{ ShortName: String(meta.config.title || meta.config.browserTitle || 'NodeBB') },
{ Description: String(meta.config.description || '') },
{ Url: [{
8 years ago
_attr: {
8 years ago
type: 'text/html',
method: 'get',
8 years ago
template: nconf.get('url') + '/search?term={searchTerms}&in=titlesposts',
},
}]},
8 years ago
],
}], { declaration: true, indent: '\t' });
}