mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-06 23:00:08 +01:00
Changed Serving Method
This commit is contained in:
@@ -5,7 +5,7 @@ var winston = require('winston');
|
||||
|
||||
var buildStart;
|
||||
|
||||
var valid = ['js', 'clientCSS', 'acpCSS', 'tpl', 'lang', 'sound', 'osd'];
|
||||
var valid = ['js', 'clientCSS', 'acpCSS', 'tpl', 'lang', 'sound'];
|
||||
|
||||
exports.buildAll = function (callback) {
|
||||
exports.build(valid.join(','), callback);
|
||||
@@ -117,12 +117,6 @@ exports.buildTargets = function (targets, callback) {
|
||||
meta.sounds.build(step.bind(this, startTime, target, next));
|
||||
break;
|
||||
|
||||
case 'osd':
|
||||
winston.info('[build] Building OpenSearchDocument XML');
|
||||
startTime = Date.now();
|
||||
meta.osd.build(step.bind(this, startTime, target, next));
|
||||
break;
|
||||
|
||||
default:
|
||||
winston.warn('[build] Unknown build target: \'' + target + '\'');
|
||||
setImmediate(next);
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var xml = require('xml');
|
||||
var fs = require('fs');
|
||||
var nconf = require('nconf');
|
||||
|
||||
var osdFilePath = path.join(__dirname, '../../build/public/osd.xml');
|
||||
var plugins = require('../plugins');
|
||||
|
||||
module.exports = function (Meta) {
|
||||
Meta.osd = {};
|
||||
Meta.osd.build = function (callback) {
|
||||
function generateXML () {
|
||||
var osdObject = {
|
||||
OpenSearchDescription: [
|
||||
{
|
||||
@@ -36,6 +34,12 @@ module.exports = function (Meta) {
|
||||
},
|
||||
],
|
||||
};
|
||||
fs.writeFile(osdFilePath, xml([osdObject], { declaration: true, indent: '\t' }), callback);
|
||||
return xml([osdObject], { declaration: true, indent: '\t' });
|
||||
}
|
||||
Meta.osd.handleOSDRequest = function (req, res, next) {
|
||||
if (plugins.hasListeners('filter:search.query')) {
|
||||
res.type('application/xml').send(generateXML());
|
||||
}
|
||||
next();
|
||||
};
|
||||
};
|
||||
|
||||
@@ -65,7 +65,7 @@ module.exports = function (Meta) {
|
||||
defaultLinks.push({
|
||||
rel: 'search',
|
||||
type: 'application/opensearchdescription+xml',
|
||||
href: nconf.get('relative_path') + '/assets/osd.xml',
|
||||
href: nconf.get('relative_path') + '/osd.xml',
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -8,4 +8,5 @@ module.exports = function (app, middleware, controllers) {
|
||||
app.get('/robots.txt', controllers.robots);
|
||||
app.get('/manifest.json', controllers.manifest);
|
||||
app.get('/css/previews/:theme', controllers.admin.themes.get);
|
||||
app.get('/osd.xml', require('../meta').osd.handleOSDRequest);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user