From 5d844d44beab68c19ec0cf7fe5d9e1594b64d751 Mon Sep 17 00:00:00 2001 From: Simak Ahmed Date: Sat, 26 Sep 2026 17:44:46 +0000 Subject: [PATCH] feat: implement privacy and copyright protection mode --- src/components/Footer.tsx | 2 +- src/components/PrivacyBlur.tsx | 35 +++++++++++ src/components/PrivacyNotice.tsx | 28 +++++++++ src/components/ProtectedImage.tsx | 60 +++++++++++++++++++ src/routes/__root.tsx | 8 +-- src/routes/_authenticated/admin.tsx | 4 +- .../_authenticated/dashboard.edit.$id.tsx | 4 +- src/routes/_authenticated/dashboard.new.tsx | 4 +- src/routes/_authenticated/dashboard.tsx | 4 +- src/routes/_authenticated/route.tsx | 7 ++- src/routes/blogs_.$slug.tsx | 11 ++++ src/routes/terms.tsx | 17 ++++-- src/styles.css | 40 +++++++++++++ vercel.json | 28 +++++++++ 14 files changed, 236 insertions(+), 16 deletions(-) create mode 100644 src/components/PrivacyBlur.tsx create mode 100644 src/components/PrivacyNotice.tsx create mode 100644 src/components/ProtectedImage.tsx diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index d31875d..7696f3e 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -84,7 +84,7 @@ export function Footer() {
- © {new Date().getFullYear()} CodeForge. + CodeForge © {new Date().getFullYear()} — All Rights Reserved. Built with React, TypeScript, Tailwind CSS & TanStack.
diff --git a/src/components/PrivacyBlur.tsx b/src/components/PrivacyBlur.tsx new file mode 100644 index 0000000..a57e0f5 --- /dev/null +++ b/src/components/PrivacyBlur.tsx @@ -0,0 +1,35 @@ +import { useEffect, useState, type ReactNode } from "react"; + +/** + * PrivacyBlur + * + * Blurs its children when the browser tab is hidden or loses visibility + * (tab switch, minimize, app switch), and restores them when the tab + * becomes visible again. + * + * This is a privacy convenience for inactive tabs — e.g. keeping an + * admin panel from being visible in a screen-share or over someone's + * shoulder while you're on another tab. It is NOT screenshot detection + * and cannot be, since the Page Visibility API only fires on tab/window + * focus changes, not on OS-level or external capture. + */ +export function PrivacyBlur({ children }: { children: ReactNode }) { + const [hidden, setHidden] = useState(false); + + useEffect(() => { + const handleVisibilityChange = () => { + setHidden(document.visibilityState === "hidden"); + }; + document.addEventListener("visibilitychange", handleVisibilityChange); + return () => document.removeEventListener("visibilitychange", handleVisibilityChange); + }, []); + + return ( +
+ {children} +
+ ); +} diff --git a/src/components/PrivacyNotice.tsx b/src/components/PrivacyNotice.tsx new file mode 100644 index 0000000..455db2e --- /dev/null +++ b/src/components/PrivacyNotice.tsx @@ -0,0 +1,28 @@ +import { ShieldAlert } from "lucide-react"; + +/** + * Site-wide privacy & copyright notice. + * + * Intentionally honest about what this is: a legal/deterrence notice, + * not a technical guarantee. It must never claim screenshots are + * blocked or that every capture attempt is detected. + */ +export function PrivacyNotice() { + return ( +
+ + +
+ ); +} diff --git a/src/components/ProtectedImage.tsx b/src/components/ProtectedImage.tsx new file mode 100644 index 0000000..0a8ac0f --- /dev/null +++ b/src/components/ProtectedImage.tsx @@ -0,0 +1,60 @@ +import { type ImgHTMLAttributes } from "react"; + +/** + * ProtectedImage + * + * Wraps a portfolio/blog image with: + * - a subtle, accessible copyright watermark + * - right-click and drag deterrence scoped to THIS image only + * + * This is a deterrence layer, not a security control. It does not and + * cannot prevent screenshots, OS-level capture, or a determined user + * with dev tools open. See PrivacyNotice.tsx for the user-facing copy + * that describes this honestly. + * + * Deliberately NOT applied globally — normal site text, code blocks, + * and form fields remain selectable and copyable as usual. + */ +type ProtectedImageProps = ImgHTMLAttributes & { + watermarkText?: string; + className?: string; + containerClassName?: string; +}; + +const DEFAULT_WATERMARK = "CodeForge © 2026 — All Rights Reserved"; + +export function ProtectedImage({ + watermarkText = DEFAULT_WATERMARK, + className, + containerClassName, + draggable, + onContextMenu, + onDragStart, + alt, + ...imgProps +}: ProtectedImageProps) { + return ( +
+ {alt} { + event.preventDefault(); + onContextMenu?.(event); + }} + onDragStart={(event) => { + event.preventDefault(); + onDragStart?.(event); + }} + className={className} + /> + +
+ ); +} diff --git a/src/routes/__root.tsx b/src/routes/__root.tsx index 7dd1f5c..1af1c6e 100644 --- a/src/routes/__root.tsx +++ b/src/routes/__root.tsx @@ -13,6 +13,7 @@ import appCss from "../styles.css?url"; import { AuthProvider } from "@/hooks/use-auth"; import { Toaster } from "@/components/ui/sonner"; import { EditModeProvider } from "@/contexts/EditModeContext"; +import { PrivacyNotice } from "@/components/PrivacyNotice"; function NotFoundComponent() { return ( @@ -124,11 +125,8 @@ function RootShell({ children }: { children: ReactNode }) { - event.preventDefault()} - onCopy={(event) => event.preventDefault()} - onCut={(event) => event.preventDefault()} - > + + {children} diff --git a/src/routes/_authenticated/admin.tsx b/src/routes/_authenticated/admin.tsx index 2b28c54..4f34f09 100644 --- a/src/routes/_authenticated/admin.tsx +++ b/src/routes/_authenticated/admin.tsx @@ -46,7 +46,9 @@ import { useAuth } from "@/hooks/use-auth"; import { toast } from "sonner"; export const Route = createFileRoute("/_authenticated/admin")({ - head: () => ({ meta: [{ title: "Admin — CodeForge" }] }), + head: () => ({ + meta: [{ title: "Admin — CodeForge" }, { name: "robots", content: "noindex, nofollow" }], + }), beforeLoad: async () => { const { data: u } = await supabase.auth.getUser(); if (!u.user) throw redirect({ to: "/auth" }); diff --git a/src/routes/_authenticated/dashboard.edit.$id.tsx b/src/routes/_authenticated/dashboard.edit.$id.tsx index 7719293..714c9e3 100644 --- a/src/routes/_authenticated/dashboard.edit.$id.tsx +++ b/src/routes/_authenticated/dashboard.edit.$id.tsx @@ -7,7 +7,9 @@ import { PostEditor, type PostDraft } from "@/components/PostEditor"; import { supabase } from "@/integrations/supabase/client"; export const Route = createFileRoute("/_authenticated/dashboard/edit/$id")({ - head: () => ({ meta: [{ title: "Edit post — CodeForge" }] }), + head: () => ({ + meta: [{ title: "Edit post — CodeForge" }, { name: "robots", content: "noindex, nofollow" }], + }), component: EditPost, }); diff --git a/src/routes/_authenticated/dashboard.new.tsx b/src/routes/_authenticated/dashboard.new.tsx index 41d71be..bc2beb2 100644 --- a/src/routes/_authenticated/dashboard.new.tsx +++ b/src/routes/_authenticated/dashboard.new.tsx @@ -4,7 +4,9 @@ import { SiteLayout } from "@/components/SiteLayout"; import { PostEditor } from "@/components/PostEditor"; export const Route = createFileRoute("/_authenticated/dashboard/new")({ - head: () => ({ meta: [{ title: "New post — CodeForge" }] }), + head: () => ({ + meta: [{ title: "New post — CodeForge" }, { name: "robots", content: "noindex, nofollow" }], + }), component: NewPost, }); diff --git a/src/routes/_authenticated/dashboard.tsx b/src/routes/_authenticated/dashboard.tsx index 0c3b811..59919c4 100644 --- a/src/routes/_authenticated/dashboard.tsx +++ b/src/routes/_authenticated/dashboard.tsx @@ -15,7 +15,9 @@ import { toast } from "sonner"; import { SecurityTab } from "@/components/SecurityTab"; export const Route = createFileRoute("/_authenticated/dashboard")({ - head: () => ({ meta: [{ title: "Dashboard — CodeForge" }] }), + head: () => ({ + meta: [{ title: "Dashboard — CodeForge" }, { name: "robots", content: "noindex, nofollow" }], + }), component: Dashboard, }); diff --git a/src/routes/_authenticated/route.tsx b/src/routes/_authenticated/route.tsx index 5357f80..6d1cc71 100644 --- a/src/routes/_authenticated/route.tsx +++ b/src/routes/_authenticated/route.tsx @@ -22,6 +22,7 @@ import { registerCurrentAdminSession, touchCurrentAdminSession, } from "@/lib/admin-sessions"; +import { PrivacyBlur } from "@/components/PrivacyBlur"; export const Route = createFileRoute("/_authenticated")({ ssr: false, @@ -84,5 +85,9 @@ function AuthenticatedLayout() { }; }, [navigate]); - return ; + return ( + + + + ); } diff --git a/src/routes/blogs_.$slug.tsx b/src/routes/blogs_.$slug.tsx index 32cf4ba..9ae753e 100644 --- a/src/routes/blogs_.$slug.tsx +++ b/src/routes/blogs_.$slug.tsx @@ -12,6 +12,7 @@ import { Textarea } from "@/components/ui/textarea"; import { toast } from "sonner"; import { TurnstileWidget } from "@/components/TurnstileWidget"; import { submitGuestComment } from "@/lib/comment.functions"; +import { ProtectedImage } from "@/components/ProtectedImage"; function toSafeJsonLd(value: unknown): string { return JSON.stringify(value) @@ -278,6 +279,16 @@ const post = useQuery({ {children}
), + img: ({ src, alt }) => + typeof src === "string" ? ( + + ) : null, }} > {p.content} diff --git a/src/routes/terms.tsx b/src/routes/terms.tsx index 457a939..088b848 100644 --- a/src/routes/terms.tsx +++ b/src/routes/terms.tsx @@ -24,7 +24,7 @@ export const Route = createFileRoute("/terms")({ component: TermsPage, }); -const LAST_UPDATED = "September 14, 2026"; +const LAST_UPDATED = "September 26, 2026"; function TermsPage() { return ( @@ -56,10 +56,17 @@ function TermsPage() {

3. Intellectual property

- Unless otherwise noted, the design, branding, and written content on CodeForge belong - to the site owner. Open-source project code is governed by the license published in - that project's own repository. Please don't reproduce written content from this site - without permission or attribution. + Unless otherwise noted, the design, branding, written content, images, and watermarked + assets on CodeForge belong to the site owner. Open-source project code is governed by + the license published in that project's own repository. +

+

+ You may view and share links to this content for personal, non-commercial use. + Reproducing, copying, screenshotting, redistributing, republishing, or using this + site's content — including images, articles, and project write-ups — for commercial + purposes or without permission or attribution is not allowed. Some pages on this site + display a privacy and copyright notice and visible watermarking as a reminder of these + terms; their absence on any given page does not waive these rights.

diff --git a/src/styles.css b/src/styles.css index 4fe8077..50d2299 100644 --- a/src/styles.css +++ b/src/styles.css @@ -338,3 +338,43 @@ svg { .prose-content tr:last-child td { border-bottom: 0; } + +/* ------------------------------------------------------------------ */ +/* Privacy & Copyright Protection Mode */ +/* Deterrence + legal-notice styling only — not access control. */ +/* ------------------------------------------------------------------ */ + +/* Watermark overlay text on protected images. Text-shadow (rather than + relying on opacity alone) keeps it legible over both light and dark + image content without needing per-image contrast tuning. */ +.protected-image-watermark { + text-shadow: + 0 1px 2px rgba(0, 0, 0, 0.85), + 0 0 6px rgba(0, 0, 0, 0.5); +} + +/* Visibility-based privacy blur, applied only inside the authenticated + admin/dashboard layout (see PrivacyBlur.tsx). Restores instantly when + the tab becomes visible again. This does not detect or prevent + screenshots — it only reacts to the tab losing browser focus. */ +.privacy-blur-active { + filter: blur(16px); + transition: filter 0.15s ease; + pointer-events: none; + user-select: none; +} + +/* Print handling: keep the watermark and copyright notice visible in + printed/PDF output rather than letting print stylesheets silently + drop them, and never print a mid-blur frozen state. */ +@media print { + .privacy-blur-active { + filter: none; + } + + .protected-image-watermark { + opacity: 1 !important; + color: rgba(0, 0, 0, 0.55) !important; + text-shadow: none; + } +} diff --git a/vercel.json b/vercel.json index f05bdac..80f4fe8 100644 --- a/vercel.json +++ b/vercel.json @@ -29,6 +29,34 @@ "value": "max-age=31536000; includeSubDomains" } ] + }, + { + "source": "/admin", + "headers": [{ "key": "Cache-Control", "value": "no-store" }] + }, + { + "source": "/admin/(.*)", + "headers": [{ "key": "Cache-Control", "value": "no-store" }] + }, + { + "source": "/dashboard", + "headers": [{ "key": "Cache-Control", "value": "no-store" }] + }, + { + "source": "/dashboard/(.*)", + "headers": [{ "key": "Cache-Control", "value": "no-store" }] + }, + { + "source": "/auth", + "headers": [{ "key": "Cache-Control", "value": "no-store" }] + }, + { + "source": "/mfa-setup", + "headers": [{ "key": "Cache-Control", "value": "no-store" }] + }, + { + "source": "/mfa-verify", + "headers": [{ "key": "Cache-Control", "value": "no-store" }] } ] }