From f761191fcaede5bb6b0ea388531cb0e640b8c9f1 Mon Sep 17 00:00:00 2001 From: RoiEX Date: Sun, 5 Mar 2017 14:45:30 +0100 Subject: [PATCH 01/19] Add OSD --- src/meta.js | 1 + src/meta/build.js | 8 +++++++- src/meta/osd.js | 41 +++++++++++++++++++++++++++++++++++++++++ src/meta/tags.js | 8 ++++++++ 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/meta/osd.js diff --git a/src/meta.js b/src/meta.js index 6cbccd70a1..f0c1756053 100644 --- a/src/meta.js +++ b/src/meta.js @@ -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'); diff --git a/src/meta/build.js b/src/meta/build.js index 9ba5ec89bf..cba910bf83 100644 --- a/src/meta/build.js +++ b/src/meta/build.js @@ -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); diff --git a/src/meta/osd.js b/src/meta/osd.js new file mode 100644 index 0000000000..35a614b6b7 --- /dev/null +++ b/src/meta/osd.js @@ -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); + } +}; \ No newline at end of file diff --git a/src/meta/tags.js b/src/meta/tags.js index fa88fa30b8..4655c2b555 100644 --- a/src/meta/tags.js +++ b/src/meta/tags.js @@ -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']) { From 431f5e1f0f451d4c1e0785440fa10d9a8397e094 Mon Sep 17 00:00:00 2001 From: RoiEX Date: Sun, 5 Mar 2017 14:56:50 +0100 Subject: [PATCH 02/19] Add missing dependency This deoendency is required by rss, but travis doesn't seem to notice that --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index d4bb4e53b5..9889f45992 100644 --- a/package.json +++ b/package.json @@ -94,6 +94,7 @@ "underscore.deep": "^0.5.1", "validator": "^6.1.0", "winston": "^2.1.0", + "xml": "^1.0.1", "xregexp": "~3.1.0" }, "devDependencies": { From eca150f39293e3d9c8743e8ad03b956a137aa1c5 Mon Sep 17 00:00:00 2001 From: RoiEX Date: Sun, 5 Mar 2017 15:10:35 +0100 Subject: [PATCH 03/19] Fix Tests --- src/meta/build.js | 2 +- src/meta/osd.js | 26 +++++++++++++------------- src/meta/tags.js | 12 ++++++------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/meta/build.js b/src/meta/build.js index cba910bf83..2c82459777 100644 --- a/src/meta/build.js +++ b/src/meta/build.js @@ -122,7 +122,7 @@ exports.buildTargets = function (targets, callback) { startTime = Date.now(); meta.osd.build(step.bind(this, startTime, target, next)); break; - + default: winston.warn('[build] Unknown build target: \'' + target + '\''); setImmediate(next); diff --git a/src/meta/osd.js b/src/meta/osd.js index 35a614b6b7..3928c535c3 100644 --- a/src/meta/osd.js +++ b/src/meta/osd.js @@ -7,35 +7,35 @@ var nconf = require('nconf'); var osdFilePath = path.join(__dirname, '../../build/public/osd.xml'); -module.exports = function(Meta){ +module.exports = function (Meta) { Meta.osd = {}; - Meta.osd.build = function(callback){ + Meta.osd.build = function (callback) { var osdObject = { - "OpenSearchDescription": [ + OpenSearchDescription: [ { _attr: { - "xmlns": "http://a9.com/-/spec/opensearch/1.1/" + xmlns: 'http://a9.com/-/spec/opensearch/1.1/', } }, { - "ShortName": String(Meta.config.title || Meta.config.browserTitle || 'NodeBB') + ShortName: String(Meta.config.title || Meta.config.browserTitle || 'NodeBB'), }, { - "Description": String(Meta.config.description || '') + Description: String(Meta.config.description || ''), }, { - "Url": [ + Url: [ { _attr: { - "type": "text/html", - "method": "get", - "template": nconf.get('url') + '/search?term={searchTerms}&in=titlesposts' + type: 'text/html', + method: 'get', + template: nconf.get('url') + '/search?term={searchTerms}&in=titlesposts', } } ] } ] }; - fs.writeFile(osdFilePath, xml([osdObject], {declaration: true, indent: '\t'}), callback); - } -}; \ No newline at end of file + fs.writeFile(osdFilePath, xml([osdObject], { declaration: true, indent: '\t' }), callback); + }; +}; diff --git a/src/meta/tags.js b/src/meta/tags.js index 4655c2b555..d54a07addc 100644 --- a/src/meta/tags.js +++ b/src/meta/tags.js @@ -60,13 +60,13 @@ module.exports = function (Meta) { rel: 'manifest', href: nconf.get('relative_path') + '/manifest.json', }]; - - if(plugins.hasListeners('filter:search.query')){ + + if (plugins.hasListeners('filter:search.query')) { defaultLinks.push({ - rel: 'search', - type: 'application/opensearchdescription+xml', - href: nconf.get('relative_path') + '/assets/osd.xml', - }); + rel: 'search', + type: 'application/opensearchdescription+xml', + href: nconf.get('relative_path') + '/assets/osd.xml', + }); } // Touch icons for mobile-devices From 0710c6488daa0b802c39cff22cd97a00b9777ce1 Mon Sep 17 00:00:00 2001 From: RoiEX Date: Sun, 5 Mar 2017 15:15:41 +0100 Subject: [PATCH 04/19] Fix trailing commas --- src/meta/osd.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/meta/osd.js b/src/meta/osd.js index 3928c535c3..dd11ff5d44 100644 --- a/src/meta/osd.js +++ b/src/meta/osd.js @@ -15,7 +15,7 @@ module.exports = function (Meta) { { _attr: { xmlns: 'http://a9.com/-/spec/opensearch/1.1/', - } + }, }, { ShortName: String(Meta.config.title || Meta.config.browserTitle || 'NodeBB'), @@ -30,11 +30,11 @@ module.exports = function (Meta) { type: 'text/html', method: 'get', template: nconf.get('url') + '/search?term={searchTerms}&in=titlesposts', - } - } + }, + }, ] - } - ] + }, + ], }; fs.writeFile(osdFilePath, xml([osdObject], { declaration: true, indent: '\t' }), callback); }; From 4082ca40c12fbb6f12909340f6dfe9a4f4e5ce0d Mon Sep 17 00:00:00 2001 From: RoiEX Date: Sun, 5 Mar 2017 15:20:35 +0100 Subject: [PATCH 05/19] Add last comma --- src/meta/osd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/meta/osd.js b/src/meta/osd.js index dd11ff5d44..05763baf50 100644 --- a/src/meta/osd.js +++ b/src/meta/osd.js @@ -32,7 +32,7 @@ module.exports = function (Meta) { template: nconf.get('url') + '/search?term={searchTerms}&in=titlesposts', }, }, - ] + ], }, ], }; From 743a7e00b4b0c88489bbc98dc88ca4dbfe060b33 Mon Sep 17 00:00:00 2001 From: Accalia de Elementia Date: Mon, 6 Mar 2017 13:14:15 +0000 Subject: [PATCH 06/19] fix: auto cropper on image upload selects maximum image area by default --- public/src/modules/pictureCropper.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/src/modules/pictureCropper.js b/public/src/modules/pictureCropper.js index 0ed62d3d8c..bbe0a76735 100644 --- a/public/src/modules/pictureCropper.js +++ b/public/src/modules/pictureCropper.js @@ -42,6 +42,7 @@ define('pictureCropper', ['translator', 'cropper'], function (translator, croppe var img = document.getElementById('cropped-image'); var cropperTool = new cropper.default(img, { aspectRatio: data.aspectRatio, + autoCropArea: 1, viewMode: 1, cropmove: function () { if (data.restrictImageDimension) { From 603d45fbfa493ed78c60c438a083accc38b6bb90 Mon Sep 17 00:00:00 2001 From: RoiEX Date: Mon, 6 Mar 2017 19:47:03 +0100 Subject: [PATCH 07/19] Changed Serving Method --- src/meta/build.js | 8 +------- src/meta/osd.js | 14 +++++++++----- src/meta/tags.js | 2 +- src/routes/meta.js | 1 + 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/meta/build.js b/src/meta/build.js index 2c82459777..9ba5ec89bf 100644 --- a/src/meta/build.js +++ b/src/meta/build.js @@ -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); diff --git a/src/meta/osd.js b/src/meta/osd.js index 05763baf50..4111a463d0 100644 --- a/src/meta/osd.js +++ b/src/meta/osd.js @@ -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(); }; }; diff --git a/src/meta/tags.js b/src/meta/tags.js index d54a07addc..5b1097d427 100644 --- a/src/meta/tags.js +++ b/src/meta/tags.js @@ -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', }); } diff --git a/src/routes/meta.js b/src/routes/meta.js index cfeeac5b9b..0d97468c84 100644 --- a/src/routes/meta.js +++ b/src/routes/meta.js @@ -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); }; From 710377ceeac4dc786dd1fa3c3e4ad4ddedccd0ff Mon Sep 17 00:00:00 2001 From: RoiEX Date: Mon, 6 Mar 2017 19:51:53 +0100 Subject: [PATCH 08/19] Remove space --- src/meta/osd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/meta/osd.js b/src/meta/osd.js index 4111a463d0..5db9578047 100644 --- a/src/meta/osd.js +++ b/src/meta/osd.js @@ -7,7 +7,7 @@ var plugins = require('../plugins'); module.exports = function (Meta) { Meta.osd = {}; - function generateXML () { + function generateXML() { var osdObject = { OpenSearchDescription: [ { From 186c1f40e9a6fe8e08d308484c65c25859ee1ef9 Mon Sep 17 00:00:00 2001 From: RoiEX Date: Mon, 6 Mar 2017 20:07:06 +0100 Subject: [PATCH 09/19] Refactor Code --- src/controllers/index.js | 1 + src/controllers/osd.js | 44 +++++++++++++++++++++++++++++++++++++++ src/meta.js | 1 - src/meta/osd.js | 45 ---------------------------------------- src/routes/meta.js | 2 +- 5 files changed, 46 insertions(+), 47 deletions(-) create mode 100644 src/controllers/osd.js delete mode 100644 src/meta/osd.js diff --git a/src/controllers/index.js b/src/controllers/index.js index 49c1c4c2c2..a02e3c9fbd 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -32,6 +32,7 @@ Controllers.mods = require('./mods'); Controllers.sitemap = require('./sitemap'); Controllers['404'] = require('./404'); Controllers.errors = require('./errors'); +Controllers.handleOSDRequest = require('./osd'); Controllers.home = function (req, res, next) { var route = meta.config.homePageRoute || (meta.config.homePageCustom || '').replace(/^\/+/, '') || 'categories'; diff --git a/src/controllers/osd.js b/src/controllers/osd.js new file mode 100644 index 0000000000..b05fac72c9 --- /dev/null +++ b/src/controllers/osd.js @@ -0,0 +1,44 @@ +'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: [ + { + _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', + }, + }, + ], + }, + ], + }], { declaration: true, indent: '\t' }); +} diff --git a/src/meta.js b/src/meta.js index f0c1756053..6cbccd70a1 100644 --- a/src/meta.js +++ b/src/meta.js @@ -21,7 +21,6 @@ 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'); diff --git a/src/meta/osd.js b/src/meta/osd.js deleted file mode 100644 index 5db9578047..0000000000 --- a/src/meta/osd.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; - -var xml = require('xml'); -var nconf = require('nconf'); - -var plugins = require('../plugins'); - -module.exports = function (Meta) { - Meta.osd = {}; - function generateXML() { - 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', - }, - }, - ], - }, - ], - }; - 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(); - }; -}; diff --git a/src/routes/meta.js b/src/routes/meta.js index 0d97468c84..e17533af05 100644 --- a/src/routes/meta.js +++ b/src/routes/meta.js @@ -8,5 +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); + app.get('/osd.xml', controllers.handleOSDRequest); }; From f1b4a9b786846c5c9aab447fb01bfaca92e75087 Mon Sep 17 00:00:00 2001 From: RoiEX Date: Mon, 6 Mar 2017 20:23:34 +0100 Subject: [PATCH 10/19] Shrink JSON --- src/controllers/osd.js | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/controllers/osd.js b/src/controllers/osd.js index b05fac72c9..b93a0cbcce 100644 --- a/src/controllers/osd.js +++ b/src/controllers/osd.js @@ -17,27 +17,15 @@ module.exports = 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 || '') }, + { Url: [{ _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', - }, - }, - ], + type: 'text/html', + method: 'get', + template: nconf.get('url') + '/search?term={searchTerms}&in=titlesposts' }, + }], }, ], }], { declaration: true, indent: '\t' }); From 0f9530bbc088d8a301d626062ddf6e85e4c93ebd Mon Sep 17 00:00:00 2001 From: RoiEX Date: Mon, 6 Mar 2017 20:24:00 +0100 Subject: [PATCH 11/19] Shrink JSON fix --- src/controllers/osd.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/osd.js b/src/controllers/osd.js index b93a0cbcce..cafbaccda3 100644 --- a/src/controllers/osd.js +++ b/src/controllers/osd.js @@ -24,9 +24,9 @@ function generateXML() { _attr: { type: 'text/html', method: 'get', - template: nconf.get('url') + '/search?term={searchTerms}&in=titlesposts' }, - }], - }, + template: nconf.get('url') + '/search?term={searchTerms}&in=titlesposts', + }, + }]}, ], }], { declaration: true, indent: '\t' }); } From fcda83205230b96d96f68d6a1a2c1b6d212bddf4 Mon Sep 17 00:00:00 2001 From: RoiEX Date: Mon, 6 Mar 2017 20:39:26 +0100 Subject: [PATCH 12/19] Add spaces --- src/controllers/osd.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/osd.js b/src/controllers/osd.js index cafbaccda3..13d9b659d5 100644 --- a/src/controllers/osd.js +++ b/src/controllers/osd.js @@ -17,7 +17,7 @@ module.exports = function (req, res, next) { function generateXML() { return xml([{ OpenSearchDescription: [ - { _attr: { xmlns: 'http://a9.com/-/spec/opensearch/1.1/' }}, + { _attr: { xmlns: 'http://a9.com/-/spec/opensearch/1.1/' } }, { ShortName: String(meta.config.title || meta.config.browserTitle || 'NodeBB') }, { Description: String(meta.config.description || '') }, { Url: [{ @@ -26,7 +26,7 @@ function generateXML() { method: 'get', template: nconf.get('url') + '/search?term={searchTerms}&in=titlesposts', }, - }]}, + }] }, ], }], { declaration: true, indent: '\t' }); } From 6420e224532e50f27c138bf1eb08aeca0a25570c Mon Sep 17 00:00:00 2001 From: RoiEX Date: Mon, 6 Mar 2017 20:43:06 +0100 Subject: [PATCH 13/19] Remove uneccessary curly brackets --- src/controllers/osd.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/osd.js b/src/controllers/osd.js index 13d9b659d5..01bb474033 100644 --- a/src/controllers/osd.js +++ b/src/controllers/osd.js @@ -20,13 +20,13 @@ function generateXML() { { _attr: { xmlns: 'http://a9.com/-/spec/opensearch/1.1/' } }, { ShortName: String(meta.config.title || meta.config.browserTitle || 'NodeBB') }, { Description: String(meta.config.description || '') }, - { Url: [{ + { Url: { _attr: { type: 'text/html', method: 'get', template: nconf.get('url') + '/search?term={searchTerms}&in=titlesposts', }, - }] }, + } }, ], }], { declaration: true, indent: '\t' }); } From 33e474759b5328b800f7263413e500c2b0f0b6b1 Mon Sep 17 00:00:00 2001 From: RoiEX Date: Mon, 6 Mar 2017 21:00:20 +0100 Subject: [PATCH 14/19] Change var names --- src/controllers/index.js | 2 +- src/controllers/osd.js | 2 +- src/routes/meta.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/index.js b/src/controllers/index.js index a02e3c9fbd..a3b9361651 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -30,9 +30,9 @@ Controllers.admin = require('./admin'); Controllers.globalMods = require('./globalmods'); Controllers.mods = require('./mods'); Controllers.sitemap = require('./sitemap'); +Controllers.osd = require('./osd'); Controllers['404'] = require('./404'); Controllers.errors = require('./errors'); -Controllers.handleOSDRequest = require('./osd'); Controllers.home = function (req, res, next) { var route = meta.config.homePageRoute || (meta.config.homePageCustom || '').replace(/^\/+/, '') || 'categories'; diff --git a/src/controllers/osd.js b/src/controllers/osd.js index 01bb474033..c83f7f142c 100644 --- a/src/controllers/osd.js +++ b/src/controllers/osd.js @@ -6,7 +6,7 @@ var nconf = require('nconf'); var plugins = require('../plugins'); var meta = require('../meta'); -module.exports = function (req, res, next) { +module.exports.handle = function (req, res, next) { if (plugins.hasListeners('filter:search.query')) { res.type('application/xml').send(generateXML()); } else { diff --git a/src/routes/meta.js b/src/routes/meta.js index e17533af05..de0bb52406 100644 --- a/src/routes/meta.js +++ b/src/routes/meta.js @@ -8,5 +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', controllers.handleOSDRequest); + app.get('/osd.xml', controllers.osd.handle); }; From 992e3128bdb7772b1bdc10e2cf746b0bf6d593db Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 7 Mar 2017 13:09:14 +0300 Subject: [PATCH 15/19] closes #5499 --- public/src/client/account/settings.js | 5 ++++- src/controllers/accounts/settings.js | 1 + src/controllers/api.js | 5 +++-- src/middleware/header.js | 4 ++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/public/src/client/account/settings.js b/public/src/client/account/settings.js index eba41faf9c..bffefc725f 100644 --- a/public/src/client/account/settings.js +++ b/public/src/client/account/settings.js @@ -49,9 +49,12 @@ define('forum/account/settings', ['forum/account/header', 'components', 'sounds' function changePageSkin(skinName) { var css = $('#bootswatchCSS'); - if (skinName === 'default') { + if (skinName === 'noskin' || (skinName === 'default' && config.defaultBootswatchSkin === 'noskin')) { css.remove(); } else { + if (skinName === 'default') { + skinName = config.defaultBootswatchSkin; + } var cssSource = '//maxcdn.bootstrapcdn.com/bootswatch/latest/' + skinName + '/bootstrap.min.css'; if (css.length) { css.attr('href', cssSource); diff --git a/src/controllers/accounts/settings.js b/src/controllers/accounts/settings.js index edd5d58282..2f360f883c 100644 --- a/src/controllers/accounts/settings.js +++ b/src/controllers/accounts/settings.js @@ -108,6 +108,7 @@ settingsController.get = function (req, res, callback) { userData.bootswatchSkinOptions = [ + { name: 'No skin', value: 'noskin' }, { name: 'Default', value: 'default' }, { name: 'Cerulean', value: 'cerulean' }, { name: 'Cosmo', value: 'cosmo' }, diff --git a/src/controllers/api.js b/src/controllers/api.js index cfa78a6908..5ddbd0731b 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -61,7 +61,8 @@ apiController.getConfig = function (req, res, next) { config.categoryTopicSort = meta.config.categoryTopicSort || 'newest_to_oldest'; config.csrf_token = req.csrfToken(); config.searchEnabled = plugins.hasListeners('filter:search.query'); - config.bootswatchSkin = meta.config.bootswatchSkin || 'default'; + config.bootswatchSkin = meta.config.bootswatchSkin || 'noskin'; + config.defaultBootswatchSkin = meta.config.bootswatchSkin || 'noskin'; var timeagoCutoff = meta.config.timeagoCutoff === undefined ? 30 : meta.config.timeagoCutoff; config.timeagoCutoff = timeagoCutoff !== '' ? Math.max(0, parseInt(timeagoCutoff, 10)) : timeagoCutoff; @@ -90,7 +91,7 @@ apiController.getConfig = function (req, res, next) { config.categoryTopicSort = settings.categoryTopicSort || config.categoryTopicSort; config.topicSearchEnabled = settings.topicSearchEnabled || false; config.delayImageLoading = settings.delayImageLoading !== undefined ? settings.delayImageLoading : true; - config.bootswatchSkin = settings.bootswatchSkin || config.bootswatchSkin; + config.bootswatchSkin = (settings.bootswatchSkin && settings.bootswatchSkin !== 'default') ? settings.bootswatchSkin : config.bootswatchSkin; plugins.fireHook('filter:config.get', config, next); }, ], function (err, config) { diff --git a/src/middleware/header.js b/src/middleware/header.js index 44a541f4bf..e5d4de66bb 100644 --- a/src/middleware/header.js +++ b/src/middleware/header.js @@ -190,12 +190,12 @@ module.exports = function (middleware) { } function setBootswatchCSS(obj, config) { - if (config && config.bootswatchSkin !== 'default') { + if (config && config.bootswatchSkin !== 'noskin') { var skinToUse = ''; if (parseInt(meta.config.disableCustomUserSkins, 10) !== 1) { skinToUse = config.bootswatchSkin; - } else if (meta.config.bootswatchSkin !== 'default') { + } else if (meta.config.bootswatchSkin) { skinToUse = meta.config.bootswatchSkin; } From 69c6ee5834f9f0c384a31b48d77014ce91b3b0bb Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 7 Mar 2017 13:38:31 +0300 Subject: [PATCH 16/19] closes #5483 --- public/src/ajaxify.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 12ebff1540..a8d4085c85 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -102,7 +102,8 @@ $(document).ready(function () { url = ajaxify.removeRelativePath(url.replace(/\/$/, '')).toLowerCase(); var isClientToAdmin = url.startsWith('admin') && window.location.pathname.indexOf(RELATIVE_PATH + '/admin') !== 0; var isAdminToClient = !url.startsWith('admin') && window.location.pathname.indexOf(RELATIVE_PATH + '/admin') === 0; - var uploadsOrApi = url.startsWith('uploads') || url.startsWith('api'); + var uploadsOrApi = url.startsWith('assets/uploads') || url.startsWith('uploads') || url.startsWith('api'); + if (isClientToAdmin || isAdminToClient || uploadsOrApi) { window.open(RELATIVE_PATH + '/' + url, '_top'); return true; From b7e6104bbc5bc802ad29be1a236139fc3c2daa64 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 7 Mar 2017 15:59:50 +0300 Subject: [PATCH 17/19] closes #5511 --- src/controllers/uploads.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/uploads.js b/src/controllers/uploads.js index 7a309d5200..82556ee12c 100644 --- a/src/controllers/uploads.js +++ b/src/controllers/uploads.js @@ -122,7 +122,7 @@ function resizeImage(fileObj, callback) { var extname = path.extname(fileObj.url); var basename = path.basename(fileObj.url, extname); - fileObj.url = path.join(dirname, basename + '-resized' + extname); + fileObj.url = dirname + '/' + basename + '-resized' + extname; next(null, fileObj); }, From 8a123f7c1c78b94632f4df952591a2db4f37bb85 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 7 Mar 2017 16:13:09 +0300 Subject: [PATCH 18/19] closes #5509 --- public/src/ajaxify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index a8d4085c85..913dbb6fd6 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -99,7 +99,7 @@ $(document).ready(function () { }; ajaxify.handleRedirects = function (url) { - url = ajaxify.removeRelativePath(url.replace(/\/$/, '')).toLowerCase(); + url = ajaxify.removeRelativePath(url.replace(/^\/|\/$/g, '')).toLowerCase(); var isClientToAdmin = url.startsWith('admin') && window.location.pathname.indexOf(RELATIVE_PATH + '/admin') !== 0; var isAdminToClient = !url.startsWith('admin') && window.location.pathname.indexOf(RELATIVE_PATH + '/admin') === 0; var uploadsOrApi = url.startsWith('assets/uploads') || url.startsWith('uploads') || url.startsWith('api'); From 1102ca8ebb2d4c20b76b09dc01353be6e388674a Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 7 Mar 2017 14:35:38 -0500 Subject: [PATCH 19/19] fix issue where an auto-redirect to SSO on login route was failing if invoked via API call (ajaxify) --- src/controllers/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/index.js b/src/controllers/index.js index a3b9361651..93b8e9a383 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -131,7 +131,7 @@ Controllers.login = function (req, res, next) { if (!data.allowLocalLogin && !data.allowRegistration && data.alternate_logins && data.authentication.length === 1) { if (res.locals.isAPI) { return helpers.redirect(res, { - external: data.authentication[0].url, + external: nconf.get('relative_path') + data.authentication[0].url, }); } return res.redirect(nconf.get('relative_path') + data.authentication[0].url);