π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Albums static link preview
Manav Rathi0748c9bf8d73
diff --git a/web/apps/photos/public/images/preview.jpg b/web/apps/photos/public/images/preview.jpgnew file mode 100644index 0000000000..2e3d9f1da4Binary files /dev/null and b/web/apps/photos/public/images/preview.jpg differdiff --git a/web/apps/photos/src/pages/_app.tsx b/web/apps/photos/src/pages/_app.tsxindex 5b86b04ec0..6531ecd47d 100644--- a/web/apps/photos/src/pages/_app.tsx+++ b/web/apps/photos/src/pages/_app.tsx@@ -10,7 +10,7 @@ import {} from "ente-accounts/services/accounts-db";import { isDesktop, staticAppTitle } from "ente-base/app";import { CenteredRow } from "ente-base/components/containers";-import { CustomHead } from "ente-base/components/Head";+import { CustomHeadPhotosOrAlbums } from "ente-base/components/Head";import {LoadingIndicator,TranslucentLoadingOverlay,@@ -170,7 +170,7 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {return (<ThemeProvider theme={photosTheme}>- <CustomHead {...{ title }} />+ <CustomHeadPhotosOrAlbums {...{ title }} /><CssBaseline enableColorScheme /><ThemedLoadingBar ref={loadingBarRef} />diff --git a/web/packages/base/components/Head.tsx b/web/packages/base/components/Head.tsxindex 3ada4645a5..988ec68929 100644--- a/web/packages/base/components/Head.tsx+++ b/web/packages/base/components/Head.tsx@@ -1,8 +1,11 @@import Head from "next/head";import React from "react";+import { haveWindow } from "../env";+import { albumsAppOrigin, isCustomAlbumsAppOrigin } from "../origins";interface CustomHeadProps {title: string;+ description?: string;}/**@@ -23,3 +26,62 @@ export const CustomHead: React.FC<CustomHeadProps> = ({ title }) => (<meta name="referrer" content="strict-origin-when-cross-origin" /></Head>);++/**+ * A static SSR-ed variant of {@link CustomHead} for use with the albums app+ * deployed on production Ente instances for link previews.+ *+ * In particular,+ *+ * - Any client side modifications to the document's head will be too late for+ * use by the link previews, so the contents of this need to part of the+ * static HTML.+ *+ * - "og:image" needs to be an absolute URL.+ *+ * To avoid getting in the way of self hosters, we do a deployment URL check+ * before inlining this into the build.+ */+export const CustomHeadAlbums: React.FC = () => (+ <Head>+ <title>Ente Photos</title>+ <link rel="icon" href="/images/favicon.png" type="image/png" />+ <meta+ name="description"+ content="Safely store and share your best moments"+ />+ <meta+ name="og:image"+ content="https://albums.ente.io/images/preview.png"+ />+ <meta name="viewport" content="width=device-width, initial-scale=1" />+ <meta name="referrer" content="strict-origin-when-cross-origin" />+ </Head>+);++/**+ * A convenience fan out to conditionally show one of {@link CustomHead} or+ * {@link CustomHeadAlbums}.+ *+ * 1. This component defaults to {@link CustomHeadAlbums} during SSR unless a+ * custom endpoint is defined.+ *+ * 2. Currently the photos and albums app use the same code. During SSR this+ * uses the albums variant, and then does a client side update to the photos+ * head when it detects that the origin it is being served on is not the+ * albums origin.+ *+ * The current content of the head is such that it sort of works for both photos+ * and public albums, so the client side update is just an enhancement. We+ * should not need this component when the photos and public albums app split.+ */+export const CustomHeadPhotosOrAlbums: React.FC<CustomHeadProps> = ({+ title,+}) =>+ isCustomAlbumsAppOrigin ||+ (haveWindow() &&+ new URL(window.location.href).origin != albumsAppOrigin()) ? (+ <CustomHead {...{ title }} />+ ) : (+ <CustomHeadAlbums />+ );diff --git a/web/packages/base/origins.ts b/web/packages/base/origins.tsindex 597eb5b908..b12606625c 100644--- a/web/packages/base/origins.ts+++ b/web/packages/base/origins.ts@@ -81,6 +81,13 @@ export const customAPIHost = async () => {export const uploaderOrigin = async () =>(await customAPIOrigin()) ?? "https://uploader.ente.io";+/**+ * A static build time constant that is `true` if the {@link albumsAppOrigin} is+ * different from the default value (Ente's production instance).+ */+export const isCustomAlbumsAppOrigin =+ process.env.NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT != "https://albums.ente.io";+/*** Return the origin that serves public albums.*