mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-05 21:45:47 +01:00
Merge branch 'master' into develop
This commit is contained in:
@@ -94,6 +94,7 @@
|
|||||||
"underscore.deep": "^0.5.1",
|
"underscore.deep": "^0.5.1",
|
||||||
"validator": "^6.1.0",
|
"validator": "^6.1.0",
|
||||||
"winston": "^2.1.0",
|
"winston": "^2.1.0",
|
||||||
|
"xml": "^1.0.1",
|
||||||
"xregexp": "~3.1.0"
|
"xregexp": "~3.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -99,10 +99,11 @@ $(document).ready(function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ajaxify.handleRedirects = function (url) {
|
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 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 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) {
|
if (isClientToAdmin || isAdminToClient || uploadsOrApi) {
|
||||||
window.open(RELATIVE_PATH + '/' + url, '_top');
|
window.open(RELATIVE_PATH + '/' + url, '_top');
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -49,9 +49,12 @@ define('forum/account/settings', ['forum/account/header', 'components', 'sounds'
|
|||||||
|
|
||||||
function changePageSkin(skinName) {
|
function changePageSkin(skinName) {
|
||||||
var css = $('#bootswatchCSS');
|
var css = $('#bootswatchCSS');
|
||||||
if (skinName === 'default') {
|
if (skinName === 'noskin' || (skinName === 'default' && config.defaultBootswatchSkin === 'noskin')) {
|
||||||
css.remove();
|
css.remove();
|
||||||
} else {
|
} else {
|
||||||
|
if (skinName === 'default') {
|
||||||
|
skinName = config.defaultBootswatchSkin;
|
||||||
|
}
|
||||||
var cssSource = '//maxcdn.bootstrapcdn.com/bootswatch/latest/' + skinName + '/bootstrap.min.css';
|
var cssSource = '//maxcdn.bootstrapcdn.com/bootswatch/latest/' + skinName + '/bootstrap.min.css';
|
||||||
if (css.length) {
|
if (css.length) {
|
||||||
css.attr('href', cssSource);
|
css.attr('href', cssSource);
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ define('pictureCropper', ['translator', 'cropper'], function (translator, croppe
|
|||||||
var img = document.getElementById('cropped-image');
|
var img = document.getElementById('cropped-image');
|
||||||
var cropperTool = new cropper.default(img, {
|
var cropperTool = new cropper.default(img, {
|
||||||
aspectRatio: data.aspectRatio,
|
aspectRatio: data.aspectRatio,
|
||||||
|
autoCropArea: 1,
|
||||||
viewMode: 1,
|
viewMode: 1,
|
||||||
cropmove: function () {
|
cropmove: function () {
|
||||||
if (data.restrictImageDimension) {
|
if (data.restrictImageDimension) {
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ settingsController.get = function (req, res, callback) {
|
|||||||
|
|
||||||
|
|
||||||
userData.bootswatchSkinOptions = [
|
userData.bootswatchSkinOptions = [
|
||||||
|
{ name: 'No skin', value: 'noskin' },
|
||||||
{ name: 'Default', value: 'default' },
|
{ name: 'Default', value: 'default' },
|
||||||
{ name: 'Cerulean', value: 'cerulean' },
|
{ name: 'Cerulean', value: 'cerulean' },
|
||||||
{ name: 'Cosmo', value: 'cosmo' },
|
{ name: 'Cosmo', value: 'cosmo' },
|
||||||
|
|||||||
@@ -61,7 +61,8 @@ apiController.getConfig = function (req, res, next) {
|
|||||||
config.categoryTopicSort = meta.config.categoryTopicSort || 'newest_to_oldest';
|
config.categoryTopicSort = meta.config.categoryTopicSort || 'newest_to_oldest';
|
||||||
config.csrf_token = req.csrfToken();
|
config.csrf_token = req.csrfToken();
|
||||||
config.searchEnabled = plugins.hasListeners('filter:search.query');
|
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;
|
var timeagoCutoff = meta.config.timeagoCutoff === undefined ? 30 : meta.config.timeagoCutoff;
|
||||||
config.timeagoCutoff = timeagoCutoff !== '' ? Math.max(0, parseInt(timeagoCutoff, 10)) : 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.categoryTopicSort = settings.categoryTopicSort || config.categoryTopicSort;
|
||||||
config.topicSearchEnabled = settings.topicSearchEnabled || false;
|
config.topicSearchEnabled = settings.topicSearchEnabled || false;
|
||||||
config.delayImageLoading = settings.delayImageLoading !== undefined ? settings.delayImageLoading : true;
|
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);
|
plugins.fireHook('filter:config.get', config, next);
|
||||||
},
|
},
|
||||||
], function (err, config) {
|
], function (err, config) {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ Controllers.admin = require('./admin');
|
|||||||
Controllers.globalMods = require('./globalmods');
|
Controllers.globalMods = require('./globalmods');
|
||||||
Controllers.mods = require('./mods');
|
Controllers.mods = require('./mods');
|
||||||
Controllers.sitemap = require('./sitemap');
|
Controllers.sitemap = require('./sitemap');
|
||||||
|
Controllers.osd = require('./osd');
|
||||||
Controllers['404'] = require('./404');
|
Controllers['404'] = require('./404');
|
||||||
Controllers.errors = require('./errors');
|
Controllers.errors = require('./errors');
|
||||||
|
|
||||||
@@ -130,7 +131,7 @@ Controllers.login = function (req, res, next) {
|
|||||||
if (!data.allowLocalLogin && !data.allowRegistration && data.alternate_logins && data.authentication.length === 1) {
|
if (!data.allowLocalLogin && !data.allowRegistration && data.alternate_logins && data.authentication.length === 1) {
|
||||||
if (res.locals.isAPI) {
|
if (res.locals.isAPI) {
|
||||||
return helpers.redirect(res, {
|
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);
|
return res.redirect(nconf.get('relative_path') + data.authentication[0].url);
|
||||||
|
|||||||
32
src/controllers/osd.js
Normal file
32
src/controllers/osd.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var xml = require('xml');
|
||||||
|
var nconf = require('nconf');
|
||||||
|
|
||||||
|
var plugins = require('../plugins');
|
||||||
|
var meta = require('../meta');
|
||||||
|
|
||||||
|
module.exports.handle = 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' });
|
||||||
|
}
|
||||||
@@ -122,7 +122,7 @@ function resizeImage(fileObj, callback) {
|
|||||||
var extname = path.extname(fileObj.url);
|
var extname = path.extname(fileObj.url);
|
||||||
var basename = path.basename(fileObj.url, extname);
|
var basename = path.basename(fileObj.url, extname);
|
||||||
|
|
||||||
fileObj.url = path.join(dirname, basename + '-resized' + extname);
|
fileObj.url = dirname + '/' + basename + '-resized' + extname;
|
||||||
|
|
||||||
next(null, fileObj);
|
next(null, fileObj);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -61,6 +61,14 @@ module.exports = function (Meta) {
|
|||||||
href: nconf.get('relative_path') + '/manifest.json',
|
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') + '/osd.xml',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Touch icons for mobile-devices
|
// Touch icons for mobile-devices
|
||||||
if (Meta.config['brand:touchIcon']) {
|
if (Meta.config['brand:touchIcon']) {
|
||||||
defaultLinks.push({
|
defaultLinks.push({
|
||||||
|
|||||||
@@ -190,12 +190,12 @@ module.exports = function (middleware) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setBootswatchCSS(obj, config) {
|
function setBootswatchCSS(obj, config) {
|
||||||
if (config && config.bootswatchSkin !== 'default') {
|
if (config && config.bootswatchSkin !== 'noskin') {
|
||||||
var skinToUse = '';
|
var skinToUse = '';
|
||||||
|
|
||||||
if (parseInt(meta.config.disableCustomUserSkins, 10) !== 1) {
|
if (parseInt(meta.config.disableCustomUserSkins, 10) !== 1) {
|
||||||
skinToUse = config.bootswatchSkin;
|
skinToUse = config.bootswatchSkin;
|
||||||
} else if (meta.config.bootswatchSkin !== 'default') {
|
} else if (meta.config.bootswatchSkin) {
|
||||||
skinToUse = meta.config.bootswatchSkin;
|
skinToUse = meta.config.bootswatchSkin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,4 +8,5 @@ module.exports = function (app, middleware, controllers) {
|
|||||||
app.get('/robots.txt', controllers.robots);
|
app.get('/robots.txt', controllers.robots);
|
||||||
app.get('/manifest.json', controllers.manifest);
|
app.get('/manifest.json', controllers.manifest);
|
||||||
app.get('/css/previews/:theme', controllers.admin.themes.get);
|
app.get('/css/previews/:theme', controllers.admin.themes.get);
|
||||||
|
app.get('/osd.xml', controllers.osd.handle);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user