mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Support GRIST_INCLUDE_CUSTOM_SCRIPT_URL for custom scripts, specifically for rapid prototyping support
Test Plan: Tested manually on localhost Reviewers: paulfitz, georgegevoian Reviewed By: paulfitz, georgegevoian Subscribers: paulfitz, georgegevoian Differential Revision: https://phab.getgrist.com/D4186
This commit is contained in:
parent
b64802dfe8
commit
7de33078f3
@ -116,6 +116,12 @@ export function makeSendAppPage(opts: {
|
||||
baseDomain?: string
|
||||
}) {
|
||||
const {server, staticDir, tag, testLogin} = opts;
|
||||
|
||||
// If env var GRIST_INCLUDE_CUSTOM_SCRIPT_URL is set, load it in a <script> tag on all app pages.
|
||||
const customScriptUrl = process.env.GRIST_INCLUDE_CUSTOM_SCRIPT_URL;
|
||||
const insertCustomScript: string = customScriptUrl ?
|
||||
`<script src="${customScriptUrl}" crossorigin="anonymous"></script>` : '';
|
||||
|
||||
return async (req: express.Request, resp: express.Response, options: ISendAppPageOptions) => {
|
||||
const config = makeGristConfig({
|
||||
homeUrl: !isSingleUserMode() ? server.getHomeUrl(req) : null,
|
||||
@ -153,6 +159,7 @@ export function makeSendAppPage(opts: {
|
||||
.replace("<!-- INSERT BASE -->", `<base href="${staticBaseUrl}">` + tagManagerSnippet)
|
||||
.replace("<!-- INSERT LOCALE -->", preloads)
|
||||
.replace("<!-- INSERT CUSTOM -->", customHeadHtmlSnippet)
|
||||
.replace("<!-- INSERT CUSTOM SCRIPT -->", insertCustomScript)
|
||||
.replace(
|
||||
"<!-- INSERT CONFIG -->",
|
||||
`<script>window.gristConfig = ${jsesc(config, {isScriptContext: true, json: true})};</script>`
|
||||
|
@ -17,6 +17,7 @@
|
||||
<!-- INSERT LOCALE -->
|
||||
<!-- INSERT CONFIG -->
|
||||
<!-- INSERT CUSTOM -->
|
||||
<!-- INSERT CUSTOM SCRIPT -->
|
||||
|
||||
<title><!-- INSERT TITLE --><!-- INSERT TITLE SUFFIX --></title>
|
||||
</head>
|
||||
|
@ -8,6 +8,7 @@
|
||||
<!-- INSERT LOCALE -->
|
||||
<!-- INSERT CONFIG -->
|
||||
<!-- INSERT CUSTOM -->
|
||||
<!-- INSERT CUSTOM SCRIPT -->
|
||||
<title>Loading...<!-- INSERT TITLE SUFFIX --></title>
|
||||
</head>
|
||||
<body>
|
||||
|
Loading…
Reference in New Issue
Block a user