π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add public social profile links
Anand Baburajanbc1be19c44a1
diff --git a/web/apps/social/next.config.js b/web/apps/social/next.config.jsindex 5a52794ab2..736f640b5f 100644--- a/web/apps/social/next.config.js+++ b/web/apps/social/next.config.js@@ -1 +1,20 @@-module.exports = require("ente-base/next.config.base.js");+const baseConfig = require("ente-base/next.config.base.js");++module.exports = {+ ...baseConfig,+ // Static deployments serve arbitrary profile links through index.html.+ // In development, mirror that behavior with a fallback rewrite.+ ...(process.env.NODE_ENV === "development" && {+ output: undefined,+ async rewrites() {+ return {+ fallback: [+ {+ source: "/:path((?!_next|images|favicon.ico).*)",+ destination: "/",+ },+ ],+ };+ },+ }),+};diff --git a/web/apps/social/public/_redirects b/web/apps/social/public/_redirectsnew file mode 100644index 0000000000..4aa7faf062--- /dev/null+++ b/web/apps/social/public/_redirects@@ -0,0 +1 @@+/* /index.html 200diff --git a/web/apps/social/src/pages/index.tsx b/web/apps/social/src/pages/index.tsxindex fc9409e487..341e9e6737 100644--- a/web/apps/social/src/pages/index.tsx+++ b/web/apps/social/src/pages/index.tsx@@ -1,5 +1,6 @@+import { Box } from "@mui/material";import Head from "next/head";-import React, { useState } from "react";+import React, { useEffect, useState } from "react";import {CreateAccountScreen,createAccountBackground,@@ -19,6 +20,7 @@ import {ProfileScreen,profileBackground,} from "screens/ProfileScreen";+import { PublicProfileScreen } from "screens/PublicProfileScreen";import {SetupProfileScreen,setupProfileBackground,@@ -46,7 +48,58 @@ type Screen =type ProfileBackScreen = "login" | "recovery-key";+const samplePublicProfileData = {+ avatarUrl: "/images/sample-avatar.jpg",+ fullName: "Maya Iyer",+ username: "maya",+};++interface PublicProfileLink {+ token: string;+ username: string;+}++type RouteMode =+ | { kind: "checking" }+ | { kind: "app" }+ | ({ kind: "public-profile" } & PublicProfileLink);++const parsePublicProfileLink = (): PublicProfileLink | null => {+ const match = /^\/([^/]+)\/?$/.exec(window.location.pathname);+ const token = window.location.hash.slice(1);+ if (!match || !token) return null;++ try {+ const username = decodeURIComponent(match[1] ?? "").trim();+ return username ? { token, username } : null;+ } catch {+ return null;+ }+};++const profileNameFromUsername = (username: string) =>+ username+ .replace(/[._-]+/g, " ")+ .split(/\s+/)+ .filter(Boolean)+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))+ .join(" ");++const publicProfileFromLink = ({+ username,+}: PublicProfileLink): SetupProfile => ({+ avatarUrl: samplePublicProfileData.avatarUrl,+ fullName:+ username == samplePublicProfileData.username+ ? samplePublicProfileData.fullName+ : profileNameFromUsername(username),+ username,+});+const Page: React.FC = () => {+ const [routeMode, setRouteMode] = useState<RouteMode>({+ kind: "checking",+ });const [screen, setScreen] = useState<Screen>("onboarding");const [email, setEmail] = useState("[email protected]");const [profile, setProfile] = useState<SetupProfile | null>(null);@@ -58,31 +111,40 @@ const Page: React.FC = () => {setScreen("setup-profile");};+ useEffect(() => {+ const publicProfileLink = parsePublicProfileLink();+ setRouteMode(+ publicProfileLink+ ? { kind: "public-profile", ...publicProfileLink }+ : { kind: "app" },+ );+ }, []);++ const themeColor =+ routeMode.kind != "app"+ ? profileBackground+ : screen == "onboarding"+ ? onboardingGreen+ : screen == "verify-email"+ ? verifyEmailBackground+ : screen == "recovery-key"+ ? recoveryKeyBackground+ : screen == "login"+ ? loginBackground+ : screen == "setup-profile"+ ? setupProfileBackground+ : screen == "share-profile-link"+ ? shareProfileLinkBackground+ : screen == "home"+ ? homeBackground+ : screen == "profile"+ ? profileBackground+ : createAccountBackground;+return (<><Head>- <meta- name="theme-color"- content={- screen == "onboarding"- ? onboardingGreen- : screen == "verify-email"- ? verifyEmailBackground- : screen == "recovery-key"- ? recoveryKeyBackground- : screen == "login"- ? loginBackground- : screen == "setup-profile"- ? setupProfileBackground- : screen == "share-profile-link"- ? shareProfileLinkBackground- : screen == "home"- ? homeBackground- : screen == "profile"- ? profileBackground- : createAccountBackground- }- />+ <meta name="theme-color" content={themeColor} /><meta name="description" content={onboardingDescription} /><link rel="preconnect" href="https://fonts.googleapis.com" /><link@@ -95,70 +157,78 @@ const Page: React.FC = () => {rel="stylesheet"/></Head>- {screen == "onboarding" && (- <OnboardingScreen- onCreateAccount={() => setScreen("create-account")}- onLogin={() => setScreen("login")}- />- )}- {screen == "create-account" && (- <CreateAccountScreen- onBack={() => setScreen("onboarding")}- onCreateAccount={(nextEmail) => {- setEmail(nextEmail || "[email protected]");- setScreen("verify-email");- }}- onLogin={() => setScreen("login")}- />- )}- {screen == "login" && (- <LoginScreen- onBack={() => setScreen("onboarding")}- onContinue={() => openSetupProfile("login")}- onSignup={() => setScreen("create-account")}- />- )}- {screen == "verify-email" && (- <VerifyEmailScreen- email={email}- onBack={() => setScreen("create-account")}- onChangeEmail={() => setScreen("create-account")}- onVerify={() => setScreen("recovery-key")}- />- )}- {screen == "recovery-key" && (- <RecoveryKeyScreen- onBack={() => setScreen("verify-email")}- onNext={() => openSetupProfile("recovery-key")}- />- )}- {screen == "setup-profile" && (- <SetupProfileScreen- onBack={() => setScreen(profileBackScreen)}- onContinue={(nextProfile) => {- setProfile(nextProfile);- setScreen("share-profile-link");- }}- />- )}- {screen == "share-profile-link" && profile && (- <ShareProfileLinkScreen- profile={profile}- onBack={() => setScreen("setup-profile")}- onDone={() => setScreen("home")}- />- )}- {screen == "home" && profile && (- <HomeScreen- profile={profile}- onOpenProfile={() => setScreen("profile")}- />- )}- {screen == "profile" && profile && (- <ProfileScreen- profile={profile}- onBack={() => setScreen("home")}- />+ {routeMode.kind == "checking" ? (+ <Box sx={{ bgcolor: profileBackground, minHeight: "100svh" }} />+ ) : routeMode.kind == "public-profile" ? (+ <PublicProfileScreen profile={publicProfileFromLink(routeMode)} />+ ) : (+ <>+ {screen == "onboarding" && (+ <OnboardingScreen+ onCreateAccount={() => setScreen("create-account")}+ onLogin={() => setScreen("login")}+ />+ )}+ {screen == "create-account" && (+ <CreateAccountScreen+ onBack={() => setScreen("onboarding")}+ onCreateAccount={(nextEmail) => {+ setEmail(nextEmail || "[email protected]");+ setScreen("verify-email");+ }}+ onLogin={() => setScreen("login")}+ />+ )}+ {screen == "login" && (+ <LoginScreen+ onBack={() => setScreen("onboarding")}+ onContinue={() => openSetupProfile("login")}+ onSignup={() => setScreen("create-account")}+ />+ )}+ {screen == "verify-email" && (+ <VerifyEmailScreen+ email={email}+ onBack={() => setScreen("create-account")}+ onChangeEmail={() => setScreen("create-account")}+ onVerify={() => setScreen("recovery-key")}+ />+ )}+ {screen == "recovery-key" && (+ <RecoveryKeyScreen+ onBack={() => setScreen("verify-email")}+ onNext={() => openSetupProfile("recovery-key")}+ />+ )}+ {screen == "setup-profile" && (+ <SetupProfileScreen+ onBack={() => setScreen(profileBackScreen)}+ onContinue={(nextProfile) => {+ setProfile(nextProfile);+ setScreen("share-profile-link");+ }}+ />+ )}+ {screen == "share-profile-link" && profile && (+ <ShareProfileLinkScreen+ profile={profile}+ onBack={() => setScreen("setup-profile")}+ onDone={() => setScreen("home")}+ />+ )}+ {screen == "home" && profile && (+ <HomeScreen+ profile={profile}+ onOpenProfile={() => setScreen("profile")}+ />+ )}+ {screen == "profile" && profile && (+ <ProfileScreen+ profile={profile}+ onBack={() => setScreen("home")}+ />+ )}+ </>)}</>);diff --git a/web/apps/social/src/screens/ProfileScreen.tsx b/web/apps/social/src/screens/ProfileScreen.tsxindex cbfacfcbb4..0ddcb34e2f 100644--- a/web/apps/social/src/screens/ProfileScreen.tsx+++ b/web/apps/social/src/screens/ProfileScreen.tsx@@ -1,6 +1,7 @@import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded";import SettingsRoundedIcon from "@mui/icons-material/SettingsRounded";-import { Box } from "@mui/material";+import { Box, Button } from "@mui/material";+import { EnteLogo } from "ente-base/components/EnteLogo";import React from "react";import type { SetupProfile } from "screens/SetupProfileScreen";@@ -77,7 +78,9 @@ const sampleMomentItems = [];interface ProfileScreenProps {- onBack: () => void;+ headerVariant?: "owner" | "public";+ onBack?: () => void;+ onFollow?: () => void;profile: SetupProfile;}@@ -115,9 +118,12 @@ const Stat: React.FC<StatProps> = ({ label, value }) => ();export const ProfileScreen: React.FC<ProfileScreenProps> = ({+ headerVariant = "owner",onBack,+ onFollow,profile,}) => {+ const isPublicProfile = headerVariant == "public";const displayName = profile.fullName.trim() || profile.username.trim();const initialsSource = displayName || profile.username.trim();const initials = initialsSource@@ -153,78 +159,122 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({sx={{alignItems: "center",display: "grid",- gridTemplateColumns: "24px 1fr 24px",- p: 2,+ gridTemplateColumns: isPublicProfile+ ? "1fr auto"+ : "24px 1fr 24px",+ height: 56,+ px: 2,+ py: 0,width: "100%",}}>- <Box- component="button"- type="button"- aria-label="Back to home"- onClick={onBack}- sx={{- alignItems: "center",- bgcolor: "transparent",- border: 0,- color: textBase,- cursor: "pointer",- display: "flex",- height: 24,- justifyContent: "flex-start",- p: 0,- width: 24,- "&:focus-visible": {- borderRadius: "50%",- outline: `2px solid ${green}`,- outlineOffset: 2,- },- }}- >- <ArrowBackRoundedIcon sx={{ fontSize: 24 }} />- </Box>- <Box- component="h1"- sx={{- color: textBase,- fontFamily: '"Inter Variable", Inter, sans-serif',- fontSize: 18,- fontWeight: 700,- justifySelf: "center",- lineHeight: "24px",- m: 0,- maxWidth: "100%",- overflow: "hidden",- textOverflow: "ellipsis",- whiteSpace: "nowrap",- }}- >- {profile.username}- </Box>- <Box- component="button"- type="button"- aria-label="Settings"- sx={{- alignItems: "center",- bgcolor: "transparent",- border: 0,- color: textBase,- cursor: "pointer",- display: "flex",- height: 24,- justifyContent: "flex-end",- p: 0,- width: 24,- "&:focus-visible": {- borderRadius: "50%",- outline: `2px solid ${green}`,- outlineOffset: 2,- },- }}- >- <SettingsRoundedIcon sx={{ fontSize: 22 }} />- </Box>+ {isPublicProfile ? (+ <Box+ sx={{+ alignSelf: "center",+ color: textBase,+ justifySelf: "flex-start",+ lineHeight: 0,+ overflow: "visible",+ width: 65,+ "& svg": {+ display: "block",+ overflow: "visible",+ },+ }}+ >+ <EnteLogo height={20} />+ </Box>+ ) : (+ <Box+ component="button"+ type="button"+ aria-label="Back to home"+ onClick={onBack}+ sx={{+ alignItems: "center",+ bgcolor: "transparent",+ border: 0,+ color: textBase,+ cursor: "pointer",+ display: "flex",+ height: 24,+ justifyContent: "flex-start",+ p: 0,+ width: 24,+ "&:focus-visible": {+ borderRadius: "50%",+ outline: `2px solid ${green}`,+ outlineOffset: 2,+ },+ }}+ >+ <ArrowBackRoundedIcon sx={{ fontSize: 24 }} />+ </Box>+ )}+ {!isPublicProfile && (+ <Box+ component="h1"+ sx={{+ color: textBase,+ fontFamily:+ '"Inter Variable", Inter, sans-serif',+ fontSize: 18,+ fontWeight: 700,+ justifySelf: "center",+ lineHeight: "24px",+ m: 0,+ maxWidth: "100%",+ overflow: "hidden",+ textOverflow: "ellipsis",+ whiteSpace: "nowrap",+ }}+ >+ {profile.username}+ </Box>+ )}+ {isPublicProfile ? (+ <Button+ type="button"+ onClick={onFollow}+ sx={{+ backgroundColor: green,+ borderRadius: "16px",+ color: "#FFFFFF",+ justifySelf: "flex-end",+ paddingBlock: "11px",+ paddingInline: "20px",+ "&:hover": { backgroundColor: "#07A820" },+ }}+ >+ Follow+ </Button>+ ) : (+ <Box+ component="button"+ type="button"+ aria-label="Settings"+ sx={{+ alignItems: "center",+ bgcolor: "transparent",+ border: 0,+ color: textBase,+ cursor: "pointer",+ display: "flex",+ height: 24,+ justifyContent: "flex-end",+ p: 0,+ width: 24,+ "&:focus-visible": {+ borderRadius: "50%",+ outline: `2px solid ${green}`,+ outlineOffset: 2,+ },+ }}+ >+ <SettingsRoundedIcon sx={{ fontSize: 22 }} />+ </Box>+ )}</Box><Box sx={{ bgcolor: divider, height: "1px", width: "100%" }} />diff --git a/web/apps/social/src/screens/PublicProfileScreen.tsx b/web/apps/social/src/screens/PublicProfileScreen.tsxnew file mode 100644index 0000000000..928687908c--- /dev/null+++ b/web/apps/social/src/screens/PublicProfileScreen.tsx@@ -0,0 +1,19 @@+import React from "react";+import { ProfileScreen } from "screens/ProfileScreen";+import type { SetupProfile } from "screens/SetupProfileScreen";++interface PublicProfileScreenProps {+ profile: SetupProfile;+}++export const PublicProfileScreen: React.FC<PublicProfileScreenProps> = ({+ profile,+}) => (+ <ProfileScreen+ headerVariant="public"+ profile={profile}+ onFollow={() => {+ window.location.assign("/");+ }}+ />+);