mirror of
				https://github.com/gristlabs/grist-core.git
				synced 2025-06-13 20:53:59 +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 |   baseDomain?: string | ||||||
| }) { | }) { | ||||||
|   const {server, staticDir, tag, testLogin} = opts; |   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) => { |   return async (req: express.Request, resp: express.Response, options: ISendAppPageOptions) => { | ||||||
|     const config = makeGristConfig({ |     const config = makeGristConfig({ | ||||||
|       homeUrl: !isSingleUserMode() ? server.getHomeUrl(req) : null, |       homeUrl: !isSingleUserMode() ? server.getHomeUrl(req) : null, | ||||||
| @ -153,6 +159,7 @@ export function makeSendAppPage(opts: { | |||||||
|       .replace("<!-- INSERT BASE -->", `<base href="${staticBaseUrl}">` + tagManagerSnippet) |       .replace("<!-- INSERT BASE -->", `<base href="${staticBaseUrl}">` + tagManagerSnippet) | ||||||
|       .replace("<!-- INSERT LOCALE -->", preloads) |       .replace("<!-- INSERT LOCALE -->", preloads) | ||||||
|       .replace("<!-- INSERT CUSTOM -->", customHeadHtmlSnippet) |       .replace("<!-- INSERT CUSTOM -->", customHeadHtmlSnippet) | ||||||
|  |       .replace("<!-- INSERT CUSTOM SCRIPT -->", insertCustomScript) | ||||||
|       .replace( |       .replace( | ||||||
|         "<!-- INSERT CONFIG -->", |         "<!-- INSERT CONFIG -->", | ||||||
|         `<script>window.gristConfig = ${jsesc(config, {isScriptContext: true, json: true})};</script>` |         `<script>window.gristConfig = ${jsesc(config, {isScriptContext: true, json: true})};</script>` | ||||||
|  | |||||||
| @ -17,6 +17,7 @@ | |||||||
| <!-- INSERT LOCALE --> | <!-- INSERT LOCALE --> | ||||||
| <!-- INSERT CONFIG --> | <!-- INSERT CONFIG --> | ||||||
| <!-- INSERT CUSTOM --> | <!-- INSERT CUSTOM --> | ||||||
|  | <!-- INSERT CUSTOM SCRIPT --> | ||||||
| 
 | 
 | ||||||
| <title><!-- INSERT TITLE --><!-- INSERT TITLE SUFFIX --></title> | <title><!-- INSERT TITLE --><!-- INSERT TITLE SUFFIX --></title> | ||||||
| </head> | </head> | ||||||
|  | |||||||
| @ -8,6 +8,7 @@ | |||||||
|   <!-- INSERT LOCALE --> |   <!-- INSERT LOCALE --> | ||||||
|   <!-- INSERT CONFIG --> |   <!-- INSERT CONFIG --> | ||||||
|   <!-- INSERT CUSTOM --> |   <!-- INSERT CUSTOM --> | ||||||
|  |   <!-- INSERT CUSTOM SCRIPT --> | ||||||
|   <title>Loading...<!-- INSERT TITLE SUFFIX --></title> |   <title>Loading...<!-- INSERT TITLE SUFFIX --></title> | ||||||
| </head> | </head> | ||||||
| <body> | <body> | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user