Compare commits

..

4 Commits

Author SHA1 Message Date
Barış Soner Uşaklı
32b38643f8 feat: add response:helpers.notAllowed 2022-04-04 17:36:45 -04:00
Barış Soner Uşaklı
37ba8a2c8e fix: use asset_base_url 2022-03-31 11:15:58 -04:00
Barış Soner Uşaklı
35f0c559c0 fix: dont overwrite asset_base_url 2022-03-31 11:15:02 -04:00
Barış Soner Uşaklı
d19a273ce9 fix: #10360, only take top level posts 2022-03-02 15:25:27 -05:00
7 changed files with 15 additions and 4 deletions

View File

@@ -424,7 +424,7 @@ ajaxify = window.ajaxify || {};
};
ajaxify.loadTemplate = function (template, callback) {
require([config.assetBaseUrl + '/templates/' + template + '.js'], callback, function (err) {
require([config.asset_base_url + '/templates/' + template + '.js'], callback, function (err) {
console.error('Unable to load template: ' + template);
throw err;
});

View File

@@ -132,7 +132,7 @@ define('forum/topic/posts', [
if (!isPreviousPostAdded && data.posts[0].selfPost) {
return ajaxify.go('post/' + data.posts[0].pid);
}
const repliesSelector = $('[component="post"]:not([data-index=0]), [component="topic/event"]');
const repliesSelector = $('[component="topic"]>[component="post"]:not([data-index=0]), [component="topic"]>[component="topic/event"]');
createNewPosts(data, repliesSelector, direction, false, function (html) {
if (html) {
html.addClass('new');

View File

@@ -3,7 +3,7 @@
(function (factory) {
function loadClient(language, namespace) {
return new Promise(function (resolve, reject) {
jQuery.getJSON([config.assetBaseUrl, 'language', language, namespace].join('/') + '.json?' + config['cache-buster'], function (data) {
jQuery.getJSON([config.asset_base_url, 'language', language, namespace].join('/') + '.json?' + config['cache-buster'], function (data) {
const payload = {
language: language,
namespace: namespace,

View File

@@ -14,6 +14,7 @@ const apiController = module.exports;
const relative_path = nconf.get('relative_path');
const upload_url = nconf.get('upload_url');
const asset_base_url = nconf.get('asset_base_url');
const socketioTransports = nconf.get('socket.io:transports') || ['polling', 'websocket'];
const socketioOrigins = nconf.get('socket.io:origins');
const websocketAddress = nconf.get('socket.io:address') || '';
@@ -22,7 +23,8 @@ apiController.loadConfig = async function (req) {
const config = {
relative_path,
upload_url,
assetBaseUrl: `${relative_path}/assets`,
asset_base_url,
assetBaseUrl: asset_base_url, // deprecate in 1.20.x
siteTitle: validator.escape(String(meta.config.title || meta.config.browserTitle || 'NodeBB')),
browserTitle: validator.escape(String(meta.config.browserTitle || meta.config.title || 'NodeBB')),
titleLayout: (meta.config.titleLayout || '{pageTitle} | {browserTitle}').replace(/{/g, '{').replace(/}/g, '}'),

View File

@@ -123,6 +123,11 @@ helpers.buildTerms = function (url, term, query) {
helpers.notAllowed = async function (req, res, error) {
({ error } = await plugins.hooks.fire('filter:helpers.notAllowed', { req, res, error }));
await plugins.hooks.fire('response:helpers.notAllowed', { req, res, error });
if (res.headersSent) {
return;
}
if (req.loggedIn || req.uid === -1) {
if (res.locals.isAPI) {
if (req.originalUrl.startsWith(`${relative_path}/api/v3`)) {

View File

@@ -94,6 +94,9 @@ function loadConfig(configFile) {
nconf.set('secure', urlObject.protocol === 'https:');
nconf.set('use_port', !!urlObject.port);
nconf.set('relative_path', relativePath);
if (!nconf.get('asset_base_url')) {
nconf.set('asset_base_url', `${relativePath}/assets`);
}
nconf.set('port', nconf.get('PORT') || nconf.get('port') || urlObject.port || (nconf.get('PORT_ENV_VAR') ? nconf.get(nconf.get('PORT_ENV_VAR')) : false) || 4567);
// cookies don't provide isolation by port: http://stackoverflow.com/a/16328399/122353

View File

@@ -38,6 +38,7 @@ nconf.defaults({
const urlObject = url.parse(nconf.get('url'));
const relativePath = urlObject.pathname !== '/' ? urlObject.pathname : '';
nconf.set('relative_path', relativePath);
nconf.set('asset_base_url', `${relativePath}/assets`);
nconf.set('upload_path', path.join(nconf.get('base_dir'), nconf.get('upload_path')));
nconf.set('upload_url', '/assets/uploads');
nconf.set('url_parsed', urlObject);