From 64685b3d13870d72f94c27d1c3ba91f97668d367 Mon Sep 17 00:00:00 2001 From: fflorent Date: Fri, 4 Oct 2024 15:26:16 +0200 Subject: [PATCH] Add description and icon to preview URLs for non-document resources #1242 When pasting a URL in some app or website that allows previewing the link, for other resources than documents, you were offered an irrelevant description. This patches aims to give a generic description of what is Grist. --- app/server/lib/sendAppPage.ts | 32 ++++++++++++++------------------ static/img/icon-grist.png | Bin 0 -> 10103 bytes static/locales/en.server.json | 3 ++- 3 files changed, 16 insertions(+), 19 deletions(-) create mode 100644 static/img/icon-grist.png diff --git a/app/server/lib/sendAppPage.ts b/app/server/lib/sendAppPage.ts index 38f3dcb5e9c..30b325f074c 100644 --- a/app/server/lib/sendAppPage.ts +++ b/app/server/lib/sendAppPage.ts @@ -157,8 +157,8 @@ export function makeSendAppPage({ server, staticDir, tag, testLogin, baseDomain const staticTag = options.tag || tag; // If boot tag is used, serve assets locally, otherwise respect // APP_STATIC_URL. - const staticOrigin = staticTag === 'boot' ? '' : (process.env.APP_STATIC_URL || ''); - const staticBaseUrl = `${staticOrigin}/v/${staticTag}/`; + const staticOrigin = staticTag === 'boot' ? '' : (process.env.APP_STATIC_URL || config.homeUrl || ''); + const staticBaseUrl = new URL(`/v/${staticTag}/`, staticOrigin).href; const customHeadHtmlSnippet = server.create.getExtraHeadHtml?.() ?? ""; const warning = testLogin ? "
Authentication is not enforced
" : ""; // Preload all languages that will be used or are requested by client. @@ -173,7 +173,7 @@ export function makeSendAppPage({ server, staticDir, tag, testLogin, baseDomain const content = fileContent .replace("", warning) .replace("", getPageTitle(req, config)) - .replace("", getPageMetadataHtmlSnippet(config)) + .replace("", getPageMetadataHtmlSnippet(req, config, staticBaseUrl)) .replace("", getPageTitleSuffix(server.getGristConfig())) .replace("", `` + tagManagerSnippet) .replace("", preloads) @@ -284,25 +284,21 @@ function getPageTitle(req: express.Request, config: GristLoadConfig): string { * * Note: The string returned is escaped and safe to insert into HTML. */ -function getPageMetadataHtmlSnippet(config: GristLoadConfig): string { +function getPageMetadataHtmlSnippet(req: express.Request, config: GristLoadConfig, staticBaseUrl: string): string { const metadataElements: string[] = []; const maybeDoc = getDocFromConfig(config); - const description = maybeDoc?.options?.description; - if (description) { - const content = handlebars.Utils.escapeExpression(description); - metadataElements.push(``); - metadataElements.push(``); - metadataElements.push(``); - } + const description = maybeDoc?.options?.description ?? String(translate(req, 'gristMetaDescription')); + const escapedDescription = handlebars.Utils.escapeExpression(description); + metadataElements.push(``); + metadataElements.push(``); + metadataElements.push(``); - const icon = maybeDoc?.options?.icon; - if (icon) { - const content = handlebars.Utils.escapeExpression(icon); - metadataElements.push(``); - metadataElements.push(``); - metadataElements.push(``); - } + const icon = maybeDoc?.options?.icon ?? new URL('img/icon-grist.png', staticBaseUrl).href; + const escapedIcon = handlebars.Utils.escapeExpression(icon); + metadataElements.push(``); + metadataElements.push(``); + metadataElements.push(``); return metadataElements.join('\n'); } diff --git a/static/img/icon-grist.png b/static/img/icon-grist.png new file mode 100644 index 0000000000000000000000000000000000000000..f4e9f56f93c7ad5e6a14d02b8c31bd9beb83a89f GIT binary patch literal 10103 zcmZ{K1yCGK6z1Z=3GR~M?oLRM;O?+ULeRzCB?PzN!7V_rU375`EDk{e!52tym*C;% zzq-1syQ-V2*{`O-Gfd$3mBC&rP@vnr z(Rc#_)hFXVyu$#V8LgFdH9(*MRuCxc69{w%RE6z=K;HZy(7qK2B>4pdqHxP=*O3NZ zV7^yVQUFTex|Qz;1qy68WfM;jh@9oW8%0Hz`M>$Fyi_z4v379jP+5373+zNdAXZxy zg*W`o?n$MSjDki zPz5aVWLqWp$MS;9Krg$pRZ#8cht$gKZ=_sFrC;KmOumvUm$1j8`x1jtKK@dE&jepP zk+~?H#!uZuEuq=PybG+>Cwg5pExr>tc^|w}pqRqa6@;v_A#KKlbN+I`ThT!{PGV5`uti~mK3Bc|m=rg-f|IaVsvWI; zD4<=z=yn33VKUMWLzgAGK=gk7$ZLH=Ij&QtAHU#=Pxo}YY-@qCb`Rr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