Profil public : lien bobinoo.org/@pseudo visible sans compte (au choix)
deploy / deploy (push) Successful in 1m5s

Nouveau réglage « Profil visible sans compte » dans Modifier le profil,
désactivé par défaut et sans effet sur un compte privé. Une fois activé,
le lien bobinoo.org/@pseudo s'ouvre pour tout le monde : photo, bio,
Top 5, titres en cours et derniers vus, avec les notes. Les avis et la
bibliothèque complète restent réservés aux membres.

Côté base, public_profile() est la seule fonction ouverte sans compte :
elle renvoie null pour un profil non public, privé, suspendu ou inconnu
(pas moyen de deviner si un pseudo existe) et ne renvoie que le strict
nécessaire de chaque fiche. Le lien n'est pas indexé par les moteurs de
recherche. Un membre connecté qui ouvre le lien voit le profil comme
avant ; un visiteur peut s'abonner ou rejoindre Bobinoo depuis la page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
Claude committed 2026-12-02 11:14:33 +00:00
1 parent e161930e82
commit 116efa4a30
31 files changed
+486 -39

No files matched your search

+2 -1
View File
@@ -90,7 +90,8 @@ export default function TopFive({ onOpen, items: others }: { onOpen: (item: Medi
)
}
>
{t('top.title')} <span className="text-accent">5</span>
{/* « Mes Top 5 » pour le mien ; « Top 5 » pour celui d'un autre profil */}
{readOnly ? t('social.top5') : <>{t('top.title')} <span className="text-accent">5</span></>}
</SectionTitle>
{/* Choix de la catégorie */}
+25 -2
View File
@@ -1,4 +1,4 @@
import { Camera, ImagePlus, Loader2, Lock, Trash2 } from 'lucide-react'
import { Camera, Globe, ImagePlus, Loader2, Lock, Trash2 } from 'lucide-react'
import { useEffect, useRef, useState } from 'react'
import { t } from '../../i18n'
import { deleteProfileImage, updateProfile, uploadProfileImage, USERNAME_RE, type ProfilePatch } from '../../lib/cloud/social'
@@ -9,13 +9,14 @@ import ImageCropper from './ImageCropper'
import Sheet from './Sheet'
import { useSocial } from './SocialProvider'
/** Modifier mon profil : photo, bannière, nom, pseudo, bio, compte privé. */
/** Modifier mon profil : photo, bannière, nom, pseudo, bio, compte privé, lien public. */
export default function EditProfile({ onClose }: { onClose: () => void }) {
const { me, refresh } = useSocial()
const [displayName, setDisplayName] = useState(me?.displayName ?? '')
const [username, setUsername] = useState(me?.username ?? '')
const [bio, setBio] = useState(me?.bio ?? '')
const [isPrivate, setIsPrivate] = useState(me?.isPrivate ?? false)
const [publicLink, setPublicLink] = useState(me?.publicLink ?? false)
const [avatar, setAvatar] = useState<{ blob?: Blob; preview?: string; removed?: boolean }>({ preview: me?.avatarUrl })
const [banner, setBanner] = useState<{ blob?: Blob; preview?: string; removed?: boolean }>({ preview: me?.bannerUrl })
const [saving, setSaving] = useState(false)
@@ -73,6 +74,7 @@ export default function EditProfile({ onClose }: { onClose: () => void }) {
if (cleanUsername !== me.username) patch.username = cleanUsername
if (bio.trim() !== me.bio) patch.bio = bio.trim()
if (isPrivate !== me.isPrivate) patch.is_private = isPrivate
if (publicLink !== !!me.publicLink) patch.public_link = publicLink
if (avatar.blob) {
patch.avatar_url = await uploadProfileImage('avatar', avatar.blob)
uploaded.push(patch.avatar_url)
@@ -186,6 +188,27 @@ export default function EditProfile({ onClose }: { onClose: () => void }) {
</span>
</button>
{/* Lien bobinoo.org/@pseudo ouvert sans compte : sans effet tant que le compte est privé */}
<button
type="button"
role="switch"
aria-checked={publicLink && !isPrivate}
disabled={isPrivate}
onClick={() => setPublicLink((v) => !v)}
className="flex w-full items-center gap-3 rounded-2xl border border-line px-4 py-3.5 text-start disabled:opacity-60"
>
<Globe size={18} className="shrink-0 text-ink-2" />
<span className="flex-1">
<span className="block text-sm font-medium">{t('social.publicLink')}</span>
<span className="mt-0.5 block text-xs text-ink-3">
{isPrivate ? t('social.publicLinkPrivate') : t('social.publicLinkHint', { link: `bobinoo.org/@${usernameOk ? cleanUsername : me.username}` })}
</span>
</span>
<span className={cx('relative h-6 w-11 shrink-0 rounded-full transition-colors', publicLink && !isPrivate ? 'bg-accent-fill' : 'bg-surface-2 border border-line-strong')}>
<span className={cx('absolute top-0.5 size-5 rounded-full bg-ink transition-all', publicLink && !isPrivate ? 'start-[22px] bg-on-accent' : 'start-0.5')} />
</span>
</button>
{error && (
<p role="alert" className="rounded-xl border border-accent px-3 py-2.5 text-sm">
{error}
+50 -16
View File
@@ -1,7 +1,7 @@
import { Ban, Check, Loader2, Lock, Share2, Star, UserCheck, UserPlus } from 'lucide-react'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { fmtNumber, t } from '../../i18n'
import { follow, getProfile, getProfileItems, PROFILE_ITEMS_PAGE, profileLink, unfollow, type Profile } from '../../lib/cloud/social'
import { follow, getProfile, getProfileItems, getPublicProfile, PROFILE_ITEMS_PAGE, profileLink, unfollow, type Profile } from '../../lib/cloud/social'
import { STATUSES, TOP_CATEGORIES } from '../../lib/constants'
import { cx, formatRating } from '../../lib/utils'
import { useMedia } from '../../store'
@@ -50,10 +50,14 @@ function Stat({ value, label, onClick }: { value?: number; label: string; onClic
)
}
/** Page de profil (la mienne ou celle d'un autre). */
export default function ProfileView({ username, onClose }: { username: string; onClose: () => void }) {
/**
* Page de profil (la mienne ou celle d'un autre).
* `guest` : ouverte sans compte depuis un lien bobinoo.org/@pseudo. Seulement la version publique du profil
* (si la personne l'a activée), et chaque geste (suivre, voir la bibliothèque) propose de créer un compte.
*/
export default function ProfileView({ username, onClose, guest = false }: { username: string; onClose: () => void; guest?: boolean }) {
const social = useSocial()
const { settings, items: myItems } = useMedia()
const { settings, items: myItems, requestAccount } = useMedia()
// Mon profil : affiché tout de suite avec ce qu'on a déjà, puis rechargé
const [profile, setProfile] = useState<Profile | null | undefined>(() => (social.me?.username === username ? social.me : undefined))
const [error, setError] = useState<string>()
@@ -62,7 +66,7 @@ export default function ProfileView({ username, onClose }: { username: string; o
const [confirmUnfollow, setConfirmUnfollow] = useState(false)
const [toast, setToast] = useState<string>()
const [confirmBlock, setConfirmBlock] = useState(false)
const { isBlocked } = useBlocked(!!profile && !profile.isMe)
const { isBlocked } = useBlocked(!guest && !!profile && !profile.isMe)
const blocked = !!profile && !profile.isMe && isBlocked(profile.id)
/** `reload` : rechargement après une action (s'abonner, bloquer…) — en cas d'échec, on garde le profil affiché. */
@@ -70,7 +74,7 @@ export default function ProfileView({ username, onClose }: { username: string; o
async (reload = false) => {
if (!reload) setError(undefined)
try {
const next = await getProfile(username)
const next = await (guest ? getPublicProfile(username) : getProfile(username))
if (reload) setError(undefined)
setProfile(next)
} catch (e) {
@@ -79,7 +83,7 @@ export default function ProfileView({ username, onClose }: { username: string; o
setProfile(null)
}
},
[username],
[username, guest],
)
useEffect(() => {
@@ -104,11 +108,15 @@ export default function ProfileView({ username, onClose }: { username: string; o
const share = async () => {
if (!profile) return
const url = profileLink(profile.username)
// Mon lien, pas encore public : il ne s'ouvrira que pour les membres connectés (on le dit, sans bloquer le partage)
const membersOnly = profile.isMe && !profile.publicLink
try {
if (navigator.share && window.matchMedia?.('(pointer: coarse)').matches) await navigator.share({ title: profile.displayName, url })
else {
if (navigator.share && window.matchMedia?.('(pointer: coarse)').matches) {
await navigator.share({ title: profile.displayName, url })
if (membersOnly) setToast(t('social.linkMembersOnly'))
} else {
await navigator.clipboard.writeText(url)
setToast(t('social.linkCopied'))
setToast(membersOnly ? `${t('social.linkCopied')} ${t('social.linkMembersOnly')}` : t('social.linkCopied'))
}
} catch {
/* partage annulé */
@@ -190,6 +198,8 @@ export default function ProfileView({ username, onClose }: { username: string; o
// Mon profil : l'onglet Top 5 est toujours là (c'est ici qu'on le modifie) ; un autre : seulement s'il en a un
const showTop = !!profile && (profile.isMe ? settings.topCategories.length > 0 : topByCategory.length > 0)
// Sans compte : pas de bibliothèque complète (réservée aux membres)
const tabs = (['profile', ...(showTop ? ['top'] : []), ...(guest ? [] : ['library'])] as ('profile' | 'top' | 'library')[])
return (
<Sheet
@@ -211,7 +221,16 @@ export default function ProfileView({ username, onClose }: { username: string; o
</p>
) : profile === null ? (
<div className="px-4">
<EmptyState title={error ? t('social.loadError') : t('social.notFound')} text={error ?? t('social.notFoundHint', { username })} />
{guest && !error ? (
<>
<EmptyState title={t('social.publicNotFound')} text={t('social.publicNotFoundHint')} />
<button onClick={requestAccount} className="btn btn-primary mx-auto mt-5 flex px-5 py-2.5">
{t('social.publicJoin')}
</button>
</>
) : (
<EmptyState title={error ? t('social.loadError') : t('social.notFound')} text={error ?? t('social.notFoundHint', { username })} />
)}
</div>
) : (
<>
@@ -227,6 +246,10 @@ export default function ProfileView({ username, onClose }: { username: string; o
<button onClick={social.openEdit} className="btn btn-ghost mt-[3.5rem] px-4 py-2 text-sm lg:mt-[4.25rem]">
{t('social.editProfile')}
</button>
) : guest ? (
<button onClick={requestAccount} className="btn btn-primary mt-[3.5rem] px-4 py-2 text-sm lg:mt-[4.25rem]">
<UserPlus size={15} /> {t('social.follow')}
</button>
) : (
<div className="mt-[3.5rem] flex items-center gap-1 lg:mt-[4.25rem]">
{blocked ? (
@@ -288,8 +311,8 @@ export default function ProfileView({ username, onClose }: { username: string; o
<div className="mt-5 flex divide-x divide-line rounded-2xl border border-line py-3 lg:max-w-2xl">
<Stat value={profile.visible ? (profile.seen ?? 0) : undefined} label={t('social.seen')} />
<Stat value={profile.followers} label={t('social.followers', { count: profile.followers })} onClick={profile.visible ? () => social.openFollowList(profile, 'followers') : undefined} />
<Stat value={profile.following} label={t('social.followingCount', { count: profile.following })} onClick={profile.visible ? () => social.openFollowList(profile, 'following') : undefined} />
<Stat value={profile.followers} label={t('social.followers', { count: profile.followers })} onClick={profile.visible && !guest ? () => social.openFollowList(profile, 'followers') : undefined} />
<Stat value={profile.following} label={t('social.followingCount', { count: profile.following })} onClick={profile.visible && !guest ? () => social.openFollowList(profile, 'following') : undefined} />
</div>
{profile.isMe && social.requests.length > 0 && (
@@ -307,8 +330,8 @@ export default function ProfileView({ username, onClose }: { username: string; o
</div>
) : (
<>
<div className={cx('mt-6 grid gap-1 rounded-md border border-line p-1 lg:max-w-md', showTop ? 'grid-cols-3' : 'grid-cols-2')}>
{(showTop ? (['profile', 'top', 'library'] as const) : (['profile', 'library'] as const)).map((v) => (
<div className={cx('mt-6 grid gap-1 rounded-md border border-line p-1 lg:max-w-md', tabs.length === 3 ? 'grid-cols-3' : 'grid-cols-2')}>
{tabs.map((v) => (
<button
key={v}
onClick={() => setTab(v)}
@@ -319,7 +342,18 @@ export default function ProfileView({ username, onClose }: { username: string; o
))}
</div>
{tab === 'profile' ? (
<ProfileTab profile={profile} topByCategory={topByCategory} onOpen={openItem} />
<>
<ProfileTab profile={profile} topByCategory={topByCategory} onOpen={openItem} />
{guest && (
<div className="mt-10 rounded-2xl border border-line px-5 py-6 text-center lg:max-w-2xl">
<p className="font-semibold">{t('social.publicCtaTitle')}</p>
<p className="mx-auto mt-1 max-w-sm text-sm text-ink-3">{t('social.publicCtaText', { name: profile.displayName })}</p>
<button onClick={requestAccount} className="btn btn-primary mx-auto mt-4 flex px-5 py-2.5">
{t('social.publicJoin')}
</button>
</div>
)}
</>
) : tab === 'top' ? (
<TopTab profile={profile} onOpen={openItem} />
) : (
+21 -14
View File
@@ -1,6 +1,6 @@
import { createContext, Suspense, useCallback, useContext, useEffect, useMemo, useState, type ReactNode } from 'react'
import { createContext, Suspense, useCallback, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
import { lazyPreload } from '../../lib/lazyPreload'
import { cachedMyProfile, getFollowRequests, getMyProfile, unreadNotifications, type Profile, type ProfileCard } from '../../lib/cloud/social'
import { cachedMyProfile, getFollowRequests, getMyProfile, profileFromPath, unreadNotifications, type Profile, type ProfileCard } from '../../lib/cloud/social'
import { useMedia } from '../../store'
import type { MediaItem } from '../../types'
import type { PeekOwner } from './ItemPeek'
@@ -97,7 +97,7 @@ export function SocialProvider({
/** Ouvre la fiche d'un titre pas encore dans ma bibliothèque */
onOpenSeed?: (seed: SearchResult) => void
}) {
const { account, items } = useMedia()
const { account, items, guest } = useMedia()
const enabled = !!account
// Profil gardé sur l'appareil : photo et pseudo tout de suite, sans attendre le serveur
const [me, setMe] = useState<Profile | null>(() => (enabled ? cachedMyProfile() : null))
@@ -161,28 +161,34 @@ export function SocialProvider({
const push = useCallback((o: Overlay) => setStack((s) => [...s.slice(-8), { ...o, uid: ++overlayUid }]), [])
const close = useCallback((uid: number) => setStack((s) => s.filter((x) => x.uid !== uid)), [])
// Lien partagé « #/u/pseudo »
// Lien partagé « bobinoo.org/@pseudo » (ou l'ancien « #/u/pseudo ») : le profil s'ouvre par-dessus l'accueil.
// Sans compte (mode découverte), c'est la version publique, si la personne l'a activée.
useEffect(() => {
if (!enabled) return
if (!enabled && !guest) return
const check = () => {
const m = location.hash.match(/^#\/u\/([a-z0-9_]{3,20})$/i)
if (!m) return
history.replaceState(null, '', `${location.pathname}${location.search}#/home`)
push({ kind: 'profile', username: m[1].toLowerCase() })
const name = profileFromPath() ?? location.hash.match(/^#\/u\/([a-z0-9_]{3,20})$/i)?.[1].toLowerCase()
if (!name) return
history.replaceState(null, '', `/${location.search}#/home`)
push({ kind: 'profile', username: name })
}
check()
window.addEventListener('hashchange', check)
return () => window.removeEventListener('hashchange', check)
}, [enabled, push])
}, [enabled, guest, push])
const openItem = useCallback(
(item: MediaItem, owner?: PeekOwner) => {
// Sans compte (profil public) : la fiche du catalogue, en lecture seule
if (!enabled) {
if (item.externalId) void openTitleRef.current({ externalId: item.externalId, title: item.title, poster: item.poster, type: item.type, year: item.year, addedAt: '', addedBy: null })
return
}
const mine = !owner || owner.username === me?.username
const local = mine ? items.find((i) => i.id === item.id) : undefined
if (local) onOpenOwnItem(local)
else setPeeked({ item, owner })
},
[items, me?.username, onOpenOwnItem],
[enabled, items, me?.username, onOpenOwnItem],
)
const openTitle = useCallback(
@@ -208,6 +214,8 @@ export function SocialProvider({
},
[items, onOpenOwnItem, onOpenSeed],
)
const openTitleRef = useRef(openTitle)
openTitleRef.current = openTitle
const api = useMemo<SocialApi>(
() => ({
@@ -235,11 +243,10 @@ export function SocialProvider({
return (
<SocialContext.Provider value={api}>
{/* Les écrans sociaux sont placés avant l'app : une fiche ouverte depuis un profil passe au-dessus */}
{enabled &&
stack.map((o) => (
{(enabled ? stack : guest ? stack.filter((o) => o.kind === 'profile') : []).map((o) => (
<Suspense key={o.uid} fallback={null}>
{o.kind === 'profile' ? (
<ProfileView key={o.uid} username={o.username} onClose={() => close(o.uid)} />
<ProfileView key={o.uid} username={o.username} guest={!enabled} onClose={() => close(o.uid)} />
) : o.kind === 'search' ? (
<PeopleSearch key={o.uid} onClose={() => close(o.uid)} />
) : o.kind === 'edit' ? (