diff --git a/app/assets/javascripts/discourse/app/index.html b/app/assets/javascripts/discourse/app/index.html index c7c50c7784f..ba049ba54ce 100644 --- a/app/assets/javascripts/discourse/app/index.html +++ b/app/assets/javascripts/discourse/app/index.html @@ -13,7 +13,6 @@ - {{content-for "head"}} diff --git a/app/assets/javascripts/discourse/lib/bootstrap-json/index.js b/app/assets/javascripts/discourse/lib/bootstrap-json/index.js index 802454bf904..60424357282 100644 --- a/app/assets/javascripts/discourse/lib/bootstrap-json/index.js +++ b/app/assets/javascripts/discourse/lib/bootstrap-json/index.js @@ -29,7 +29,7 @@ function htmlTag(buffer, bootstrap) { buffer.push(``); } -function head(buffer, bootstrap) { +function head(buffer, bootstrap, headers, baseURL) { if (bootstrap.csrf_token) { buffer.push(``); buffer.push(``); @@ -87,6 +87,13 @@ function head(buffer, bootstrap) { buffer.push(link); }); + if (bootstrap.preloaded.currentUser) { + let staff = JSON.parse(bootstrap.preloaded.currentUser).staff; + if (staff) { + buffer.push(``); + } + } + bootstrap.plugin_js.forEach((src) => buffer.push(``) ); @@ -156,15 +163,15 @@ const BUILDERS = { "locale-script": localeScript, }; -function replaceIn(bootstrap, template, id, headers) { +function replaceIn(bootstrap, template, id, headers, baseURL) { let buffer = []; - BUILDERS[id](buffer, bootstrap, headers); + BUILDERS[id](buffer, bootstrap, headers, baseURL); let contents = buffer.filter((b) => b && b.length > 0).join("\n"); return template.replace(``, contents); } -async function applyBootstrap(bootstrap, template, response) { +async function applyBootstrap(bootstrap, template, response, baseURL) { // If our initial page added some preload data let's not lose that. let json = await response.json(); if (json && json.preloaded) { @@ -172,7 +179,7 @@ async function applyBootstrap(bootstrap, template, response) { } Object.keys(BUILDERS).forEach((id) => { - template = replaceIn(bootstrap, template, id, response); + template = replaceIn(bootstrap, template, id, response, baseURL); }); return template; } @@ -192,7 +199,7 @@ function buildFromBootstrap(assetPath, proxy, baseURL, req, response) { getJSON(url, null, req.headers) .then((json) => { - return applyBootstrap(json.bootstrap, template, response); + return applyBootstrap(json.bootstrap, template, response, baseURL); }) .then(resolve) .catch((e) => {