mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Add config to include custom CSS
Summary: Adds a new environment variable that allows for custom CSS to be included in all core static pages. Test Plan: Tested manually in grist-core. Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D3419
This commit is contained in:
@@ -29,6 +29,9 @@ export interface ICreate {
|
||||
sessionSecret(): string;
|
||||
// Get configuration information to show at start-up.
|
||||
configurationOptions(): {[key: string]: any};
|
||||
// Return a string containing 1 or more HTML tags to insert into the head element of every
|
||||
// static page.
|
||||
getExtraHeadHtml?(): string;
|
||||
}
|
||||
|
||||
export interface ICreateActiveDocOptions {
|
||||
@@ -90,6 +93,13 @@ export function makeSimpleCreator(opts: {
|
||||
if (config) { return config; }
|
||||
}
|
||||
return {};
|
||||
}
|
||||
},
|
||||
getExtraHeadHtml() {
|
||||
let customHeadHtmlSnippet = '';
|
||||
if (process.env.APP_STATIC_INCLUDE_CUSTOM_CSS === 'true') {
|
||||
customHeadHtmlSnippet += '<link rel="stylesheet" href="custom.css">';
|
||||
}
|
||||
return customHeadHtmlSnippet;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -90,10 +90,12 @@ export function makeSendAppPage(opts: {
|
||||
const tagManagerSnippet = needTagManager ? getTagManagerSnippet(process.env.GOOGLE_TAG_MANAGER_ID) : '';
|
||||
const staticOrigin = process.env.APP_STATIC_URL || "";
|
||||
const staticBaseUrl = `${staticOrigin}/v/${options.tag || tag}/`;
|
||||
const customHeadHtmlSnippet = server?.create.getExtraHeadHtml?.() ?? "";
|
||||
const warning = testLogin ? "<div class=\"dev_warning\">Authentication is not enforced</div>" : "";
|
||||
const content = fileContent
|
||||
.replace("<!-- INSERT WARNING -->", warning)
|
||||
.replace("<!-- INSERT BASE -->", `<base href="${staticBaseUrl}">` + tagManagerSnippet)
|
||||
.replace("<!-- INSERT CUSTOM -->", customHeadHtmlSnippet)
|
||||
.replace("<!-- INSERT CONFIG -->", `<script>window.gristConfig = ${JSON.stringify(config)};</script>`);
|
||||
resp.status(options.status).type('html').send(content);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user