diff --git a/app/app/api/link-preview/route.ts b/app/app/api/link-preview/route.ts new file mode 100644 index 0000000..b409f43 --- /dev/null +++ b/app/app/api/link-preview/route.ts @@ -0,0 +1,32 @@ +import { NextResponse, type NextRequest } from "next/server"; +import { config } from "@/lib/config"; +import { loadLinkPreview } from "@/lib/link-preview-server"; +import { serverClient } from "@/lib/supabase/server"; + +export const runtime = "nodejs"; +export const dynamic = "force-dynamic"; + +/** + * Link-Vorschau für Beiträge. Der Server ruft die Seite ab (nie private Netze, max. 5 s, + * nur der Kopf der Seite), damit Lesende keine Verbindung zu fremden Seiten aufbauen, + * bevor sie klicken. Im Live-Betrieb nur für angemeldete Mitglieder: kein offener Proxy. + */ +export async function GET(request: NextRequest) { + const url = request.nextUrl.searchParams.get("url") || ""; + if (!url || url.length > 2048) + return NextResponse.json({ error: "Ungültige Adresse." }, { status: 400 }); + if (config.mode === "supabase") { + const client = await serverClient(); + const { data } = await client.auth.getUser(); + if (!data.user) + return NextResponse.json( + { error: "Bitte melde dich an." }, + { status: 401, headers: { "Cache-Control": "private, no-store" } }, + ); + } + const preview = await loadLinkPreview(url); + return NextResponse.json( + { preview }, + { headers: { "Cache-Control": "private, max-age=3600" } }, + ); +} diff --git a/app/app/einstellungen/page.tsx b/app/app/einstellungen/page.tsx new file mode 100644 index 0000000..95f9619 --- /dev/null +++ b/app/app/einstellungen/page.tsx @@ -0,0 +1,9 @@ +import type { Metadata } from "next"; +import { SettingsPage } from "@/components/settings"; +export const metadata: Metadata = { + title: "Einstellungen", + robots: { index: false }, +}; +export default function Page() { + return ; +} diff --git a/app/app/globals.css b/app/app/globals.css index ebee528..bef47de 100644 --- a/app/app/globals.css +++ b/app/app/globals.css @@ -3379,3 +3379,688 @@ label.consent input[type="checkbox"] { font-size: 12px; padding: 8px 12px; } + +/* Profil-Einstellungen und erweiterte Profilansicht. */ +.profile-meta { + display: flex; + flex-wrap: wrap; + gap: 4px 14px; + margin-top: 8px; + font-size: 13px; + color: var(--ink-muted); +} +.profile-meta span { + display: inline-flex; + align-items: center; + gap: 5px; +} +.profile-links { + list-style: none; + display: flex; + flex-wrap: wrap; + gap: 8px; + padding: 0; + margin: 16px 0 0; +} +.profile-links a { + display: inline-flex; + align-items: center; + gap: 6px; + min-height: 34px; + padding: 6px 12px; + border: 1.5px solid var(--line); + border-radius: 999px; + font-size: 12px; + font-weight: 700; + overflow-wrap: anywhere; +} +.profile-links a:hover { + background: var(--mango); + color: var(--on-mango); +} +.profile-owner-bar { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 10px; + margin: 14px 0 4px; +} +.profile-owner-bar .button { + min-height: 36px; + padding: 6px 14px; + font-size: 12px; +} +.visibility-chip { + display: inline-flex; + align-items: center; + gap: 6px; + font-size: 11px; + font-weight: 800; + letter-spacing: 0.06em; + text-transform: uppercase; + padding: 5px 10px; + border: 1.5px solid var(--line); + border-radius: 999px; +} +.settings-layout { + max-width: 710px; + margin: auto; +} +.settings-layout > .eyebrow { + display: flex; +} +.settings-title { + font-size: 54px; + margin: 12px 0 24px; +} +.settings-tabs { + display: flex; + gap: 8px; + overflow-x: auto; + border-bottom: 2px solid var(--line); + padding-bottom: 12px; + margin-bottom: 8px; +} +.settings-tabs button { + display: inline-flex; + align-items: center; + gap: 8px; + flex: none; + min-height: 42px; + padding: 8px 14px; + border: 1.5px solid transparent; + border-radius: 5px; + font-weight: 750; + font-size: 13px; +} +.settings-tabs button:hover { + background: color-mix(in srgb, var(--ink) 7%, transparent); +} +.settings-tabs button[data-state="active"] { + border-color: var(--line); + background: var(--mango); + color: var(--on-mango); +} +.settings-panel { + padding: 8px 0 40px; +} +.settings-panel h2 { + font-size: 26px; + margin: 28px 0 12px; +} +.settings-panel fieldset { + border: 0; + padding: 0; + margin: 24px 0 0; + min-width: 0; +} +.settings-panel legend { + padding: 0; + font-size: 12px; + font-weight: 700; + margin-bottom: 8px; +} +.settings-panel legend small { + font-weight: 400; + color: var(--ink-muted); + margin-left: 6px; +} +.settings-save { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: 12px; + margin-top: 26px; + padding-top: 18px; + border-top: 2px solid var(--line); +} +.settings-save .helper-text { + margin: 0; +} +.avatar-editor { + display: flex; + align-items: center; + gap: 22px; + padding: 18px 0 8px; +} +.avatar-editor .helper-text { + margin: 2px 0 10px; +} +.avatar-actions { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 14px; +} +.avatar-actions .button { + min-height: 40px; + padding: 8px 14px; + font-size: 13px; +} +.link-row { + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) auto; + gap: 8px; + margin-bottom: 8px; + align-items: center; +} +label.radio-card, +label.switch-row { + display: flex; + align-items: flex-start; + gap: 12px; + margin: 0 0 10px; + padding: 14px; + border: 1.5px solid var(--line); + border-radius: 5px; + background: var(--surface-raised); + font-weight: 400; + cursor: pointer; +} +label.radio-card.checked { + background: color-mix(in srgb, var(--mango) 16%, var(--surface-raised)); + box-shadow: 3px 3px 0 var(--line); +} +label.radio-card input[type="radio"], +label.switch-row input[type="checkbox"] { + width: 18px; + height: 18px; + flex: none; + margin: 2px 0 0; + padding: 0; + accent-color: var(--blue); +} +label.radio-card > svg { + flex: none; + margin-top: 1px; +} +label.radio-card > span, +label.switch-row > span { + float: none; + display: grid; + gap: 3px; + font-size: 14px; + color: var(--ink); +} +label.radio-card small, +label.switch-row small { + font-size: 12px; + color: var(--ink-muted); + line-height: 1.55; +} +label.switch-row:has(input:disabled) { + opacity: 0.5; + cursor: not-allowed; +} +.inline-form { + display: flex; + gap: 8px; + align-items: stretch; + margin-bottom: 16px; +} +.inline-form input { + flex: 1; + min-width: 0; +} +.account-email { + font-size: 14px; + margin-bottom: 4px; + overflow-wrap: anywhere; +} +.danger-zone { + margin-top: 36px; + padding: 18px; + border: 2px solid var(--line); + border-left: 6px solid #c1121f; + border-radius: 5px; +} +.danger-zone h2 { + margin-top: 0; +} +.button-danger { + background: #c1121f; + color: #fff; + border-color: #c1121f; +} +@media (max-width: 640px) { + .settings-title { + font-size: 40px; + } + .link-row { + grid-template-columns: 1fr auto; + } + .link-row input:first-child { + grid-column: 1 / -1; + } + .link-row .icon-button { + grid-column: 2; + grid-row: 2; + } + .avatar-editor { + flex-direction: column; + align-items: flex-start; + } + .inline-form { + flex-direction: column; + } +} + +/* ---------- Social-Basics: Links, Vorschau, Herzen, Kommentare ---------- */ +.inline-link { + color: var(--blue); + text-decoration: underline; + text-decoration-thickness: 1px; + text-underline-offset: 2px; + overflow-wrap: anywhere; +} +.inline-link:hover { + text-decoration-thickness: 2px; +} +.inline-mention { + color: var(--blue); + font-weight: 700; +} +[data-theme="dark"] .inline-link, +[data-theme="dark"] .inline-mention { + color: var(--mango); +} +.post-menu-push { + margin-left: auto; +} +.icon-action { + display: inline-flex; + align-items: center; + justify-content: center; + min-width: 32px; + min-height: 32px; + border-radius: var(--radius-sm); + color: var(--ink-muted); +} +.icon-action:hover:not(:disabled) { + color: var(--ink); + background: color-mix(in srgb, var(--ink) 6%, transparent); +} +.icon-action.send:not(:disabled) { + color: var(--blue); +} +.link-card { + display: flex; + border: 1px solid color-mix(in srgb, var(--line) 35%, transparent); + border-radius: 6px; + overflow: hidden; + margin: 12px 0 4px; + background: var(--surface-raised, var(--surface)); + transition: border-color 0.15s; +} +a.link-card:hover { + border-color: var(--line); +} +.link-card-loading { + height: 76px; + background: linear-gradient( + 90deg, + color-mix(in srgb, var(--ink) 4%, transparent), + color-mix(in srgb, var(--ink) 8%, transparent), + color-mix(in srgb, var(--ink) 4%, transparent) + ); + background-size: 200% 100%; + animation: link-shimmer 1.4s infinite linear; +} +@keyframes link-shimmer { + to { + background-position: -200% 0; + } +} +.link-card-image { + flex: 0 0 132px; + background: color-mix(in srgb, var(--ink) 5%, transparent); +} +.link-card-image img { + width: 100%; + height: 100%; + object-fit: cover; + display: block; +} +.link-card-body { + display: flex; + flex-direction: column; + gap: 3px; + padding: 11px 13px; + min-width: 0; + font-size: 12px; +} +.link-card-body strong { + font-size: 13px; + line-height: 1.35; + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + overflow: hidden; +} +.link-card-body small { + color: var(--ink-muted); + font-size: 11px; + line-height: 1.4; + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + overflow: hidden; +} +.link-site { + display: inline-flex; + align-items: center; + gap: 4px; + font-size: 9px; + font-weight: 800; + letter-spacing: 0.06em; + text-transform: uppercase; + color: var(--ink-muted); +} +.link-card-media .link-card-body .text-button { + align-self: flex-start; + margin-top: 4px; +} +.link-card-media .embed-note { + font-size: 9px; +} +.media-cover { + position: relative; + flex: 0 0 140px; + min-height: 140px; + padding: 0; + overflow: hidden; + background: #1db954; +} +.media-youtube .media-cover { + flex-basis: 200px; + min-height: 0; + aspect-ratio: 16 / 9; + background: #111; +} +.media-cover img { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + object-fit: cover; +} +.media-fallback { + position: absolute; + inset: 0; + display: grid; + place-items: end start; + padding: 8px 10px; + font-size: 11px !important; + color: #fff; + font-weight: 800; + font-size: 14px; +} +.media-play { + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + width: 48px; + height: 48px; + border-radius: 50%; + display: grid; + place-items: center; + color: #fff; + background: rgb(0 0 0 / 0.62); + transition: transform 0.15s; +} +.media-cover:hover .media-play { + transform: translate(-50%, -50%) scale(1.08); +} +.link-embed { + margin: 12px 0 4px; + border-radius: 12px; + overflow: hidden; +} +.link-embed.embed-youtube { + aspect-ratio: 16 / 9; +} +.link-embed iframe { + width: 100%; + height: 100%; + border: 0; + display: block; +} +.like-summary { + display: flex; + align-items: center; + gap: 8px; + font-size: 10px; + color: var(--ink-muted); + margin: -4px 0 8px; + text-align: left; +} +.like-summary:hover { + color: var(--ink); + text-decoration: underline; +} +.like-faces { + display: inline-flex; +} +.like-faces .avatar { + width: 20px; + height: 20px; + font-size: 7px; + border: 1.5px solid var(--surface); + margin-left: -6px; +} +.like-faces .avatar:first-child { + margin-left: 0; +} +.post-actions-main { + display: flex; + align-items: center; + gap: 14px; +} +.like-button { + display: inline-flex; + align-items: center; + gap: 6px; + font-size: 10px; + min-height: 31px; + color: var(--ink-muted); + transition: color 0.15s; +} +.like-button:hover:not(:disabled) { + color: #e0245e; +} +.like-button.liked { + color: #e0245e; + font-weight: 700; +} +.like-button.liked svg { + animation: like-pop 0.3s ease-out; +} +.like-button:disabled { + opacity: 0.75; +} +.like-small { + min-height: 26px; + font-size: 10px; + gap: 4px; +} +@keyframes like-pop { + 50% { + transform: scale(1.3); + } +} +.comments { + border-top: 1px solid color-mix(in srgb, var(--line) 15%, transparent); + padding-top: 10px; +} +.comments > .text-button { + margin-bottom: 6px; +} +.comments ul { + list-style: none; + margin: 0; + padding: 0; + display: grid; + gap: 10px; +} +.comment { + display: flex; + gap: 9px; + align-items: flex-start; +} +.comment-body { + min-width: 0; + flex: 1; +} +.comment-bubble { + background: color-mix(in srgb, var(--ink) 4.5%, transparent); + border-radius: 12px; + padding: 8px 12px; + display: inline-block; + max-width: 100%; +} +.comment-head { + display: flex; + gap: 8px; + align-items: baseline; + font-size: 11px; +} +.comment-head a { + font-weight: 750; +} +.comment-head a:hover { + text-decoration: underline; +} +.comment-head time { + color: var(--ink-muted); + font-size: 9px; +} +.comment-text { + white-space: pre-wrap; + overflow-wrap: anywhere; + font-size: 12px; + line-height: 1.5; + margin-top: 2px; +} +.comment-text.muted { + color: var(--ink-muted); + font-style: italic; +} +.comment-image { + margin-top: 6px; + max-width: 220px; + border-radius: 6px; + display: block; +} +.comment-actions { + display: flex; + align-items: center; + gap: 4px; + padding-left: 6px; +} +.comment-actions .icon-action { + min-width: 26px; + min-height: 26px; +} +.comment-form { + display: flex; + align-items: flex-end; + gap: 6px; + margin-top: 12px; +} +.comment-form textarea { + flex: 1; + min-width: 0; + resize: none; + border: 1px solid color-mix(in srgb, var(--line) 35%, transparent); + border-radius: 18px; + padding: 7px 14px; + font-size: 12px; + line-height: 1.45; + background: var(--surface); + color: var(--ink); + max-height: 160px; +} +.comment-form textarea:focus { + outline: 2px solid var(--focus, var(--blue)); + outline-offset: 1px; +} +.liker-list { + list-style: none; + padding: 0; + margin: 0; + display: grid; + gap: 6px; + max-height: 50vh; + overflow: auto; +} +.liker-list a { + display: flex; + align-items: center; + gap: 10px; + padding: 6px; + border-radius: 6px; + font-size: 13px; +} +.liker-list a:hover { + background: color-mix(in srgb, var(--ink) 5%, transparent); +} +.liker-list span { + color: var(--ink-muted); + font-size: 11px; +} +.post-permalink:hover { + text-decoration: underline; +} +.post-detail { + max-width: 720px; + margin: 0 auto; + display: grid; + gap: 14px; +} +.profile-stats { + display: flex; + gap: 18px; + justify-content: center; + font-size: 12px; + color: var(--ink-muted); + margin: 6px 0 4px; +} +.profile-stats strong { + color: var(--ink); + font-size: 15px; + margin-right: 4px; +} +.voice-editor { + border-top: 1px solid color-mix(in srgb, var(--line) 15%, transparent); + padding-top: 18px; + margin-top: 18px; + display: grid; + gap: 10px; +} +.composer-preview { + margin-top: 6px; +} +@media (max-width: 760px) { + .action-label { + display: none; + } + .post-actions-main { + gap: 10px; + } + .link-card-image { + flex-basis: 96px; + } + .media-cover { + flex-basis: 112px; + min-height: 112px; + } + .media-youtube { + flex-direction: column; + } + .media-youtube .media-cover { + flex-basis: auto; + width: 100%; + } +} diff --git a/app/app/p/[id]/page.tsx b/app/app/p/[id]/page.tsx new file mode 100644 index 0000000..a8c4f63 --- /dev/null +++ b/app/app/p/[id]/page.tsx @@ -0,0 +1,12 @@ +import type { Metadata } from "next"; +import { PostDetail } from "@/components/post-detail"; +type Props = { params: Promise<{ id: string }> }; +export const metadata: Metadata = { + title: "Beitrag", + // Beiträge sind nur für Mitglieder sichtbar; Suchmaschinen sehen hier nichts. + robots: { index: false }, +}; +export default async function Page({ params }: Props) { + const { id } = await params; + return ; +} diff --git a/app/app/u/[username]/page.tsx b/app/app/u/[username]/page.tsx index 6734e6e..03f343e 100644 --- a/app/app/u/[username]/page.tsx +++ b/app/app/u/[username]/page.tsx @@ -1,11 +1,19 @@ import type { Metadata } from "next"; import { ProfilePage } from "@/components/profile"; +import { loadPublicProfile } from "@/lib/public-profile"; type Props = { params: Promise<{ username: string }> }; export async function generateMetadata({ params }: Props): Promise { const { username } = await params; - return { title: `@${username}` }; + const person = await loadPublicProfile(username); + if (!person) return { title: `@${username}`, robots: { index: false } }; + return { + title: `${person.display_name} (@${person.username})`, + description: + person.bio || `${person.display_name} ist Mitglied bei Humans Only.`, + }; } export default async function Page({ params }: Props) { const { username } = await params; - return ; + const publicProfile = await loadPublicProfile(username); + return ; } diff --git a/app/components/composer.tsx b/app/components/composer.tsx index 1f8f710..73436eb 100644 --- a/app/components/composer.tsx +++ b/app/components/composer.tsx @@ -1,9 +1,11 @@ "use client"; -import { useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { ImagePlus, Mic, Send, Type, X } from "lucide-react"; import { Modal } from "./ui"; import { VoiceRecorder, type Recording } from "./voice-recorder"; import { useClub } from "./provider"; +import { LinkPreviewCard } from "./link-preview"; +import { firstUrl } from "@/lib/links"; export function Composer({ open, onOpenChange, @@ -24,6 +26,12 @@ export function Composer({ const [recordingBusy, setRecordingBusy] = useState(false); const [error, setError] = useState(""); const file = useRef(null); + // Vorschau erst, wenn kurz nicht mehr getippt wird (nicht bei jedem Tastendruck). + const [previewUrl, setPreviewUrl] = useState(null); + useEffect(() => { + const timer = setTimeout(() => setPreviewUrl(firstUrl(text)), 700); + return () => clearTimeout(timer); + }, [text]); async function submit(event: React.FormEvent) { event.preventDefault(); setBusy(true); @@ -108,6 +116,11 @@ export function Composer({ rows={5} />
{text.length} / 2.000
+ {previewUrl && !image && ( +
+ +
+ )} {kind === "image" && (
diff --git a/app/components/link-preview.tsx b/app/components/link-preview.tsx new file mode 100644 index 0000000..13810cb --- /dev/null +++ b/app/components/link-preview.tsx @@ -0,0 +1,128 @@ +"use client"; +import { useEffect, useState } from "react"; +import { ExternalLink, Play } from "lucide-react"; +import { detectEmbed, displayUrl, type LinkPreview } from "@/lib/links"; + +const cache = new Map>(); +function load(url: string) { + let hit = cache.get(url); + if (!hit) { + hit = fetch(`/api/link-preview?url=${encodeURIComponent(url)}`) + .then((res) => (res.ok ? res.json() : { preview: null })) + .then((body: { preview: LinkPreview | null }) => body.preview) + .catch(() => null); + cache.set(url, hit); + } + return hit; +} + +/** + * Vorschau-Karte unter einem Beitrag. Spotify und YouTube zeigen ein Cover mit Play-Knopf; + * erst ein Klick lädt den echten Player (Zwei-Klick-Lösung: vorher keine Verbindung dorthin). + */ +export function LinkPreviewCard({ url }: { url: string }) { + const [preview, setPreview] = useState(); + const [playing, setPlaying] = useState(false); + const instant = detectEmbed(url); + useEffect(() => { + let alive = true; + void load(url).then((p) => alive && setPreview(p)); + return () => { + alive = false; + }; + }, [url]); + const embed = preview?.embed || instant; + if (embed && playing) + return ( +
+