feat: +assetBaseUrl, -l10BaseUrl, -requireBaseUrl

Additional base URLs were necessary for benchpress and translator,
and in order to not clutter the API response with needless one-
time use base URLs, I decided to use a single base that is used
by all of the services, assetBaseUrl.
v1.18.x
Julian Lam 5 years ago
parent 75ef4bbe34
commit 9adaccd036

@ -328,7 +328,7 @@ $(document).ready(function () {
}; };
ajaxify.loadTemplate = function (template, callback) { ajaxify.loadTemplate = function (template, callback) {
require([config.relative_path + '/assets/templates/' + template + '.js'], callback, function (err) { require([config.assetBaseUrl + '/templates/' + template + '.js'], callback, function (err) {
console.error('Unable to load template: ' + template); console.error('Unable to load template: ' + template);
throw err; throw err;
}); });

@ -2,7 +2,7 @@
(function (factory) { (function (factory) {
function loadClient(language, namespace) { function loadClient(language, namespace) {
return Promise.resolve(jQuery.getJSON(config.l10nBaseUrl + '/' + language + '/' + namespace + '.json?' + config['cache-buster'])); return Promise.resolve(jQuery.getJSON([config.assetBaseUrl, 'language', language, namespace].join('/') + '.json?' + config['cache-buster']));
} }
var warn = function () { console.warn.apply(console, arguments); }; var warn = function () { console.warn.apply(console, arguments); };
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
@ -605,7 +605,7 @@
} }
var originalSettings = assign({}, jQuery.timeago.settings.strings); var originalSettings = assign({}, jQuery.timeago.settings.strings);
jQuery.getScript(config.relative_path + '/assets/vendor/jquery/timeago/locales/jquery.timeago.' + languageCode + '-short.js').done(function () { jQuery.getScript(config.assetBaseUrl + '/vendor/jquery/timeago/locales/jquery.timeago.' + languageCode + '-short.js').done(function () {
adaptor.timeagoShort = assign({}, jQuery.timeago.settings.strings); adaptor.timeagoShort = assign({}, jQuery.timeago.settings.strings);
jQuery.timeago.settings.strings = assign({}, originalSettings); jQuery.timeago.settings.strings = assign({}, originalSettings);
toggle(); toggle();
@ -620,7 +620,7 @@
delete adaptor.timeagoShort; delete adaptor.timeagoShort;
var languageCode = utils.userLangToTimeagoCode(config.userLang); var languageCode = utils.userLangToTimeagoCode(config.userLang);
jQuery.getScript(config.relative_path + '/assets/vendor/jquery/timeago/locales/jquery.timeago.' + languageCode + '.js').done(callback); jQuery.getScript(config.assetBaseUrl + '/vendor/jquery/timeago/locales/jquery.timeago.' + languageCode + '.js').done(callback);
}, },
prepareDOM: function prepareDOM() { prepareDOM: function prepareDOM() {

@ -1,7 +1,7 @@
'use strict'; 'use strict';
require.config({ require.config({
baseUrl: config.requireBaseUrl, baseUrl: config.assetBaseUrl + '/src/modules',
waitSeconds: 0, waitSeconds: 0,
urlArgs: config['cache-buster'], urlArgs: config['cache-buster'],
paths: { paths: {

@ -19,8 +19,7 @@ apiController.loadConfig = async function (req) {
let config = { let config = {
relative_path: nconf.get('relative_path'), relative_path: nconf.get('relative_path'),
upload_url: nconf.get('upload_url'), upload_url: nconf.get('upload_url'),
requireBaseUrl: `${nconf.get('relative_path')}/assets/src/modules`, assetBaseUrl: `${nconf.get('relative_path')}/assets`,
l10nBaseUrl: `${nconf.get('relative_path')}/assets/language`,
siteTitle: validator.escape(String(meta.config.title || meta.config.browserTitle || 'NodeBB')), siteTitle: validator.escape(String(meta.config.title || meta.config.browserTitle || 'NodeBB')),
browserTitle: validator.escape(String(meta.config.browserTitle || meta.config.title || 'NodeBB')), browserTitle: validator.escape(String(meta.config.browserTitle || meta.config.title || 'NodeBB')),
titleLayout: (meta.config.titleLayout || '{pageTitle} | {browserTitle}').replace(/{/g, '{').replace(/}/g, '}'), titleLayout: (meta.config.titleLayout || '{pageTitle} | {browserTitle}').replace(/{/g, '{').replace(/}/g, '}'),

Loading…
Cancel
Save