Merge pull request 'Give /kit and /press their own pages, and hold /privacy until counsel' (#111) from adilallo/feature/CR-288-kit-press-privacy into main

Reviewed-on: #111
This commit was merged in pull request #111.
This commit is contained in:
an.di committed 2026-11-21 03:00:14 +00:00
commit 2dfc365dbd
56 files changed
+912 -199

No files matched your search

+7 -1
View File
@@ -13,7 +13,13 @@ SESSION_SECRET="dev-only-change-me-16chars-min"
# CLOUDRON_MAIL_SMTP_PASSWORD=
# Leave mail vars unset in dev to log the magic-link verify URL to the server console instead of sending email.
SMTP_FROM="Community Rule <noreply@localhost>"
SMTP_FROM="CommunityRule <noreply@localhost>"
# /privacy. Unset or any value other than `true` is off (404, no footer/login/email links).
# Staging: `true`. Production stays off until university counsel has read the policy.
# Only ENABLE_PRIVACY_POLICY counts. It is read at runtime on Cloudron.
# A build-time NEXT_PUBLIC_ENABLE_PRIVACY_POLICY value does not turn the page on.
# ENABLE_PRIVACY_POLICY=true
# CR-107: inbox for Ask an organizer form submissions (requires CLOUDRON_MAIL_SMTP_* in production).
ORGANIZER_INQUIRY_TO=
+2 -1
View File
@@ -6,6 +6,7 @@ import { MessagesProvider } from "../contexts/MessagesContext";
import { AuthModalProvider } from "../contexts/AuthModalContext";
import messages from "../../messages/en/index";
import { MAIN_CONTENT_ID } from "../../lib/mainContent";
import { isPrivacyPolicyEnabled } from "../../lib/privacyPolicyEnabled";
import { NO_INDEX_ROBOTS } from "../../lib/siteMetadata";
export const metadata: Metadata = {
@@ -21,7 +22,7 @@ export const metadata: Metadata = {
export default function AdminLayout({ children }: { children: ReactNode }) {
return (
<MessagesProvider messages={messages}>
<AuthModalProvider>
<AuthModalProvider privacyEnabled={isPrivacyPolicyEnabled()}>
<SkipToContent />
<Suspense fallback={null}>
<ConditionalNavigation />
+2 -1
View File
@@ -6,6 +6,7 @@ import { MessagesProvider } from "../contexts/MessagesContext";
import { AuthModalProvider } from "../contexts/AuthModalContext";
import messages from "../../messages/en/index";
import { MAIN_CONTENT_ID } from "../../lib/mainContent";
import { isPrivacyPolicyEnabled } from "../../lib/privacyPolicyEnabled";
import { NO_INDEX_ROBOTS } from "../../lib/siteMetadata";
export const metadata: Metadata = {
@@ -28,7 +29,7 @@ export const metadata: Metadata = {
export default function AppLayout({ children }: { children: ReactNode }) {
return (
<MessagesProvider messages={messages}>
<AuthModalProvider>
<AuthModalProvider privacyEnabled={isPrivacyPolicyEnabled()}>
<SkipToContent />
<Suspense fallback={null}>
<ConditionalNavigation />
+72
View File
@@ -0,0 +1,72 @@
"use client";
import { Suspense } from "react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useTranslation } from "../../contexts/MessagesContext";
import Login from "../../components/modals/Login";
import LoginForm from "../../components/modals/Login/LoginForm";
const loginPageBgClass =
"min-h-[100dvh] bg-[var(--color-surface-invert-brand-primary)]";
function LoginLoadingFallback() {
const t = useTranslation("pages.login");
return (
<div className={`${loginPageBgClass} flex items-center justify-center`}>
<p className="text-[14px] text-[var(--color-content-default-primary)]">
{t("loadingFallback")}
</p>
</div>
);
}
function LoginWithSearchParams({
privacyEnabled,
}: {
privacyEnabled: boolean;
}) {
const router = useRouter();
const t = useTranslation("pages.login");
const closeToHome = () => {
router.push("/");
};
return (
<div className={loginPageBgClass}>
<Login
isOpen
usePortal={false}
backdropVariant="solid"
onClose={closeToHome}
ariaLabelledBy="login-modal-heading"
belowCard={
<Link
href="/"
className="text-small-paragraph text-[var(--color-content-invert-tertiary,#2d2d2d)] text-center hover:opacity-90"
>
{t("backToHome")}
</Link>
}
>
<LoginForm privacyEnabled={privacyEnabled} onClose={closeToHome} />
</Login>
</div>
);
}
/**
* Full-page login shell for magic-link **error redirects** (`?error=*`) and direct `/login` visits.
* Header **Log in** uses `AuthModalProvider` instead; this route stays for verify failures and bookmarks.
*/
export default function LoginPageClient({
privacyEnabled,
}: {
privacyEnabled: boolean;
}) {
return (
<Suspense fallback={<LoginLoadingFallback />}>
<LoginWithSearchParams privacyEnabled={privacyEnabled} />
</Suspense>
);
}
+3 -61
View File
@@ -1,64 +1,6 @@
"use client";
import { Suspense } from "react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useTranslation } from "../../contexts/MessagesContext";
import Login from "../../components/modals/Login";
import LoginForm from "../../components/modals/Login/LoginForm";
const loginPageBgClass =
"min-h-[100dvh] bg-[var(--color-surface-invert-brand-primary)]";
function LoginLoadingFallback() {
const t = useTranslation("pages.login");
return (
<div className={`${loginPageBgClass} flex items-center justify-center`}>
<p className="text-[14px] text-[var(--color-content-default-primary)]">
{t("loadingFallback")}
</p>
</div>
);
}
/**
* Full-page login shell for magic-link **error redirects** (`?error=*`) and direct `/login` visits.
* Header **Log in** uses `AuthModalProvider` instead; this route stays for verify failures and bookmarks.
*/
function LoginWithSearchParams() {
const router = useRouter();
const t = useTranslation("pages.login");
const closeToHome = () => {
router.push("/");
};
return (
<div className={loginPageBgClass}>
<Login
isOpen
usePortal={false}
backdropVariant="solid"
onClose={closeToHome}
ariaLabelledBy="login-modal-heading"
belowCard={
<Link
href="/"
className="text-small-paragraph text-[var(--color-content-invert-tertiary,#2d2d2d)] text-center hover:opacity-90"
>
{t("backToHome")}
</Link>
}
>
<LoginForm onClose={closeToHome} />
</Login>
</div>
);
}
import { isPrivacyPolicyEnabled } from "../../../lib/privacyPolicyEnabled";
import LoginPageClient from "./LoginPageClient";
export default function LoginPage() {
return (
<Suspense fallback={<LoginLoadingFallback />}>
<LoginWithSearchParams />
</Suspense>
);
return <LoginPageClient privacyEnabled={isPrivacyPolicyEnabled()} />;
}
+2 -1
View File
@@ -5,6 +5,7 @@ import { MessagesProvider } from "../contexts/MessagesContext";
import { AuthModalProvider } from "../contexts/AuthModalContext";
import messages from "../../messages/en/index";
import { MAIN_CONTENT_ID } from "../../lib/mainContent";
import { isPrivacyPolicyEnabled } from "../../lib/privacyPolicyEnabled";
import { NO_INDEX_ROBOTS } from "../../lib/siteMetadata";
export const metadata: Metadata = {
@@ -18,7 +19,7 @@ export default function DevLayout({ children }: { children: ReactNode }) {
}
return (
<MessagesProvider messages={messages}>
<AuthModalProvider>
<AuthModalProvider privacyEnabled={isPrivacyPolicyEnabled()}>
<main
id={MAIN_CONTENT_ID}
tabIndex={-1}
@@ -8,6 +8,7 @@ import {
} from "../../../lib/legalSyntheticPost";
import { getRequestSiteOrigin } from "../../../lib/requestSiteOrigin";
import { absoluteSiteUrl } from "../../../lib/siteMetadata";
import { isPrivacyPolicyEnabled } from "../../../lib/privacyPolicyEnabled";
import ContentBanner from "../../components/sections/ContentBanner";
type LegalDocumentPageProps = {
@@ -45,7 +46,9 @@ function LegalInlineText({ text }: { text: string }) {
const label = match[1];
const href = match[2];
if (isSafeHref(href)) {
if (href === "/privacy" && !isPrivacyPolicyEnabled()) {
nodes.push(label);
} else if (isSafeHref(href)) {
const isInternal = href.startsWith("/") && !href.startsWith("//");
nodes.push(
isInternal ? (
@@ -91,7 +94,7 @@ export function legalPageMetadata(
}
/**
* Public legal documents (`/privacy`, `/terms`, `/cookies`).
* Public Content page Template documents (`/privacy`, `/terms`, `/cookies`, `/kit`, `/press`).
*
* Figma: "Content page Template" (19003:23305) — ContentBanner guide
* (22078:806964) + article column (19003:23574). Body stacks follow
+25 -4
View File
@@ -1,6 +1,27 @@
import { redirect } from "next/navigation";
/**
* Figma: "C8 Kit page / 1440+" (25218:120616) on "Content page Template" (19003:23305)
* https://www.figma.com/design/agv0VBLiBlcnSAaiAORgPR/Community-Rule-System?node-id=25218-120616
*/
import type { Metadata } from "next";
import messages from "../../../messages/en/index";
import { legalPathForSlug } from "../../../lib/legalSyntheticPost";
import { routeMetadata } from "../../../lib/siteMetadata";
import LegalDocumentPage, {
legalPageMetadata,
} from "../_components/LegalDocumentPage";
/** Office-hours pointer used in the 48-hour follow-up email. */
export default function KitPage() {
redirect("/workshops");
const SLUG = "kit" as const;
const PATH = legalPathForSlug(SLUG);
export function generateMetadata(): Metadata {
return routeMetadata(
PATH,
legalPageMetadata(messages.metadata.kit, messages.pages.kit),
);
}
export default function KitPage() {
return (
<LegalDocumentPage slug={SLUG} path={PATH} page={messages.pages.kit} />
);
}
+2 -1
View File
@@ -5,12 +5,13 @@ import SkipToContent from "../components/navigation/SkipToContent";
import { MessagesProvider } from "../contexts/MessagesContext";
import { AuthModalProvider } from "../contexts/AuthModalContext";
import { MAIN_CONTENT_ID } from "../../lib/mainContent";
import { isPrivacyPolicyEnabled } from "../../lib/privacyPolicyEnabled";
import marketingMessages from "../../messages/en/marketing";
export default function MarketingLayout({ children }: { children: ReactNode }) {
return (
<MessagesProvider messages={marketingMessages}>
<AuthModalProvider>
<AuthModalProvider privacyEnabled={isPrivacyPolicyEnabled()}>
{/*
* Same session-aware shell as `(app)` / `(admin)`: `ConditionalNavigation`
* reads the cookie behind Suspense so the static page shell can prerender
+30
View File
@@ -0,0 +1,30 @@
/**
* Figma: "Press / Breakpoint=1024+, State=Embargoed" (24810:39764)
* https://www.figma.com/design/agv0VBLiBlcnSAaiAORgPR/Community-Rule-System?node-id=24810-39764
*
* Holds the press kit on the Content page Template until the embargo lifts.
* Live Figma (24810:39765) adds the release, screenshots and Boulder count.
*/
import type { Metadata } from "next";
import messages from "../../../messages/en/index";
import { legalPathForSlug } from "../../../lib/legalSyntheticPost";
import { routeMetadata } from "../../../lib/siteMetadata";
import LegalDocumentPage, {
legalPageMetadata,
} from "../_components/LegalDocumentPage";
const SLUG = "press" as const;
const PATH = legalPathForSlug(SLUG);
export function generateMetadata(): Metadata {
return routeMetadata(
PATH,
legalPageMetadata(messages.metadata.press, messages.pages.press),
);
}
export default function PressPage() {
return (
<LegalDocumentPage slug={SLUG} path={PATH} page={messages.pages.press} />
);
}
+4
View File
@@ -3,8 +3,10 @@
* https://www.figma.com/design/agv0VBLiBlcnSAaiAORgPR/Community-Rule-System?node-id=19003-23305
*/
import type { Metadata } from "next";
import { notFound } from "next/navigation";
import messages from "../../../messages/en/index";
import { legalPathForSlug } from "../../../lib/legalSyntheticPost";
import { isPrivacyPolicyEnabled } from "../../../lib/privacyPolicyEnabled";
import { routeMetadata } from "../../../lib/siteMetadata";
import LegalDocumentPage, {
legalPageMetadata,
@@ -14,6 +16,7 @@ const SLUG = "privacy" as const;
const PATH = legalPathForSlug(SLUG);
export function generateMetadata(): Metadata {
if (!isPrivacyPolicyEnabled()) notFound();
return routeMetadata(
PATH,
legalPageMetadata(messages.metadata.privacy, messages.pages.privacy),
@@ -21,6 +24,7 @@ export function generateMetadata(): Metadata {
}
export default function PrivacyPage() {
if (!isPrivacyPolicyEnabled()) notFound();
return (
<LegalDocumentPage
slug={SLUG}
+2 -1
View File
@@ -2,6 +2,7 @@ import type { ReactNode } from "react";
import { MessagesProvider } from "../contexts/MessagesContext";
import { AuthModalProvider } from "../contexts/AuthModalContext";
import { MAIN_CONTENT_ID } from "../../lib/mainContent";
import { isPrivacyPolicyEnabled } from "../../lib/privacyPolicyEnabled";
import marketingMessages from "../../messages/en/marketing";
/** Full-viewport case-study surfaces (completed rule demos) — no marketing footer. */
@@ -12,7 +13,7 @@ export default function MarketingCaseStudyLayout({
}) {
return (
<MessagesProvider messages={marketingMessages}>
<AuthModalProvider>
<AuthModalProvider privacyEnabled={isPrivacyPolicyEnabled()}>
<main
id={MAIN_CONTENT_ID}
tabIndex={-1}
+5 -2
View File
@@ -1,5 +1,8 @@
import { NextRequest, NextResponse } from "next/server";
import { sendOrganizerInquiryNotification } from "../../../lib/server/mail";
import {
resolveMailFrom,
sendOrganizerInquiryNotification,
} from "../../../lib/server/mail";
import { rateLimitKey } from "../../../lib/server/rateLimit";
import {
errorJson,
@@ -66,7 +69,7 @@ export const POST = apiRoute(SCOPE, async (request: NextRequest, _ctx, { request
return serverMisconfigured("ORGANIZER_INQUIRY_TO is not configured");
}
const from = process.env.SMTP_FROM ?? "noreply@localhost";
const from = resolveMailFrom();
try {
await sendOrganizerInquiryNotification({
+1 -1
View File
@@ -120,7 +120,7 @@ export const POST = apiRoute(SCOPE, async (request: NextRequest, _ctx, { request
const verifyUrl = `${origin}/api/user/email-change/verify?token=${encodeURIComponent(token)}`;
try {
await sendEmailChangeEmail(newEmail, verifyUrl);
await sendEmailChangeEmail(newEmail, verifyUrl, origin);
} catch (err) {
logRouteError(SCOPE, requestId, err, { phase: "sendEmailChangeEmail" });
await prisma.emailChangeToken.deleteMany({ where: { userId: user.id } });
+14 -7
View File
@@ -111,6 +111,8 @@ export type LoginFormProps = {
variant?: LoginFormVariant;
/** Overrides URL `next` for `requestMagicLink` (e.g. create-flow exit modal). */
magicLinkNextPath?: string;
/** When false, the login legal line links terms only. */
privacyEnabled?: boolean;
/** `keepRule`: Continue without saving. */
onDismiss?: () => void;
/** Sent-state Close, and the dialog chrome close. */
@@ -120,6 +122,7 @@ export type LoginFormProps = {
export default function LoginForm({
variant = "default",
magicLinkNextPath,
privacyEnabled = false,
onDismiss,
onClose,
}: LoginFormProps) {
@@ -365,13 +368,17 @@ export default function LoginForm({
>
{tFooter("legal.termsOfService")}
</Link>
{t("legalAnd")}
<Link
href={tFooter("legal.privacyPolicyHref")}
className="text-[var(--color-content-default-tertiary)] underline decoration-solid underline-offset-2"
>
{tFooter("legal.privacyPolicy")}
</Link>
{privacyEnabled ? (
<>
{t("legalAnd")}
<Link
href={tFooter("legal.privacyPolicyHref")}
className="text-[var(--color-content-default-tertiary)] underline decoration-solid underline-offset-2"
>
{tFooter("legal.privacyPolicy")}
</Link>
</>
) : null}
{t("legalSuffix")}
</p>
</>
+12 -4
View File
@@ -13,7 +13,13 @@ import { PRODUCTION_SITE_ORIGIN } from "../../../lib/siteMetadata";
* Tiers: smallest viewports (below `md`), `md` through `lg`, `lg` and up.
* Matches `--breakpoint-md: 640px`, `--breakpoint-lg: 1024px` in `app/tailwind.css`.
*/
const Footer = memo(({ siteOrigin = PRODUCTION_SITE_ORIGIN }: { siteOrigin?: string }) => {
const Footer = memo(({
siteOrigin = PRODUCTION_SITE_ORIGIN,
privacyEnabled = false,
}: {
siteOrigin?: string;
privacyEnabled?: boolean;
}) => {
const t = useTranslation("footer");
const tChrome = useTranslation("controlsChrome");
@@ -213,9 +219,11 @@ const Footer = memo(({ siteOrigin = PRODUCTION_SITE_ORIGIN }: { siteOrigin?: str
<Link href={t("takeawayHref")} className={legalLinkClass}>
{t("takeaway")}
</Link>
<Link href={t("legal.privacyPolicyHref")} className={legalLinkClass}>
{t("legal.privacyPolicy")}
</Link>
{privacyEnabled ? (
<Link href={t("legal.privacyPolicyHref")} className={legalLinkClass}>
{t("legal.privacyPolicy")}
</Link>
) : null}
<Link href={t("legal.termsOfServiceHref")} className={legalLinkClass}>
{t("legal.termsOfService")}
</Link>
@@ -1,8 +1,14 @@
import Footer from "./Footer";
import { isPrivacyPolicyEnabled } from "../../../lib/privacyPolicyEnabled";
import { getRequestSiteOrigin } from "../../../lib/requestSiteOrigin";
/** Footer JSON-LD uses the request origin, same host as the page canonical. */
export default async function FooterWithOrigin() {
const siteOrigin = await getRequestSiteOrigin();
return <Footer siteOrigin={siteOrigin} />;
return (
<Footer
siteOrigin={siteOrigin}
privacyEnabled={isPrivacyPolicyEnabled()}
/>
);
}
@@ -43,7 +43,7 @@ function WorkshopHeroView({ className = "" }: { className?: string }) {
{copy.body}
</p>
</div>
<Button href={href} size="small">
<Button href={href} size="small" className="self-start">
{copy.button}
</Button>
<p className="border-t border-[var(--color-border-default-secondary)] pt-6 text-[12px] leading-4 text-[var(--color-content-default-tertiary)]">
+8 -1
View File
@@ -39,7 +39,13 @@ type AuthModalContextValue = {
const AuthModalContext = createContext<AuthModalContextValue | null>(null);
export function AuthModalProvider({ children }: { children: ReactNode }) {
export function AuthModalProvider({
children,
privacyEnabled = false,
}: {
children: ReactNode;
privacyEnabled?: boolean;
}) {
const tLogin = useTranslation("pages.login");
const [open, setOpen] = useState(false);
const [opts, setOpts] = useState<OpenLoginOptions>({});
@@ -93,6 +99,7 @@ export function AuthModalProvider({ children }: { children: ReactNode }) {
<LoginForm
variant={opts.variant ?? "default"}
magicLinkNextPath={opts.nextPath}
privacyEnabled={privacyEnabled}
onDismiss={keepRuleDismiss}
onClose={closeLogin}
/>
+10 -3
View File
@@ -75,8 +75,14 @@ per-app in the manifest and provisioned at install time.
- `SESSION_SECRET` — long random (`openssl rand -hex 32`). Required,
≥ 16 chars. Rotating it logs everyone out.
- `SMTP_FROM` — visible "From:" address on sign-in emails. Cloudron
does not inject this. Use `hello@communityrule.info` (continuity
with the legacy service; SES relay accepts it).
does not inject this. Use `CommunityRule <hello@communityrule.info>`
(continuity with the legacy service; SES relay accepts it). A leftover
`Community Rule` display name is rewritten to one word.
- `ENABLE_PRIVACY_POLICY=true` — turns on `/privacy` at runtime. Staging
keeps this on so counsel can read the page. Leave unset in production
until that review is done (the route 404s and public chrome does not
link to it). Only this runtime name counts. A build-time
`NEXT_PUBLIC_ENABLE_PRIVACY_POLICY` value does not turn the page on.
- `NEXT_PUBLIC_ENABLE_BACKEND_SYNC=true` — turns on Postgres draft
persistence for signed-in users. Required in production.
- `UPLOAD_ROOT` — absolute path to a writable directory on the Cloudron
@@ -444,7 +450,8 @@ production env vars, and verify the vertical slice before apex cutover
```bash
cloudron env set --app staging.communityrule.info \
SESSION_SECRET="$(openssl rand -hex 32)" \
SMTP_FROM="Community Rule <hello@communityrule.info>" \
SMTP_FROM="CommunityRule <hello@communityrule.info>" \
ENABLE_PRIVACY_POLICY=true \
NEXT_PUBLIC_ENABLE_BACKEND_SYNC=true \
UPLOAD_ROOT=/app/data/uploads
```
+3 -2
View File
@@ -246,7 +246,8 @@ persist across image updates unless changed:
| Variable | Purpose |
| -------- | ------- |
| `SESSION_SECRET` | Session cookie signing (≥ 16 chars). Rotating logs everyone out. |
| `SMTP_FROM` | Visible From on sign-in emails (e.g. `Community Rule <hello@communityrule.info>`). |
| `SMTP_FROM` | Visible From on sign-in emails (e.g. `CommunityRule <hello@communityrule.info>`). The app rewrites a leftover `Community Rule` display name to one word. |
| `ENABLE_PRIVACY_POLICY` | `true` on staging so `/privacy` is reachable. Unset in production until counsel has read the policy (404, no public links). |
| `NEXT_PUBLIC_ENABLE_BACKEND_SYNC` | `true` in staging/production — Postgres draft persistence. |
| `UPLOAD_ROOT` | `/app/data/uploads` on Cloudron — required for file uploads. |
| `OPS_PRUNE_TOKEN` | Bearer token for `POST /api/ops/prune`. Unset hides the route. Optional; the daily scheduler runs the prune inside the container without it. |
@@ -283,7 +284,7 @@ That is expected. Recipients still authenticate the visible `From:` (`staging.ap
2. In **Cloudron** → *Domains* → `communityrule.info` → DNS, add those CNAMEs. Cloudron's Namecheap provider publishes them to the registrar. Confirm with `dig +short CNAME <selector>._domainkey.communityrule.info`.
3. Optional but recommended for SPF alignment: add `include:amazonses.com` to the existing TXT SPF, e.g. `v=spf1 include:amazonses.com a:my.medlab.host ~all`. Do not remove `a:my.medlab.host` until you know nothing still sends directly from the box.
4. Leave DMARC at `p=reject` once DKIM verifies in SES; if a provider still quarantines after DKIM is live, inspect that provider's headers before relaxing DMARC.
5. Retest: request a magic link to Gmail **and** a non-Gmail inbox (May First / university). Check spam. Staging From is `Community Rule <staging.app@communityrule.info>`.
5. Retest: request a magic link to Gmail **and** a non-Gmail inbox (May First / university). Check spam. Staging From is `CommunityRule <staging.app@communityrule.info>`.
`SMTP_FROM` should stay the Cloudron mailbox (`staging.app@communityrule.info` on staging, `hello@communityrule.info` on the apex app). The app falls back to `CLOUDRON_MAIL_FROM` if `SMTP_FROM` is unset.
+4 -3
View File
@@ -1,8 +1,8 @@
# Privacy policy facts
Numbers and hosting details the new privacy policy leaves in brackets.
Live `/privacy` stays on the current page until university counsel has
read this text. Do not switch the route on from this file.
Live `/privacy` stays behind `ENABLE_PRIVACY_POLICY` until university
counsel has read this text. Do not switch the route on from this file.
## How long things are kept
@@ -53,6 +53,7 @@ See [`docs/guides/ops-runbook.md`](guides/ops-runbook.md) §9.3.
- `/privacy` can show the new policy only after university counsel has
read it, including the Colorado Open Records Act line, Terms, Cookies,
the legal cards, and CC0 for cards and templates.
the legal cards, and CC0 for cards and templates. Flipping
`ENABLE_PRIVACY_POLICY=true` on production is that switch.
- An email to every account holder before a change to who can read Rules
is after launch. Nothing about who can read Rules changes at launch.
+3 -1
View File
@@ -1,6 +1,6 @@
import type { BlogPost } from "./content";
export type LegalDocumentSlug = "privacy" | "terms" | "cookies";
export type LegalDocumentSlug = "privacy" | "terms" | "cookies" | "kit" | "press";
export type LegalDocumentSection = {
heading: string;
@@ -23,6 +23,8 @@ const PATH_BY_SLUG: Record<LegalDocumentSlug, string> = {
privacy: "/privacy",
terms: "/terms",
cookies: "/cookies",
kit: "/kit",
press: "/press",
};
export function legalPathForSlug(slug: LegalDocumentSlug): string {
+15
View File
@@ -0,0 +1,15 @@
/**
* `/privacy` stays off until university counsel has read the policy.
* Only the runtime switch `ENABLE_PRIVACY_POLICY=true` turns it on.
* A build-time `NEXT_PUBLIC_ENABLE_PRIVACY_POLICY` value does not.
* Unset or any other value is off.
*/
export function isPrivacyPolicyEnabled(): boolean {
return process.env.ENABLE_PRIVACY_POLICY === "true";
}
/** Absolute /privacy URL, or null while the flag is off. */
export function privacyPolicyUrl(origin: string): string | null {
if (!isPrivacyPolicyEnabled()) return null;
return `${origin.replace(/\/$/, "")}/privacy`;
}
+6 -1
View File
@@ -1,5 +1,6 @@
import type { MetadataRoute } from "next";
import { getAllBlogPosts } from "./content";
import { isPrivacyPolicyEnabled } from "./privacyPolicyEnabled";
import { sitemapUrl } from "./siteMetadata";
import { USE_CASE_DETAIL_SLUGS } from "./useCaseSyntheticPost";
@@ -11,6 +12,8 @@ const STATIC_PUBLIC_PATHS = [
"/templates",
"/blog",
"/how-it-works",
"/kit",
"/press",
"/privacy",
"/terms",
"/cookies",
@@ -24,7 +27,9 @@ const STATIC_PUBLIC_PATHS = [
export function buildPublicSitemap(
listedRules: ReadonlyArray<{ id: string; updatedAt: Date }> = [],
): MetadataRoute.Sitemap {
const entries: MetadataRoute.Sitemap = STATIC_PUBLIC_PATHS.map((path) => ({
const entries: MetadataRoute.Sitemap = STATIC_PUBLIC_PATHS.filter(
(path) => path !== "/privacy" || isPrivacyPolicyEnabled(),
).map((path) => ({
url: sitemapUrl(path),
}));
+75 -30
View File
@@ -1,5 +1,6 @@
import { ASSETS, getAssetPath } from "../assetUtils";
import { MAGIC_LINK_TTL_MINUTES } from "../privacyRetention";
import { mailLegalFooterHtml, mailLegalFooterUrls } from "./mailLegalFooter";
export const MAGIC_LINK_LOGO_PATH = getAssetPath(ASSETS.LOGO_MARK);
@@ -31,51 +32,54 @@ function originHost(origin: string): string {
}
}
export function buildMagicLinkMail(
input: MagicLinkMailInput,
type BrandedVerifyMailCopy = {
verifyUrl: string;
origin: string;
subject: string;
previewText: string;
heading: string;
intro: string;
buttonLabel: string;
ignore: string;
why: string;
};
function buildBrandedVerifyMail(
copy: BrandedVerifyMailCopy,
): MagicLinkMailContent {
const origin = input.origin.replace(/\/$/, "");
const minutes = MAGIC_LINK_TTL_MINUTES;
const subject = "Your login link for CommunityRule";
const previewText = `It works once, for ${minutes} minutes.`;
const heading = "Log in to CommunityRule";
const intro = `Use the button to log in. It works once, for ${minutes} minutes.`;
const ignore =
"If you did not ask to log in, ignore this email. Nobody can log in without the link.";
const origin = copy.origin.replace(/\/$/, "");
const { aboutUrl, privacyUrl } = mailLegalFooterUrls(origin);
const madeBy =
"CommunityRule is made by the Media Economies Design Lab at the University of Colorado Boulder.";
const privacyUrl = `${origin}/privacy`;
const aboutUrl = `${origin}/about`;
const logoUrl = `${origin}${MAGIC_LINK_LOGO_PATH}`;
const host = originHost(origin);
const href = escapeHtml(copy.verifyUrl);
const text = [
heading,
copy.heading,
"",
intro,
copy.intro,
"",
`Log in: ${input.verifyUrl}`,
`${copy.buttonLabel}: ${copy.verifyUrl}`,
"",
ignore,
copy.ignore,
"",
madeBy,
`Privacy ${privacyUrl}`,
...(privacyUrl ? [`Privacy ${privacyUrl}`] : []),
`About CommunityRule ${aboutUrl}`,
"",
`Sent because you asked to log in at ${host}.`,
copy.why,
].join("\n");
const href = escapeHtml(input.verifyUrl);
const html = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>${escapeHtml(subject)}</title>
<title>${escapeHtml(copy.subject)}</title>
</head>
<body style="margin:0;padding:0;background:#e4e4e4;">
<div style="display:none;max-height:0;overflow:hidden;mso-hide:all;">${escapeHtml(
previewText,
copy.previewText,
)}</div>
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:#e4e4e4;">
<tr>
@@ -95,19 +99,17 @@ export function buildMagicLinkMail(
</tr>
<tr>
<td style="padding:40px 32px 56px;">
<h1 style="margin:0 0 16px;font-family:'Bricolage Grotesque',Arial,sans-serif;font-size:36px;line-height:44px;font-weight:700;color:#000000;">${escapeHtml(heading)}</h1>
<p style="margin:0 0 32px;font-family:Inter,Arial,sans-serif;font-size:18px;line-height:24px;color:#303030;">${escapeHtml(intro)}</p>
<h1 style="margin:0 0 16px;font-family:'Bricolage Grotesque',Arial,sans-serif;font-size:36px;line-height:44px;font-weight:700;color:#000000;">${escapeHtml(copy.heading)}</h1>
<p style="margin:0 0 32px;font-family:Inter,Arial,sans-serif;font-size:18px;line-height:24px;color:#303030;">${escapeHtml(copy.intro)}</p>
<p style="margin:0 0 32px;">
<a href="${href}" style="display:inline-block;background:#141414;color:#ffffff;font-family:Inter,Arial,sans-serif;font-size:16px;line-height:20px;font-weight:500;text-decoration:none;border-radius:9999px;padding:12px 16px;">Log in</a>
<a href="${href}" style="display:inline-block;background:#141414;color:#ffffff;font-family:Inter,Arial,sans-serif;font-size:16px;line-height:20px;font-weight:500;text-decoration:none;border-radius:9999px;padding:12px 16px;">${escapeHtml(copy.buttonLabel)}</a>
</p>
<div style="height:1px;background:#e4e4e4;margin:0 0 32px;"></div>
<p style="margin:0 0 32px;font-family:Inter,Arial,sans-serif;font-size:16px;line-height:24px;color:#303030;">${escapeHtml(ignore)}</p>
<p style="margin:0 0 32px;font-family:Inter,Arial,sans-serif;font-size:16px;line-height:24px;color:#303030;">${escapeHtml(copy.ignore)}</p>
<div style="border-top:1px solid #e4e4e4;padding-top:24px;">
<p style="margin:0 0 12px;font-family:Inter,Arial,sans-serif;font-size:14px;line-height:20px;color:#464646;">${escapeHtml(madeBy)}</p>
<p style="margin:0;font-family:Inter,Arial,sans-serif;font-size:14px;line-height:20px;color:#464646;">
<a href="${escapeHtml(privacyUrl)}" style="color:#464646;text-decoration:underline;">Privacy</a>
&nbsp;&nbsp;
<a href="${escapeHtml(aboutUrl)}" style="color:#464646;text-decoration:underline;">About CommunityRule</a>
${mailLegalFooterHtml(origin)}
</p>
</div>
</td>
@@ -119,5 +121,48 @@ export function buildMagicLinkMail(
</body>
</html>`;
return { subject, previewText, text, html };
return {
subject: copy.subject,
previewText: copy.previewText,
text,
html,
};
}
export function buildMagicLinkMail(
input: MagicLinkMailInput,
): MagicLinkMailContent {
const minutes = MAGIC_LINK_TTL_MINUTES;
const origin = input.origin.replace(/\/$/, "");
return buildBrandedVerifyMail({
verifyUrl: input.verifyUrl,
origin,
subject: "Your login link for CommunityRule",
previewText: `It works once, for ${minutes} minutes.`,
heading: "Log in to CommunityRule",
intro: `Use the button to log in. It works once, for ${minutes} minutes.`,
buttonLabel: "Log in",
ignore:
"If you did not ask to log in, ignore this email. Nobody can log in without the link.",
why: `Sent because you asked to log in at ${originHost(origin)}.`,
});
}
export function buildEmailChangeMail(
input: MagicLinkMailInput,
): MagicLinkMailContent {
const minutes = MAGIC_LINK_TTL_MINUTES;
const origin = input.origin.replace(/\/$/, "");
return buildBrandedVerifyMail({
verifyUrl: input.verifyUrl,
origin,
subject: "Confirm your new CommunityRule email",
previewText: `It works once, for ${minutes} minutes.`,
heading: "Confirm your new email",
intro: `Use the button to confirm the new address on your CommunityRule account. It works once, for ${minutes} minutes.`,
buttonLabel: "Confirm email",
ignore:
"If you did not request this change, ignore this email. Your current login is unchanged until you confirm.",
why: `Sent because you asked to change the email on your CommunityRule account at ${originHost(origin)}.`,
});
}
+17 -12
View File
@@ -5,8 +5,7 @@ import {
buildWorkshopInboxMail,
type WorkshopInquiryMailInput,
} from "../workshopSignupMail";
import { MAGIC_LINK_TTL_MINUTES } from "../privacyRetention";
import { buildMagicLinkMail } from "./magicLinkMail";
import { buildEmailChangeMail, buildMagicLinkMail } from "./magicLinkMail";
import { getSmtpUrl } from "./env";
import {
buildRuleStakeholderInviteMail,
@@ -26,12 +25,22 @@ function escapeHtml(value: string): string {
.replace(/"/g, "&quot;");
}
/** Display name is CommunityRule, one word, even if SMTP_FROM still has a space. */
function formatMailFrom(from: string): string {
const trimmed = from
.trim()
.replace(/^"?Community Rule"?(\s*<)/, "CommunityRule$1");
if (trimmed.includes("<")) return trimmed;
if (trimmed.includes("@")) return `CommunityRule <${trimmed}>`;
return trimmed;
}
export function resolveMailFrom(): string {
return (
const raw =
process.env.SMTP_FROM?.trim() ||
process.env.CLOUDRON_MAIL_FROM?.trim() ||
"noreply@localhost"
);
"noreply@localhost";
return formatMailFrom(raw);
}
/** Avoid quoted-printable `token=3D` wrapping that some webmail clients do not decode. */
@@ -187,16 +196,12 @@ export async function sendWorkshopInquiryConfirmation(input: {
export async function sendEmailChangeEmail(
to: string,
verifyUrl: string,
origin: string,
): Promise<void> {
const { text, html } = buildVerifyLinkParts(
verifyUrl,
`You asked to change the email on your Community Rule account.\n\nOpen this link to confirm the new address (it expires in ${MAGIC_LINK_TTL_MINUTES} minutes):`,
"If you did not request this change, you can ignore this email. Your current login is unchanged until you confirm.",
"Confirm email",
);
const { subject, text, html } = buildEmailChangeMail({ verifyUrl, origin });
await sendHtmlMail({
to,
subject: "Confirm your new Community Rule email",
subject,
text,
html,
devLog: `[dev] Email change verify for ${to}: ${verifyUrl}`,
+30
View File
@@ -0,0 +1,30 @@
import { privacyPolicyUrl } from "../privacyPolicyEnabled";
function escapeHtml(value: string): string {
return value
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;");
}
export function mailLegalFooterUrls(origin: string): {
aboutUrl: string;
privacyUrl: string | null;
} {
const base = origin.replace(/\/$/, "");
return {
aboutUrl: `${base}/about`,
privacyUrl: privacyPolicyUrl(base),
};
}
/** HTML Privacy + About links. Omits Privacy while the policy flag is off. */
export function mailLegalFooterHtml(origin: string): string {
const { aboutUrl, privacyUrl } = mailLegalFooterUrls(origin);
const about = `<a href="${escapeHtml(aboutUrl)}" style="color:#464646;text-decoration:underline;">About CommunityRule</a>`;
if (!privacyUrl) return about;
return `<a href="${escapeHtml(privacyUrl)}" style="color:#464646;text-decoration:underline;">Privacy</a>
&nbsp;&nbsp;
${about}`;
}
+6 -10
View File
@@ -1,6 +1,7 @@
import { ASSETS, getAssetPath } from "../assetUtils";
import { communityPossessive } from "../create/ruleInviteCardMeta";
import { RULE_MD_FILENAME } from "../create/ruleExportModel";
import { mailLegalFooterHtml, mailLegalFooterUrls } from "./mailLegalFooter";
export const RULE_FOLLOW_UP_LOGO_PATH = getAssetPath(ASSETS.LOGO_MARK);
@@ -55,8 +56,7 @@ export function buildRuleFollowUpMail(
const why = `Sent because you finished a Rule at ${host}.`;
const madeBy =
"CommunityRule is made by the Media Economies Design Lab at the University of Colorado Boulder.";
const privacyUrl = `${origin}/privacy`;
const aboutUrl = `${origin}/about`;
const { privacyUrl } = mailLegalFooterUrls(origin);
const logoUrl = `${origin}${RULE_FOLLOW_UP_LOGO_PATH}`;
const text = [
@@ -82,7 +82,7 @@ export function buildRuleFollowUpMail(
why,
"",
madeBy,
`Privacy ${privacyUrl}`,
...(privacyUrl ? [`Privacy ${privacyUrl}`] : []),
].join("\n");
const html = followUpHtml({
@@ -98,8 +98,7 @@ export function buildRuleFollowUpMail(
signOff,
why,
madeBy,
privacyUrl,
aboutUrl,
origin,
logoUrl,
kitHostPath: `${host}/kit`,
});
@@ -120,8 +119,7 @@ function followUpHtml(opts: {
signOff: string;
why: string;
madeBy: string;
privacyUrl: string;
aboutUrl: string;
origin: string;
logoUrl: string;
kitHostPath: string;
}): string {
@@ -180,9 +178,7 @@ function followUpHtml(opts: {
<p style="margin:0 0 12px;font-family:Inter,Arial,sans-serif;font-size:14px;line-height:20px;color:#464646;">${escapeHtml(opts.why)}</p>
<p style="margin:0 0 12px;font-family:Inter,Arial,sans-serif;font-size:14px;line-height:20px;color:#464646;">${escapeHtml(opts.madeBy)}</p>
<p style="margin:0;font-family:Inter,Arial,sans-serif;font-size:14px;line-height:20px;color:#464646;">
<a href="${escapeHtml(opts.privacyUrl)}" style="color:#464646;text-decoration:underline;">Privacy</a>
&nbsp;&nbsp;
<a href="${escapeHtml(opts.aboutUrl)}" style="color:#464646;text-decoration:underline;">About CommunityRule</a>
${mailLegalFooterHtml(opts.origin)}
</p>
</div>
</td>
+6 -12
View File
@@ -1,4 +1,5 @@
import { ASSETS, getAssetPath } from "../assetUtils";
import { mailLegalFooterHtml, mailLegalFooterUrls } from "./mailLegalFooter";
import {
clipCommunityInviteDescription,
communityInviteInitials,
@@ -84,8 +85,7 @@ export function buildRuleStakeholderInviteMail(
const why = `You got this email because ${inviterEmail} added your address to ${possessive} Rule on CommunityRule. If you do not know the community, you can ignore this email.`;
const madeBy =
"CommunityRule is made by the Media Economies Design Lab at the University of Colorado Boulder.";
const privacyUrl = `${origin}/privacy`;
const aboutUrl = `${origin}/about`;
const { privacyUrl } = mailLegalFooterUrls(origin);
const logoUrl = `${origin}${RULE_STAKEHOLDER_INVITE_LOGO_PATH}`;
const text = [
@@ -106,7 +106,7 @@ export function buildRuleStakeholderInviteMail(
why,
"",
madeBy,
`Privacy ${privacyUrl}`,
...(privacyUrl ? [`Privacy ${privacyUrl}`] : []),
].join("\n");
const html = inviteHtml({
@@ -123,8 +123,7 @@ export function buildRuleStakeholderInviteMail(
copyLead,
why,
madeBy,
privacyUrl,
aboutUrl,
origin,
logoUrl,
});
@@ -145,8 +144,7 @@ function inviteHtml(opts: {
copyLead: string;
why: string;
madeBy: string;
privacyUrl: string;
aboutUrl: string;
origin: string;
logoUrl: string;
}): string {
const heading = escapeHtml(opts.subject);
@@ -165,8 +163,6 @@ function inviteHtml(opts: {
` of this one and change what does not fit.`;
const why = escapeHtml(opts.why);
const madeBy = escapeHtml(opts.madeBy);
const privacyUrl = escapeHtml(opts.privacyUrl);
const aboutUrl = escapeHtml(opts.aboutUrl);
const logoUrl = escapeHtml(opts.logoUrl);
const cardBody = description
? `<p style="margin:16px 0 0;font-family:Inter,Arial,sans-serif;font-size:14px;line-height:18px;font-weight:500;color:#000000;">${description}</p>`
@@ -236,9 +232,7 @@ function inviteHtml(opts: {
<p style="margin:0 0 12px;font-family:Inter,Arial,sans-serif;font-size:14px;line-height:20px;color:#464646;">${why}</p>
<p style="margin:0 0 12px;font-family:Inter,Arial,sans-serif;font-size:14px;line-height:20px;color:#464646;">${madeBy}</p>
<p style="margin:0;font-family:Inter,Arial,sans-serif;font-size:14px;line-height:20px;color:#464646;">
<a href="${privacyUrl}" style="color:#464646;text-decoration:underline;">Privacy</a>
&nbsp;&nbsp;
<a href="${aboutUrl}" style="color:#464646;text-decoration:underline;">About CommunityRule</a>
${mailLegalFooterHtml(opts.origin)}
</p>
</div>
</td>
+1 -1
View File
@@ -3,5 +3,5 @@ export function useCaseTemplateDuplicateTitle(sourceTitle: string): string {
const trimmed = sourceTitle.trim();
return trimmed.length > 0
? `${trimmed} Template (Copy)`
: "Community Rule Template (Copy)";
: "CommunityRule Template (Copy)";
}
+4
View File
@@ -27,6 +27,8 @@ import useCasesDetail from "./pages/useCasesDetail.json";
import useCasesCompletedRules from "./pages/useCasesCompletedRules.json";
import useCasesCompletedRule from "./pages/useCasesCompletedRule.json";
import howItWorks from "./pages/howItWorks.json";
import kit from "./pages/kit.json";
import press from "./pages/press.json";
import privacy from "./pages/privacy.json";
import terms from "./pages/terms.json";
import cookies from "./pages/cookies.json";
@@ -112,6 +114,8 @@ export default {
useCasesCompletedRules,
useCasesCompletedRule,
howItWorks,
kit,
press,
privacy,
terms,
cookies,
+4
View File
@@ -39,6 +39,8 @@ import useCasesDetail from "./pages/useCasesDetail.json";
import useCasesCompletedRules from "./pages/useCasesCompletedRules.json";
import useCasesCompletedRule from "./pages/useCasesCompletedRule.json";
import howItWorks from "./pages/howItWorks.json";
import kit from "./pages/kit.json";
import press from "./pages/press.json";
import privacy from "./pages/privacy.json";
import terms from "./pages/terms.json";
import cookies from "./pages/cookies.json";
@@ -84,6 +86,8 @@ const marketingMessages = {
useCasesCompletedRules,
useCasesCompletedRule,
howItWorks,
kit,
press,
privacy,
terms,
cookies,
+20 -10
View File
@@ -40,7 +40,7 @@
},
"create": {
"title": "Create",
"description": "This flow will give you recommendations to improve your community and help you put together a proposal for your group to consider."
"description": "Start a Rule for your community. CommunityRule recommends templates from the details you enter, then you put a proposal together for your group."
},
"blog": {
"title": "Blog",
@@ -63,11 +63,11 @@
},
"profile": {
"title": "Profile",
"description": "Manage your CommunityRules, saved progress, and account."
"description": "Manage the Rules you have finished, saved progress, and your account."
},
"monitor": {
"title": "Monitor",
"description": "Real-time monitoring of Core Web Vitals and performance metrics for Community Rule 3.0"
"description": "Real-time monitoring of Core Web Vitals and performance metrics for CommunityRule 3.0"
},
"notFound": {
"title": "Page not found",
@@ -117,8 +117,8 @@
},
"useCasesCompletedRule": {
"mutualAidColorado": {
"title": "Mutual Aid Colorado community rule",
"description": "Read the completed community rule Mutual Aid Colorado built with CommunityRule.",
"title": "Mutual Aid Colorado CommunityRule",
"description": "Read the completed Rule Mutual Aid Colorado built with CommunityRule.",
"keywords": [
"mutual aid",
"community rule",
@@ -127,8 +127,8 @@
]
},
"foodNotBombs": {
"title": "Food Not Bombs Boulder community rule",
"description": "Read the completed community rule Food Not Bombs Boulder built with CommunityRule.",
"title": "Food Not Bombs Boulder CommunityRule",
"description": "Read the completed Rule Food Not Bombs Boulder built with CommunityRule.",
"keywords": [
"food not bombs",
"community rule",
@@ -137,8 +137,8 @@
]
},
"boulderCountyStreetMedics": {
"title": "Boulder Street Medics community rule",
"description": "Read the completed community rule Boulder Street Medics built with CommunityRule.",
"title": "Boulder Street Medics CommunityRule",
"description": "Read the completed Rule Boulder Street Medics built with CommunityRule.",
"keywords": [
"street medics",
"community rule",
@@ -147,6 +147,16 @@
]
}
},
"kit": {
"title": "The kit",
"description": "Everything your community needs to write its Rule together over five short meetings you already hold. Free for volunteer-run groups.",
"keywords": ["kit", "facilitator guide", "office hours", "communityrule"]
},
"press": {
"title": "Press",
"description": "Press materials for CommunityRule, licensed CC BY-SA 4.0. Contact, embargo dates, and the story behind the tool.",
"keywords": ["press", "press kit", "communityrule", "media"]
},
"howItWorks": {
"title": "When your community sits down to write its Rule",
"description": "Sketch your Rule in CommunityRule, then make it your community's own over five short meetings.",
@@ -169,7 +179,7 @@
},
"cookies": {
"title": "Cookies",
"description": "CommunityRule uses cookies to keep you logged in and to let you claim a rule you finished without logging in.",
"description": "CommunityRule uses cookies to keep you logged in and to let you claim a Rule you finished without logging in.",
"keywords": ["cookies", "session", "privacy", "communityrule"]
}
}
+9 -4
View File
@@ -2,20 +2,25 @@
"_comment": "Cookies. Figma Content page Template (19003:23305): banner + labeled body stacks. There are no optional cookies to toggle. The footer does not link here.",
"banner": {
"title": "Cookies",
"description": "CommunityRule uses cookies to keep you logged in and to let you claim a rule you finished without logging in.",
"description": "CommunityRule uses cookies to keep you logged in and to let you claim a Rule you finished without logging in.",
"author": "Media Economies Design Lab",
"date": "2026-08-15"
},
"updated": "Last updated August 15, 2026.",
"intro": [
"CommunityRule sets a cookie named cr_session after you log in with a magic link. It keeps you logged in for up to 30 days. Set when you finish a Rule without logging in: we also set cr_rule_claim so that logging in later on this browser can attach that rule to your account. There are no advertising or analytics cookies to turn off."
"CommunityRule sets a cookie named cr_session after you log in. It keeps you logged in for up to 30 days. When you finish a Rule without logging in, we also set cr_rule_claim so that logging in later on this browser can attach that Rule to your account. There are no advertising or analytics cookies to turn off."
],
"sections": [
{
"heading": "The session cookie",
"paragraphs": [
"Log out to clear the session cookie on this browser. Blocking it will log you out and keep you from staying logged in. Browsing templates does not set this cookie.",
"Set when you finish a Rule without logging in. It is httpOnly, lasts up to 30 days, and is cleared after a successful login claim. Clearing this site’s cookies means you cannot attach that guest-finished rule to an account from this browser."
"Log out to clear the session cookie on this browser. Blocking it will log you out and keep you from staying logged in. Browsing templates does not set this cookie."
]
},
{
"heading": "The claim cookie",
"paragraphs": [
"Set when you finish a Rule without logging in. It is httpOnly, lasts up to 30 days, and is cleared after a successful login claim. Clearing this site’s cookies means you cannot attach that guest-finished Rule to an account from this browser."
]
},
{
+55
View File
@@ -0,0 +1,55 @@
{
"_comment": "Kit page at /kit. Figma C8 Kit page (25218:120616) on the Content page Template. Facilitator guide and FigJam board are live; printed cards, poster and zine are named without download links until those files exist. Office hours start 22 February 2027; the page names no weekday until two people can commit to one.",
"banner": {
"title": "The kit",
"description": "Everything your community needs to write its Rule together over five short meetings you already hold. Free for volunteer-run groups.",
"author": "Media Economies Design Lab",
"date": "2027-01-19"
},
"updated": "Last updated January 19, 2027.",
"intro": [
"The kit is how a community writes its Rule without us in the room. Any member can run it. It spreads the work over five short meetings your community already holds, and it starts on paper."
],
"sections": [
{
"heading": "What is in it",
"paragraphs": [
"The facilitator guide, with a printable worksheet for each meeting. [Download the facilitator guide](https://colorado-mutual-aid.notion.site/Workshop-facilitator-guide-40fb9b9e2d3b81b683c0ca15de007f2a).",
"The FigJam board, for communities that meet online. [Open the board](https://www.figma.com/board/gnQ55HnX7EtOV9nwlZcW1V?node-id=32-80).",
"Thirteen template cards, one for each template.",
"The four questions poster.",
"The zine.",
"No form and no account. [Download the kit](https://colorado-mutual-aid.notion.site/Workshop-facilitator-guide-40fb9b9e2d3b81b683c0ca15de007f2a)."
]
},
{
"heading": "How the five meetings run",
"paragraphs": [
"The first meeting runs an hour. It opens with the question nobody has asked out loud, then takes the first of the four questions. How you talk, who belongs, how you decide and what happens when you disagree.",
"The next three meetings take one question each, in forty-five minutes.",
"The last meeting takes your values and the signs that one is slipping. Then someone reads the draft aloud and it goes to every member.",
"A community with more time can take two questions in one meeting of ninety minutes.",
"Every meeting opens by reading aloud how the room decides, and closes the same way. Only the close puts anything into CommunityRule.",
"The draft becomes your Rule once every member has read it and has had at least seven days to object. Objections close the day before your next regular meeting, and that meeting settles them the way the draft says. [Create rule](/create/informational)."
]
},
{
"heading": "Office hours",
"paragraphs": [
"Bring your draft, your Rule or a question. No signup. Office hours start 22 February 2027. They run every week through 20 March 2027, then every month. Times are listed here once they are set."
]
},
{
"heading": "Stuck between meetings",
"paragraphs": [
"[Ask an organizer](/#ask-organizer). A person writes back within two working days."
]
},
{
"heading": "A larger organization",
"paragraphs": [
"Credit unions, mutuals and co-ops with thousands of members can bring a facilitator. [Talk to a facilitator](/workshops#workshop-signup)."
]
}
]
}
+1 -1
View File
@@ -1,7 +1,7 @@
{
"_comment": "Admin /monitor performance page",
"title": "Performance Monitoring",
"description": "Real-time monitoring of Core Web Vitals and performance metrics for Community Rule 3.0",
"description": "Real-time monitoring of Core Web Vitals and performance metrics for CommunityRule 3.0",
"performanceTargets": {
"title": "Performance Targets",
"loadTime": "Load Time",
+67
View File
@@ -0,0 +1,67 @@
{
"_comment": "Press page at /press. Figma Press / Embargoed (24810:39764). The release and Boulder count join this page when the embargo lifts at 6am Mountain time on 18 February 2027. Downloadable kit files are named without links until those files exist.",
"banner": {
"title": "Press",
"description": "Everything on this page is licensed CC BY-SA 4.0. Use it.",
"author": "Media Economies Design Lab",
"date": "2027-02-05"
},
"updated": "Last updated February 5, 2027. Embargoed until 6am Mountain time on Thursday, February 18, 2027.",
"intro": [
"The release and the Boulder count join this page when the embargo lifts. Until then they go only to journalists who have agreed to the embargo.",
"CU Boulder's news office sends the release to journalists under embargo on Tuesday, February 16. It goes public here at 6am Mountain time on Thursday, February 18, with the Boulder count of Rules written by kind of group."
],
"sections": [
{
"heading": "Contact",
"paragraphs": [
"One contact for press is Nathan Schneider at [medlab@colorado.edu](mailto:medlab@colorado.edu).",
"Writing about CommunityRule? We can put you in touch with a pilot group. [Email the press contact](mailto:medlab@colorado.edu)."
]
},
{
"heading": "The story",
"paragraphs": [
"We asked organizers from co-ops, mutual aid groups and open source projects around the world how their groups really work. The ones that lasted had settled four things early: how they decide, who belongs, how they talk, and what happens when they disagree. CommunityRule turns that finding into a Rule a group writes together, from one of 13 tested templates, with signals that show when a value is slipping. It is free and open source, built at the Media Economies Design Lab at CU Boulder. Volunteer-run groups can run a Rule-writing session for free. Larger organizations bring a facilitator, which keeps it free for everyone else."
]
},
{
"heading": "Dates",
"paragraphs": [
"Launch: Thursday, February 18, 2027.",
"Boulder launch party: Saturday, February 20, 2027. Snow date Saturday, February 27.",
"Seminar: an online seminar with Metagov from January 11 to February 14, with a live capstone on February 17."
]
},
{
"heading": "Where does the finding come from?",
"paragraphs": [
"From a UX research and service design study run inside the Media Economies Design Lab at the University of Colorado Boulder. We asked organizers from co-ops, mutual aid groups and open source projects how their groups really work. The groups that lasted had settled four things early. How they decide, who belongs, how they talk and what happens when they disagree."
]
},
{
"heading": "Who makes CommunityRule and what does it cost?",
"paragraphs": [
"CommunityRule is made at the Media Economies Design Lab at the University of Colorado Boulder. It is free and open source. Volunteer-run groups run their own session with the kit. Larger organizations bring a facilitator, and that is what keeps the kit free."
]
},
{
"heading": "Who can see a group's Rule?",
"paragraphs": [
"Only the people you share it with. Rules are private by default. A Rule is public and featured only when a community asks us in writing."
]
},
{
"heading": "Does CommunityRule use AI?",
"paragraphs": [
"No. When you choose community details such as size or organization type, we use those answers to reorder templates and methods. Ranking is a matching table we maintain. It is not an AI or machine-learning model, it does not train on your drafts, and we do not send your data to an AI service."
]
},
{
"heading": "Who can we interview?",
"paragraphs": [
"Write to [medlab@colorado.edu](mailto:medlab@colorado.edu). We can put you in touch with a pilot group."
]
}
]
}
+3 -3
View File
@@ -1,5 +1,5 @@
{
"_comment": "Privacy policy currently on /privacy. Owns personal data, hosting, and how ranking works. API usage and licenses live on Terms. Grounded in MEDLab Cloudron + SES mail relay + facet-matrix recommendations. Periods and hosting facts for the new policy live in docs/privacy-policy-facts.md. Do not switch /privacy to that text until university counsel has read it.",
"_comment": "Privacy policy currently on /privacy, behind ENABLE_PRIVACY_POLICY. Owns personal data, hosting, and how ranking works. API usage and licenses live on Terms. Grounded in MEDLab Cloudron + SES mail relay + facet-matrix recommendations. Periods and hosting facts for the new policy live in docs/privacy-policy-facts.md. Do not switch /privacy to that text until university counsel has read it.",
"banner": {
"title": "Privacy Policy",
"description": "What we collect, where it is stored, and how template recommendations work.",
@@ -14,7 +14,7 @@
{
"heading": "What we collect",
"paragraphs": [
"Your email, to log you in, change your email, or invite a stakeholder. In-progress drafts in your browser and, after you save, on our servers. Files you attach to a Rule. Messages you send through the organizer form, which go to MEDLab by email. Page performance metrics (URL, timing, and browser), which are written to our server logs and are not tied to your account. If you finish a Rule without logging in, a claim cookie on this browser so a later login can attach that Rule to your account. We count page views with Umami, self-hosted beside this app. It sets no cookies and stores aggregate counts only.",
"Your email, to log you in, change your email, or invite the people in your community. In-progress drafts in your browser and, after you save, on our servers. Files you attach to a Rule. Messages you send through the organizer form, which go to MEDLab by email. Page performance metrics (URL, timing, and browser), which are written to our server logs and are not tied to your account. If you finish a Rule without logging in, a claim cookie on this browser so a later login can attach that Rule to your account. We count page views with Umami, self-hosted beside this app. It sets no cookies and stores aggregate counts only.",
"We do not sell this information or use it for advertising. As a public university project, some records may be subject to the Colorado Open Records Act."
]
},
@@ -28,7 +28,7 @@
{
"heading": "Recommendations",
"paragraphs": [
"When you choose community details in the wizard (such as size or organization type), we use those answers to reorder templates and methods. The same ranking is available when those filters are sent to the templates API.",
"Your answers about your community’s size, kind, scale and stage reorder the templates and methods you see. The same ranking is available when those filters are sent to the templates API.",
"Ranking is a matching table we maintain. It is not an AI or machine-learning model, it does not train on your drafts, and we do not send your data to an AI service."
]
},
@@ -188,6 +188,9 @@ export const FullHD = {
// Interactive story for testing user interactions
export const Interactive = {
args: {
privacyEnabled: true,
},
parameters: {
docs: {
description: {
+11 -1
View File
@@ -118,7 +118,7 @@ describe("Footer (behavioral tests)", () => {
});
it("renders legal links to privacy and terms pages", () => {
render(<Footer />);
render(<Footer privacyEnabled />);
expect(
screen.getAllByRole("link", { name: "Privacy Policy" })[0],
).toHaveAttribute("href", "/privacy");
@@ -129,4 +129,14 @@ describe("Footer (behavioral tests)", () => {
screen.queryByRole("link", { name: "Cookies Settings" }),
).not.toBeInTheDocument();
});
it("omits the privacy link when the policy is off", () => {
render(<Footer privacyEnabled={false} />);
expect(
screen.queryByRole("link", { name: "Privacy Policy" }),
).not.toBeInTheDocument();
expect(
screen.getAllByRole("link", { name: "Terms of Service" })[0],
).toHaveAttribute("href", "/terms");
});
});
+15 -1
View File
@@ -78,7 +78,11 @@ describe("LoginForm", () => {
});
it("links terms and privacy to the legal pages", () => {
renderLoginForm();
renderWithProviders(
<Suspense fallback={null}>
<LoginForm privacyEnabled />
</Suspense>,
);
expect(
screen.getByRole("link", { name: "Terms of Service" }),
).toHaveAttribute("href", "/terms");
@@ -87,6 +91,16 @@ describe("LoginForm", () => {
).toHaveAttribute("href", "/privacy");
});
it("links terms only when the privacy policy is off", () => {
renderLoginForm();
expect(
screen.getByRole("link", { name: "Terms of Service" }),
).toHaveAttribute("href", "/terms");
expect(
screen.queryByRole("link", { name: "Privacy Policy" }),
).not.toBeInTheDocument();
});
it("shows validation error when email is invalid", async () => {
const user = userEvent.setup();
renderLoginForm();
+1
View File
@@ -19,6 +19,7 @@ describe("Workshops page sections", () => {
for (const link of links) {
expect(link).toHaveAttribute("href", "#workshop-signup");
}
expect(links[0]).toHaveClass("self-start");
});
it("shows the full field set, one optional marker, and the settled challenge line", () => {
+3
View File
@@ -17,4 +17,7 @@ vi.mock("next/navigation", () => ({
useRouter: () => testRouter,
usePathname: () => testPathname(),
useSearchParams: vi.fn(() => new URLSearchParams()),
notFound: () => {
throw new Error("NEXT_NOT_FOUND");
},
}));
+82
View File
@@ -0,0 +1,82 @@
import { describe, expect, test, vi } from "vitest";
import { screen } from "@testing-library/react";
import { renderWithProviders as render } from "../utils/test-utils";
import LegalDocumentPage from "../../app/(marketing)/_components/LegalDocumentPage";
import { legalPathForSlug } from "../../lib/legalSyntheticPost";
import messages from "../../messages/en/index";
vi.mock("../../lib/requestSiteOrigin", () => ({
getRequestSiteOrigin: async () => "https://communityrule.info",
}));
vi.mock("../../app/components/sections/ContentBanner", () => ({
default: ({ post, variant, updatedLabel }) => (
<section data-testid="content-banner" data-variant={variant}>
<h1>{post.frontmatter.title}</h1>
<p>{post.frontmatter.description}</p>
{updatedLabel ? (
<div>
<span>{post.frontmatter.author}</span>
<span>{updatedLabel}</span>
</div>
) : null}
</section>
),
}));
async function renderKitPage() {
const page = messages.pages.kit;
const ui = await LegalDocumentPage({
slug: "kit",
path: legalPathForSlug("kit"),
page,
});
return render(ui);
}
describe("kit page", () => {
test("covers the five meetings, the facilitator guide, and office hours", async () => {
await renderKitPage();
const page = messages.pages.kit;
expect(screen.getByTestId("content-banner")).toHaveAttribute(
"data-variant",
"guide",
);
expect(
screen.getByRole("heading", { level: 1, name: page.banner.title }),
).toBeInTheDocument();
expect(screen.getByText(page.banner.description)).toBeInTheDocument();
expect(
screen.getByRole("heading", { level: 2, name: "What is in it" }),
).toBeInTheDocument();
expect(
screen.getByRole("heading", { level: 2, name: "How the five meetings run" }),
).toBeInTheDocument();
expect(
screen.getByRole("heading", { level: 2, name: "Office hours" }),
).toBeInTheDocument();
expect(
screen.getByRole("link", { name: "Download the facilitator guide" }),
).toHaveAttribute(
"href",
"https://colorado-mutual-aid.notion.site/Workshop-facilitator-guide-40fb9b9e2d3b81b683c0ca15de007f2a",
);
expect(screen.getByRole("link", { name: "Open the board" })).toHaveAttribute(
"href",
"https://www.figma.com/board/gnQ55HnX7EtOV9nwlZcW1V?node-id=32-80",
);
expect(screen.getByRole("link", { name: "Create rule" })).toHaveAttribute(
"href",
"/create/informational",
);
expect(screen.getByRole("link", { name: "Ask an organizer" })).toHaveAttribute(
"href",
"/#ask-organizer",
);
expect(
screen.getByRole("link", { name: "Talk to a facilitator" }),
).toHaveAttribute("href", "/workshops#workshop-signup");
expect(screen.getByText(/22 February 2027/)).toBeInTheDocument();
});
});
+52 -8
View File
@@ -2,10 +2,14 @@ import { describe, expect, test, vi } from "vitest";
import { screen } from "@testing-library/react";
import { renderWithProviders as render } from "../utils/test-utils";
import PrivacyPage from "../../app/(marketing)/privacy/page";
import TermsPage from "../../app/(marketing)/terms/page";
import CookiesPage from "../../app/(marketing)/cookies/page";
import LegalDocumentPage from "../../app/(marketing)/_components/LegalDocumentPage";
import { legalPathForSlug } from "../../lib/legalSyntheticPost";
import messages from "../../messages/en/index";
vi.mock("../../lib/requestSiteOrigin", () => ({
getRequestSiteOrigin: async () => "https://communityrule.info",
}));
vi.mock("../../app/components/sections/ContentBanner", () => ({
default: ({ post, variant, updatedLabel }) => (
<section data-testid="content-banner" data-variant={variant}>
@@ -21,6 +25,18 @@ vi.mock("../../app/components/sections/ContentBanner", () => ({
),
}));
async function renderLegalPage(
slug: "privacy" | "terms" | "cookies",
page: (typeof messages.pages)[typeof slug],
) {
const ui = await LegalDocumentPage({
slug,
path: legalPathForSlug(slug),
page,
});
return render(ui);
}
describe("legal document pages", () => {
test("privacy copy names Umami and cookieless counts", () => {
const collect = messages.pages.privacy.sections.find(
@@ -30,8 +46,32 @@ describe("legal document pages", () => {
expect(collect?.paragraphs.join(" ")).toMatch(/sets no cookies/);
});
test("privacy page covers hosting, recommendations, and campus privacy", () => {
render(<PrivacyPage />);
test("privacy copy does not say stakeholder or wizard", () => {
const text = JSON.stringify(messages.pages.privacy);
expect(text).not.toMatch(/stakeholder/i);
expect(text).not.toMatch(/wizard/i);
});
test("privacy page 404s while the flag is off", () => {
const previous = process.env.ENABLE_PRIVACY_POLICY;
const previousPublic = process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY;
delete process.env.ENABLE_PRIVACY_POLICY;
delete process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY;
try {
expect(() => PrivacyPage()).toThrow("NEXT_NOT_FOUND");
} finally {
if (previous === undefined) delete process.env.ENABLE_PRIVACY_POLICY;
else process.env.ENABLE_PRIVACY_POLICY = previous;
if (previousPublic === undefined) {
delete process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY;
} else {
process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY = previousPublic;
}
}
});
test("privacy page covers hosting, recommendations, and campus privacy", async () => {
await renderLegalPage("privacy", messages.pages.privacy);
const page = messages.pages.privacy;
expect(screen.getByTestId("content-banner")).toHaveAttribute(
@@ -71,8 +111,8 @@ describe("legal document pages", () => {
);
});
test("terms page covers licenses and the templates API, not ranking", () => {
render(<TermsPage />);
test("terms page covers licenses and the templates API, not ranking", async () => {
await renderLegalPage("terms", messages.pages.terms);
const page = messages.pages.terms;
expect(
@@ -105,8 +145,8 @@ describe("legal document pages", () => {
).toHaveAttribute("href", "/api/templates");
});
test("cookies settings page explains there are no optional cookies", () => {
render(<CookiesPage />);
test("cookies settings page explains there are no optional cookies", async () => {
await renderLegalPage("cookies", messages.pages.cookies);
const page = messages.pages.cookies;
expect(
@@ -115,11 +155,15 @@ describe("legal document pages", () => {
expect(
screen.getByRole("heading", { level: 2, name: "The session cookie" }),
).toBeInTheDocument();
expect(
screen.getByRole("heading", { level: 2, name: "The claim cookie" }),
).toBeInTheDocument();
expect(
screen.getByText(/There are no advertising or analytics cookies to turn off/),
).toBeInTheDocument();
expect(screen.getByText(/cr_session/)).toBeInTheDocument();
expect(screen.getByText(/cr_rule_claim/)).toBeInTheDocument();
expect(JSON.stringify(page)).not.toMatch(/magic link/i);
expect(
screen.getAllByRole("link", { name: "Privacy Policy" })[0],
).toHaveAttribute("href", "/privacy");
+70
View File
@@ -0,0 +1,70 @@
import { describe, expect, test, vi } from "vitest";
import { screen } from "@testing-library/react";
import { renderWithProviders as render } from "../utils/test-utils";
import LegalDocumentPage from "../../app/(marketing)/_components/LegalDocumentPage";
import { legalPathForSlug } from "../../lib/legalSyntheticPost";
import messages from "../../messages/en/index";
vi.mock("../../lib/requestSiteOrigin", () => ({
getRequestSiteOrigin: async () => "https://communityrule.info",
}));
vi.mock("../../app/components/sections/ContentBanner", () => ({
default: ({ post, variant, updatedLabel }) => (
<section data-testid="content-banner" data-variant={variant}>
<h1>{post.frontmatter.title}</h1>
<p>{post.frontmatter.description}</p>
{updatedLabel ? (
<div>
<span>{post.frontmatter.author}</span>
<span>{updatedLabel}</span>
</div>
) : null}
</section>
),
}));
async function renderPressPage() {
const page = messages.pages.press;
const ui = await LegalDocumentPage({
slug: "press",
path: legalPathForSlug("press"),
page,
});
return render(ui);
}
describe("press page", () => {
test("holds embargoed press materials, a contact, and the story", async () => {
await renderPressPage();
const page = messages.pages.press;
expect(screen.getByTestId("content-banner")).toHaveAttribute(
"data-variant",
"guide",
);
expect(
screen.getByRole("heading", { level: 1, name: page.banner.title }),
).toBeInTheDocument();
expect(screen.getByText(page.banner.description)).toBeInTheDocument();
expect(
screen.getByText(/when the embargo lifts/),
).toBeInTheDocument();
expect(
screen.getByRole("heading", { level: 2, name: "Contact" }),
).toBeInTheDocument();
expect(
screen.getByRole("heading", { level: 2, name: "The story" }),
).toBeInTheDocument();
expect(
screen.getByRole("heading", { level: 2, name: "Does CommunityRule use AI?" }),
).toBeInTheDocument();
expect(
screen.getAllByRole("link", { name: "medlab@colorado.edu" })[0],
).toHaveAttribute("href", "mailto:medlab@colorado.edu");
expect(
screen.getByRole("link", { name: "Email the press contact" }),
).toHaveAttribute("href", "mailto:medlab@colorado.edu");
expect(screen.getByText(/CC BY-SA 4.0/)).toBeInTheDocument();
});
});
+2
View File
@@ -9,6 +9,8 @@ describe("legalSyntheticPost", () => {
expect(legalPathForSlug("privacy")).toBe("/privacy");
expect(legalPathForSlug("terms")).toBe("/terms");
expect(legalPathForSlug("cookies")).toBe("/cookies");
expect(legalPathForSlug("kit")).toBe("/kit");
expect(legalPathForSlug("press")).toBe("/press");
});
it("builds a guide-shaped post from page messages", () => {
+46 -1
View File
@@ -1,6 +1,9 @@
import { describe, expect, it } from "vitest";
import { MAGIC_LINK_TTL_MINUTES } from "../../lib/privacyRetention";
import { buildMagicLinkMail } from "../../lib/server/magicLinkMail";
import {
buildEmailChangeMail,
buildMagicLinkMail,
} from "../../lib/server/magicLinkMail";
const VERIFY_URL =
"https://communityrule.info/api/auth/magic-link/verify?token=abc";
@@ -32,4 +35,46 @@ describe("buildMagicLinkMail", () => {
expect(mail.html).not.toContain("Hi ");
expect(mail.text).not.toContain("Hi ");
});
it("omits the privacy link while the policy flag is off", () => {
const previous = process.env.ENABLE_PRIVACY_POLICY;
const previousPublic = process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY;
delete process.env.ENABLE_PRIVACY_POLICY;
delete process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY;
try {
const off = buildMagicLinkMail({
verifyUrl: VERIFY_URL,
origin: "https://communityrule.info",
});
expect(off.html).not.toContain("/privacy");
expect(off.text).not.toContain("/privacy");
expect(off.html).toContain("/about");
} finally {
if (previous === undefined) delete process.env.ENABLE_PRIVACY_POLICY;
else process.env.ENABLE_PRIVACY_POLICY = previous;
if (previousPublic === undefined) {
delete process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY;
} else {
process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY = previousPublic;
}
}
});
});
describe("buildEmailChangeMail", () => {
const mail = buildEmailChangeMail({
verifyUrl: "https://communityrule.info/api/user/email-change/verify?token=abc",
origin: "https://communityrule.info",
});
it("matches the login email chrome with CommunityRule copy", () => {
expect(mail.subject).toBe("Confirm your new CommunityRule email");
expect(mail.html).toContain("background:#000000");
expect(mail.html).toContain(">Confirm email</a>");
expect(mail.html).toContain("CommunityRule account");
expect(mail.text).toContain("CommunityRule account");
expect(mail.subject).not.toMatch(/Community Rule/);
expect(mail.html).not.toMatch(/Community Rule/);
expect(mail.text).not.toMatch(/Community Rule/);
});
});
+11 -3
View File
@@ -100,14 +100,22 @@ describe("resolveMailFrom", () => {
it("prefers SMTP_FROM, then CLOUDRON_MAIL_FROM", () => {
delete process.env.SMTP_FROM;
delete process.env.CLOUDRON_MAIL_FROM;
expect(resolveMailFrom()).toBe("noreply@localhost");
expect(resolveMailFrom()).toBe("CommunityRule <noreply@localhost>");
process.env.CLOUDRON_MAIL_FROM = "staging.app@communityrule.info";
expect(resolveMailFrom()).toBe("staging.app@communityrule.info");
expect(resolveMailFrom()).toBe(
"CommunityRule <staging.app@communityrule.info>",
);
process.env.SMTP_FROM = "Community Rule <hello@communityrule.info>";
expect(resolveMailFrom()).toBe(
"Community Rule <hello@communityrule.info>",
"CommunityRule <hello@communityrule.info>",
);
});
it("puts CommunityRule on a bare mailbox", () => {
delete process.env.SMTP_FROM;
process.env.CLOUDRON_MAIL_FROM = "hello@communityrule.info";
expect(resolveMailFrom()).toBe("CommunityRule <hello@communityrule.info>");
});
});
@@ -6,6 +6,7 @@ const sendOrganizerInquiryNotificationMock = vi.fn();
vi.mock("../../lib/server/mail", () => ({
sendOrganizerInquiryNotification: (...args: unknown[]) =>
sendOrganizerInquiryNotificationMock(...args),
resolveMailFrom: () => "CommunityRule <noreply@localhost>",
}));
const rateLimitKeyMock = vi.hoisted(() =>
@@ -54,6 +55,7 @@ describe("POST /api/organizer-inquiry", () => {
expect(body).toEqual({ ok: true });
expect(sendOrganizerInquiryNotificationMock).toHaveBeenCalledTimes(1);
const arg = sendOrganizerInquiryNotificationMock.mock.calls[0][0];
expect(arg.fromEmail).toBe("CommunityRule <noreply@localhost>");
expect(arg.visitorEmail).toBe("visitor@example.com");
expect(arg.message).toBe("How do we run consensus meetings?");
});
+44
View File
@@ -0,0 +1,44 @@
import { afterEach, describe, expect, it } from "vitest";
import {
isPrivacyPolicyEnabled,
privacyPolicyUrl,
} from "../../lib/privacyPolicyEnabled";
const KEYS = ["ENABLE_PRIVACY_POLICY", "NEXT_PUBLIC_ENABLE_PRIVACY_POLICY"] as const;
const ORIGINAL = Object.fromEntries(
KEYS.map((key) => [key, process.env[key]]),
) as Record<(typeof KEYS)[number], string | undefined>;
afterEach(() => {
for (const key of KEYS) {
const original = ORIGINAL[key];
if (original === undefined) delete process.env[key];
else process.env[key] = original;
}
});
describe("isPrivacyPolicyEnabled", () => {
it("is off unless a flag is the string true", () => {
delete process.env.ENABLE_PRIVACY_POLICY;
delete process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY;
expect(isPrivacyPolicyEnabled()).toBe(false);
expect(privacyPolicyUrl("https://communityrule.info")).toBeNull();
process.env.ENABLE_PRIVACY_POLICY = "yes";
expect(isPrivacyPolicyEnabled()).toBe(false);
process.env.ENABLE_PRIVACY_POLICY = "true";
expect(isPrivacyPolicyEnabled()).toBe(true);
expect(privacyPolicyUrl("https://communityrule.info/")).toBe(
"https://communityrule.info/privacy",
);
delete process.env.ENABLE_PRIVACY_POLICY;
process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY = "true";
expect(isPrivacyPolicyEnabled()).toBe(false);
expect(privacyPolicyUrl("https://communityrule.info")).toBeNull();
process.env.ENABLE_PRIVACY_POLICY = "true";
expect(isPrivacyPolicyEnabled()).toBe(true);
});
});
+22 -1
View File
@@ -16,6 +16,8 @@ describe("buildPublicSitemap", () => {
expect(urls).toContain(sitemapUrl("/blog"));
expect(urls).not.toContain(sitemapUrl("/use-cases"));
expect(urls).toContain(sitemapUrl("/how-it-works"));
expect(urls).toContain(sitemapUrl("/kit"));
expect(urls).toContain(sitemapUrl("/press"));
expect(urls).toContain(sitemapUrl("/privacy"));
expect(urls).toContain(sitemapUrl("/terms"));
expect(urls).toContain(sitemapUrl("/cookies"));
@@ -36,7 +38,6 @@ describe("buildPublicSitemap", () => {
expect(urls.some((url) => url.includes("/create"))).toBe(false);
expect(urls.some((url) => url.includes("/monitor"))).toBe(false);
expect(urls.some((url) => url.includes("/rule-counts"))).toBe(false);
expect(urls.some((url) => url.includes("/kit"))).toBe(false);
expect(urls.some((url) => url.includes("/api/"))).toBe(false);
});
@@ -54,4 +55,24 @@ describe("buildPublicSitemap", () => {
lastModified: updatedAt,
});
});
it("omits /privacy while the policy flag is off", () => {
const previous = process.env.ENABLE_PRIVACY_POLICY;
const previousPublic = process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY;
delete process.env.ENABLE_PRIVACY_POLICY;
delete process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY;
try {
const urls = buildPublicSitemap().map((entry) => entry.url);
expect(urls).not.toContain(sitemapUrl("/privacy"));
expect(urls).toContain(sitemapUrl("/terms"));
} finally {
if (previous === undefined) delete process.env.ENABLE_PRIVACY_POLICY;
else process.env.ENABLE_PRIVACY_POLICY = previous;
if (previousPublic === undefined) {
delete process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY;
} else {
process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY = previousPublic;
}
}
});
});
+1 -1
View File
@@ -10,7 +10,7 @@ describe("useCaseTemplateDuplicateTitle", () => {
it("falls back when the source title is empty", () => {
expect(useCaseTemplateDuplicateTitle(" ")).toBe(
"Community Rule Template (Copy)",
"CommunityRule Template (Copy)",
);
});
});
@@ -153,6 +153,7 @@ describe("POST /api/user/email-change/request", () => {
expect(sendEmailChangeEmailMock).toHaveBeenCalledWith(
"new@x.com",
expect.stringContaining("/api/user/email-change/verify?token="),
"https://x.test",
);
});
+3
View File
@@ -1,4 +1,7 @@
import "@testing-library/jest-dom/vitest";
// Tests exercise the policy as staging will: on. Production leaves this unset.
process.env.ENABLE_PRIVACY_POLICY ??= "true";
import "./tests/mocks/navigation";
import React from "react";
import { afterAll, afterEach, beforeAll, vi } from "vitest";