mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-06 12:31:33 +01:00
Add OSD
This commit is contained in:
@@ -21,6 +21,7 @@ var utils = require('../public/src/utils');
|
||||
require('./meta/errors')(Meta);
|
||||
require('./meta/tags')(Meta);
|
||||
require('./meta/dependencies')(Meta);
|
||||
require('./meta/osd')(Meta);
|
||||
Meta.templates = require('./meta/templates');
|
||||
Meta.blacklist = require('./meta/blacklist');
|
||||
Meta.languages = require('./meta/languages');
|
||||
|
||||
@@ -5,7 +5,7 @@ var winston = require('winston');
|
||||
|
||||
var buildStart;
|
||||
|
||||
var valid = ['js', 'clientCSS', 'acpCSS', 'tpl', 'lang', 'sound'];
|
||||
var valid = ['js', 'clientCSS', 'acpCSS', 'tpl', 'lang', 'sound', 'osd'];
|
||||
|
||||
exports.buildAll = function (callback) {
|
||||
exports.build(valid.join(','), callback);
|
||||
@@ -117,6 +117,12 @@ 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);
|
||||
|
||||
41
src/meta/osd.js
Normal file
41
src/meta/osd.js
Normal file
@@ -0,0 +1,41 @@
|
||||
'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');
|
||||
|
||||
module.exports = function(Meta){
|
||||
Meta.osd = {};
|
||||
Meta.osd.build = function(callback){
|
||||
var osdObject = {
|
||||
"OpenSearchDescription": [
|
||||
{
|
||||
_attr: {
|
||||
"xmlns": "http://a9.com/-/spec/opensearch/1.1/"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ShortName": String(Meta.config.title || Meta.config.browserTitle || 'NodeBB')
|
||||
},
|
||||
{
|
||||
"Description": String(Meta.config.description || '')
|
||||
},
|
||||
{
|
||||
"Url": [
|
||||
{
|
||||
_attr: {
|
||||
"type": "text/html",
|
||||
"method": "get",
|
||||
"template": nconf.get('url') + '/search?term={searchTerms}&in=titlesposts'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
fs.writeFile(osdFilePath, xml([osdObject], {declaration: true, indent: '\t'}), callback);
|
||||
}
|
||||
};
|
||||
@@ -60,6 +60,14 @@ module.exports = function (Meta) {
|
||||
rel: 'manifest',
|
||||
href: nconf.get('relative_path') + '/manifest.json',
|
||||
}];
|
||||
|
||||
if(plugins.hasListeners('filter:search.query')){
|
||||
defaultLinks.push({
|
||||
rel: 'search',
|
||||
type: 'application/opensearchdescription+xml',
|
||||
href: nconf.get('relative_path') + '/assets/osd.xml',
|
||||
});
|
||||
}
|
||||
|
||||
// Touch icons for mobile-devices
|
||||
if (Meta.config['brand:touchIcon']) {
|
||||
|
||||
Reference in New Issue
Block a user