Share reward and less robot load on shared links
The first visit of a shared link by someone else earns the sharer one free natal analysis, once per user. The share page reports visits from the visitor's browser; robots, the logged-in sharer and the address the link was made at do not count. The share button is a proper card that says so in small print; /v1/me tells whether the reward is used up. Robots: reading a share writes nothing (view_count counts people only), the frontend keeps shared content for five minutes (cleared when a link is revoked), and robots.txt turns away the known AI crawlers while leaving the link preview robots alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
// Forwards /api/v1/* to the backend, so the browser talks to one origin and
|
||||
// the session cookie belongs to the frontend's host (no CORS needed).
|
||||
import { revalidateTag } from "next/cache";
|
||||
import type { NextRequest } from "next/server";
|
||||
|
||||
import { BACKEND_URL } from "@/lib/server";
|
||||
import { SHARES_TAG } from "@/lib/share";
|
||||
|
||||
const REQUEST_HEADERS = ["accept", "accept-language", "authorization", "content-type", "cookie", "user-agent"];
|
||||
// Hop-by-hop or re-computed by the runtime.
|
||||
@@ -38,6 +40,8 @@ async function forward(req: NextRequest, ctx: { params: Promise<{ path: string[]
|
||||
if (!SKIP_RESPONSE_HEADERS.has(name)) out.set(name, value);
|
||||
});
|
||||
for (const cookie of res.headers.getSetCookie()) out.append("set-cookie", cookie);
|
||||
// A revoked link must disappear at once from the cached share pages.
|
||||
if (req.method === "DELETE" && path[0] === "shares" && res.ok) revalidateTag(SHARES_TAG, { expire: 0 });
|
||||
return new Response(res.body, { status: res.status, headers: out });
|
||||
}
|
||||
|
||||
|
||||
@@ -697,7 +697,23 @@ a.pair-row:hover strong { color: var(--gold); }
|
||||
}
|
||||
|
||||
/* Sharing a chart (summary card) and the public share page */
|
||||
.share { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
|
||||
.share { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
|
||||
.share-button {
|
||||
display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 16px; text-align: left; cursor: pointer;
|
||||
border: 1px solid rgba(217, 180, 106, 0.55); border-radius: 12px; color: var(--ink); font: inherit;
|
||||
background: linear-gradient(135deg, rgba(217, 180, 106, 0.14), rgba(217, 180, 106, 0.03));
|
||||
transition: border-color 0.15s, background 0.15s;
|
||||
}
|
||||
.share-button:hover { border-color: var(--gold); background: linear-gradient(135deg, rgba(217, 180, 106, 0.22), rgba(217, 180, 106, 0.06)); }
|
||||
.share-button:disabled { opacity: 0.7; cursor: default; }
|
||||
.share-icon {
|
||||
flex: none; width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
|
||||
background: var(--gold); color: var(--gold-ink);
|
||||
}
|
||||
.share-button-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
|
||||
.share-button-text strong { font-family: var(--font-display); font-size: 21px; font-weight: 600; line-height: 1.15; }
|
||||
.share-button-text small { font-size: 12.5px; color: var(--gold); }
|
||||
.share-fine { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
|
||||
.share-open { align-items: stretch; padding: 14px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--panel-2); }
|
||||
.share-link { display: flex; gap: 8px; }
|
||||
.share-link .inp { min-height: 36px; font-size: 14px; }
|
||||
|
||||
@@ -77,6 +77,7 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
|
||||
initial={summary}
|
||||
detailedDone={detailed?.status === "done"}
|
||||
isAdmin={me.user.roles.includes("admin")}
|
||||
shareRewardGranted={me.share_reward_granted}
|
||||
/>
|
||||
<BigThree chart={chart} />
|
||||
{(elements || modalities || phase) && (
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import type { MetadataRoute } from "next";
|
||||
|
||||
// AI crawlers that train models or answer from the site: they load pages
|
||||
// far more often than visitors do. Link preview robots (Facebook, Messenger,
|
||||
// Slack, WhatsApp, X, LinkedIn) stay allowed, they make the shared links work.
|
||||
const AI_CRAWLERS = [
|
||||
"GPTBot",
|
||||
"ChatGPT-User",
|
||||
"OAI-SearchBot",
|
||||
"ClaudeBot",
|
||||
"Claude-User",
|
||||
"Claude-SearchBot",
|
||||
"anthropic-ai",
|
||||
"CCBot",
|
||||
"Google-Extended",
|
||||
"GoogleOther",
|
||||
"Applebot-Extended",
|
||||
"PerplexityBot",
|
||||
"Perplexity-User",
|
||||
"Bytespider",
|
||||
"Amazonbot",
|
||||
"meta-externalagent",
|
||||
"meta-externalfetcher",
|
||||
"FacebookBot",
|
||||
"cohere-ai",
|
||||
"cohere-training-data-crawler",
|
||||
"Diffbot",
|
||||
"ImagesiftBot",
|
||||
"Omgilibot",
|
||||
"Omgili",
|
||||
"YouBot",
|
||||
"Timpibot",
|
||||
"AI2Bot",
|
||||
"Ai2Bot-Dolma",
|
||||
"DuckAssistBot",
|
||||
"MistralAI-User",
|
||||
"PetalBot",
|
||||
"Scrapy",
|
||||
];
|
||||
|
||||
export default function robots(): MetadataRoute.Robots {
|
||||
return {
|
||||
rules: [
|
||||
{ userAgent: AI_CRAWLERS, disallow: "/" },
|
||||
// Logged-in pages redirect anyway; shared links carry noindex.
|
||||
{ userAgent: "*", allow: "/", disallow: ["/api/", "/admin", "/profil", "/kepletek", "/osszevetesek", "/szemelyek"] },
|
||||
],
|
||||
};
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { notFound } from "next/navigation";
|
||||
|
||||
import { ChartWheel, WheelLegend } from "@/components/ChartWheel";
|
||||
import { Rich } from "@/components/Rich";
|
||||
import { ShareVisit } from "@/components/ShareVisit";
|
||||
import { Logo } from "@/components/SiteHeader";
|
||||
import { SIGNS, signName } from "@/lib/astro";
|
||||
import { getMe } from "@/lib/server";
|
||||
@@ -45,6 +46,7 @@ export default async function SharedChartPage({ params }: Props) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<ShareVisit slug={slug} />
|
||||
{!me && (
|
||||
<header className="site-header">
|
||||
<Logo />
|
||||
|
||||
Reference in New Issue
Block a user