Node.js based forum software built for the modern web
Add Support for Firefox OSD
RoiEX1fd160a4e63d
diff --git a/public/src/modules/helpers.js b/public/src/modules/helpers.jsindex 28f853ed60..736926101d 100644--- a/public/src/modules/helpers.js+++ b/public/src/modules/helpers.js@@ -77,8 +77,9 @@var type = tag.type ? 'type="' + tag.type + '" ' : '';var href = tag.href ? 'href="' + tag.href + '" ' : '';var sizes = tag.sizes ? 'sizes="' + tag.sizes + '" ' : '';+ var title = tag.title ? 'title="' + tag.title + '" ' : '';- return '<link ' + link + rel + type + sizes + href + '/>\n\t';+ return '<link ' + link + rel + type + sizes + title + href + '/>\n\t';}function stringify(obj) {diff --git a/src/controllers/osd.js b/src/controllers/osd.jsindex c83f7f142c..856d956ef5 100644--- a/src/controllers/osd.js+++ b/src/controllers/osd.js@@ -8,7 +8,7 @@ var meta = require('../meta');module.exports.handle = function (req, res, next) {if (plugins.hasListeners('filter:search.query')) {- res.type('application/xml').send(generateXML());+ res.type('application/opensearchdescription+xml').send(generateXML());} else {next();}@@ -17,9 +17,21 @@ module.exports.handle = function (req, res, next) {function generateXML() {return xml([{OpenSearchDescription: [- { _attr: { xmlns: 'http://a9.com/-/spec/opensearch/1.1/' } },- { ShortName: String(meta.config.title || meta.config.browserTitle || 'NodeBB') },- { Description: String(meta.config.description || '') },+ { _attr: {+ xmlns: 'http://a9.com/-/spec/opensearch/1.1/',+ 'xmlns:moz': 'http://www.mozilla.org/2006/browser/search/',+ } },+ { ShortName: trimToLength(String(meta.config.title || meta.config.browserTitle || 'NodeBB'), 16) },+ { Description: trimToLength(String(meta.config.description || ''), 1024) },+ { InputEncoding: 'UTF-8' },+ { Image: [+ { _attr: {+ width: '16',+ height: '16',+ type: 'image/x-icon',+ } },+ nconf.get('url') + '/favicon.ico',+ ] },{ Url: {_attr: {type: 'text/html',@@ -27,6 +39,11 @@ function generateXML() {template: nconf.get('url') + '/search?term={searchTerms}&in=titlesposts',},} },+ { 'moz:SearchForm': nconf.get('url') + '/search' },],}], { declaration: true, indent: '\t' });}++function trimToLength(string, length) {+ return string.trim().substring(0, length).trim();+}diff --git a/src/meta/tags.js b/src/meta/tags.jsindex c347b18d4e..79cb04cded 100644--- a/src/meta/tags.js+++ b/src/meta/tags.js@@ -66,6 +66,7 @@ Tags.parse = function (req, data, meta, link, callback) {defaultLinks.push({rel: 'search',type: 'application/opensearchdescription+xml',+ title: validator.escape(String(Meta.config.title || Meta.config.browserTitle || 'NodeBB')),href: nconf.get('relative_path') + '/osd.xml',});}