Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function Footer() {
</div>
</div>
<div className="mt-10 flex flex-col gap-4 border-t border-border/40 pt-6 text-xs text-muted-foreground md:flex-row md:items-start md:justify-between">
<span>© {new Date().getFullYear()} CodeForge.</span>
<span>CodeForge © {new Date().getFullYear()} — All Rights Reserved.</span>
<span>Built with React, TypeScript, Tailwind CSS & TanStack.</span>
</div>
</div>
Expand Down
35 changes: 35 additions & 0 deletions src/components/PrivacyBlur.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div
className={hidden ? "privacy-blur-active" : undefined}
aria-hidden={hidden ? "true" : undefined}
>
{children}
</div>
);
}
28 changes: 28 additions & 0 deletions src/components/PrivacyNotice.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div
role="note"
aria-label="Privacy and copyright notice"
className="border-b border-violet/20 bg-violet/5 px-4 py-2 text-center text-xs text-muted-foreground"
>
<span className="inline-flex items-center gap-1.5">
<ShieldAlert className="h-3.5 w-3.5 text-violet" aria-hidden="true" />
Privacy &amp; Copyright Protection Enabled — content on this site is protected and
unauthorized reproduction or redistribution is prohibited. See our{" "}
<a href="/terms" className="text-violet underline underline-offset-2">
Terms &amp; Conditions
</a>
.
</span>
</div>
);
}
60 changes: 60 additions & 0 deletions src/components/ProtectedImage.tsx
Original file line number Diff line number Diff line change
@@ -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<HTMLImageElement> & {
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 (
<div className={`protected-image relative overflow-hidden ${containerClassName ?? ""}`}>
<img
{...imgProps}
alt={alt}
draggable={draggable ?? false}
onContextMenu={(event) => {
event.preventDefault();
onContextMenu?.(event);
}}
onDragStart={(event) => {
event.preventDefault();
onDragStart?.(event);
}}
className={className}
/>
<span
aria-hidden="true"
className="protected-image-watermark pointer-events-none absolute inset-0 flex select-none items-end justify-end p-2 text-[11px] font-medium tracking-wide text-white/70"
>
{watermarkText}
</span>
</div>
);
}
8 changes: 3 additions & 5 deletions src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -124,11 +125,8 @@ function RootShell({ children }: { children: ReactNode }) {
<head>
<HeadContent />
</head>
<body
onContextMenu={(event) => event.preventDefault()}
onCopy={(event) => event.preventDefault()}
onCut={(event) => event.preventDefault()}
>
<body>
<PrivacyNotice />
{children}
<Scripts />
</body>
Expand Down
4 changes: 3 additions & 1 deletion src/routes/_authenticated/admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
Expand Down
4 changes: 3 additions & 1 deletion src/routes/_authenticated/dashboard.edit.$id.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down
4 changes: 3 additions & 1 deletion src/routes/_authenticated/dashboard.new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down
4 changes: 3 additions & 1 deletion src/routes/_authenticated/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down
7 changes: 6 additions & 1 deletion src/routes/_authenticated/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
registerCurrentAdminSession,
touchCurrentAdminSession,
} from "@/lib/admin-sessions";
import { PrivacyBlur } from "@/components/PrivacyBlur";

export const Route = createFileRoute("/_authenticated")({
ssr: false,
Expand Down Expand Up @@ -84,5 +85,9 @@ function AuthenticatedLayout() {
};
}, [navigate]);

return <Outlet />;
return (
<PrivacyBlur>
<Outlet />
</PrivacyBlur>
);
}
11 changes: 11 additions & 0 deletions src/routes/blogs_.$slug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -278,6 +279,16 @@ const post = useQuery({
<table>{children}</table>
</div>
),
img: ({ src, alt }) =>
typeof src === "string" ? (
<ProtectedImage
src={src}
alt={alt ?? ""}
containerClassName="my-4 rounded-xl"
className="rounded-xl"
loading="lazy"
/>
) : null,
}}
>
{p.content}
Expand Down
17 changes: 12 additions & 5 deletions src/routes/terms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -56,10 +56,17 @@ function TermsPage() {
<section>
<h2 className="text-base font-semibold text-foreground">3. Intellectual property</h2>
<p className="mt-2">
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.
</p>
<p className="mt-2">
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.
</p>
</section>

Expand Down
40 changes: 40 additions & 0 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
28 changes: 28 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" }]
}
]
}
Loading