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:
commit
2dfc365dbd
53 files changed
+894
-181
No files matched your search
@@ -15,6 +15,12 @@ SESSION_SECRET="dev-only-change-me-16chars-min"
|
|||||||
# Leave mail vars unset in dev to log the magic-link verify URL to the server console instead of sending email.
|
# Leave mail vars unset in dev to log the magic-link verify URL to the server console instead of sending email.
|
||||||
SMTP_FROM="CommunityRule <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).
|
# CR-107: inbox for Ask an organizer form submissions (requires CLOUDRON_MAIL_SMTP_* in production).
|
||||||
ORGANIZER_INQUIRY_TO=
|
ORGANIZER_INQUIRY_TO=
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { MessagesProvider } from "../contexts/MessagesContext";
|
|||||||
import { AuthModalProvider } from "../contexts/AuthModalContext";
|
import { AuthModalProvider } from "../contexts/AuthModalContext";
|
||||||
import messages from "../../messages/en/index";
|
import messages from "../../messages/en/index";
|
||||||
import { MAIN_CONTENT_ID } from "../../lib/mainContent";
|
import { MAIN_CONTENT_ID } from "../../lib/mainContent";
|
||||||
|
import { isPrivacyPolicyEnabled } from "../../lib/privacyPolicyEnabled";
|
||||||
import { NO_INDEX_ROBOTS } from "../../lib/siteMetadata";
|
import { NO_INDEX_ROBOTS } from "../../lib/siteMetadata";
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
@@ -21,7 +22,7 @@ export const metadata: Metadata = {
|
|||||||
export default function AdminLayout({ children }: { children: ReactNode }) {
|
export default function AdminLayout({ children }: { children: ReactNode }) {
|
||||||
return (
|
return (
|
||||||
<MessagesProvider messages={messages}>
|
<MessagesProvider messages={messages}>
|
||||||
<AuthModalProvider>
|
<AuthModalProvider privacyEnabled={isPrivacyPolicyEnabled()}>
|
||||||
<SkipToContent />
|
<SkipToContent />
|
||||||
<Suspense fallback={null}>
|
<Suspense fallback={null}>
|
||||||
<ConditionalNavigation />
|
<ConditionalNavigation />
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { MessagesProvider } from "../contexts/MessagesContext";
|
|||||||
import { AuthModalProvider } from "../contexts/AuthModalContext";
|
import { AuthModalProvider } from "../contexts/AuthModalContext";
|
||||||
import messages from "../../messages/en/index";
|
import messages from "../../messages/en/index";
|
||||||
import { MAIN_CONTENT_ID } from "../../lib/mainContent";
|
import { MAIN_CONTENT_ID } from "../../lib/mainContent";
|
||||||
|
import { isPrivacyPolicyEnabled } from "../../lib/privacyPolicyEnabled";
|
||||||
import { NO_INDEX_ROBOTS } from "../../lib/siteMetadata";
|
import { NO_INDEX_ROBOTS } from "../../lib/siteMetadata";
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
@@ -28,7 +29,7 @@ export const metadata: Metadata = {
|
|||||||
export default function AppLayout({ children }: { children: ReactNode }) {
|
export default function AppLayout({ children }: { children: ReactNode }) {
|
||||||
return (
|
return (
|
||||||
<MessagesProvider messages={messages}>
|
<MessagesProvider messages={messages}>
|
||||||
<AuthModalProvider>
|
<AuthModalProvider privacyEnabled={isPrivacyPolicyEnabled()}>
|
||||||
<SkipToContent />
|
<SkipToContent />
|
||||||
<Suspense fallback={null}>
|
<Suspense fallback={null}>
|
||||||
<ConditionalNavigation />
|
<ConditionalNavigation />
|
||||||
|
|||||||
@@ -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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,64 +1,6 @@
|
|||||||
"use client";
|
import { isPrivacyPolicyEnabled } from "../../../lib/privacyPolicyEnabled";
|
||||||
|
import LoginPageClient from "./LoginPageClient";
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
return (
|
return <LoginPageClient privacyEnabled={isPrivacyPolicyEnabled()} />;
|
||||||
<Suspense fallback={<LoginLoadingFallback />}>
|
|
||||||
<LoginWithSearchParams />
|
|
||||||
</Suspense>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ import { MessagesProvider } from "../contexts/MessagesContext";
|
|||||||
import { AuthModalProvider } from "../contexts/AuthModalContext";
|
import { AuthModalProvider } from "../contexts/AuthModalContext";
|
||||||
import messages from "../../messages/en/index";
|
import messages from "../../messages/en/index";
|
||||||
import { MAIN_CONTENT_ID } from "../../lib/mainContent";
|
import { MAIN_CONTENT_ID } from "../../lib/mainContent";
|
||||||
|
import { isPrivacyPolicyEnabled } from "../../lib/privacyPolicyEnabled";
|
||||||
import { NO_INDEX_ROBOTS } from "../../lib/siteMetadata";
|
import { NO_INDEX_ROBOTS } from "../../lib/siteMetadata";
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
@@ -18,7 +19,7 @@ export default function DevLayout({ children }: { children: ReactNode }) {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<MessagesProvider messages={messages}>
|
<MessagesProvider messages={messages}>
|
||||||
<AuthModalProvider>
|
<AuthModalProvider privacyEnabled={isPrivacyPolicyEnabled()}>
|
||||||
<main
|
<main
|
||||||
id={MAIN_CONTENT_ID}
|
id={MAIN_CONTENT_ID}
|
||||||
tabIndex={-1}
|
tabIndex={-1}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
} from "../../../lib/legalSyntheticPost";
|
} from "../../../lib/legalSyntheticPost";
|
||||||
import { getRequestSiteOrigin } from "../../../lib/requestSiteOrigin";
|
import { getRequestSiteOrigin } from "../../../lib/requestSiteOrigin";
|
||||||
import { absoluteSiteUrl } from "../../../lib/siteMetadata";
|
import { absoluteSiteUrl } from "../../../lib/siteMetadata";
|
||||||
|
import { isPrivacyPolicyEnabled } from "../../../lib/privacyPolicyEnabled";
|
||||||
import ContentBanner from "../../components/sections/ContentBanner";
|
import ContentBanner from "../../components/sections/ContentBanner";
|
||||||
|
|
||||||
type LegalDocumentPageProps = {
|
type LegalDocumentPageProps = {
|
||||||
@@ -45,7 +46,9 @@ function LegalInlineText({ text }: { text: string }) {
|
|||||||
|
|
||||||
const label = match[1];
|
const label = match[1];
|
||||||
const href = match[2];
|
const href = match[2];
|
||||||
if (isSafeHref(href)) {
|
if (href === "/privacy" && !isPrivacyPolicyEnabled()) {
|
||||||
|
nodes.push(label);
|
||||||
|
} else if (isSafeHref(href)) {
|
||||||
const isInternal = href.startsWith("/") && !href.startsWith("//");
|
const isInternal = href.startsWith("/") && !href.startsWith("//");
|
||||||
nodes.push(
|
nodes.push(
|
||||||
isInternal ? (
|
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
|
* Figma: "Content page Template" (19003:23305) — ContentBanner guide
|
||||||
* (22078:806964) + article column (19003:23574). Body stacks follow
|
* (22078:806964) + article column (19003:23574). Body stacks follow
|
||||||
|
|||||||
@@ -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. */
|
const SLUG = "kit" as const;
|
||||||
export default function KitPage() {
|
const PATH = legalPathForSlug(SLUG);
|
||||||
redirect("/workshops");
|
|
||||||
|
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} />
|
||||||
|
);
|
||||||
}
|
}
|
||||||
@@ -5,12 +5,13 @@ import SkipToContent from "../components/navigation/SkipToContent";
|
|||||||
import { MessagesProvider } from "../contexts/MessagesContext";
|
import { MessagesProvider } from "../contexts/MessagesContext";
|
||||||
import { AuthModalProvider } from "../contexts/AuthModalContext";
|
import { AuthModalProvider } from "../contexts/AuthModalContext";
|
||||||
import { MAIN_CONTENT_ID } from "../../lib/mainContent";
|
import { MAIN_CONTENT_ID } from "../../lib/mainContent";
|
||||||
|
import { isPrivacyPolicyEnabled } from "../../lib/privacyPolicyEnabled";
|
||||||
import marketingMessages from "../../messages/en/marketing";
|
import marketingMessages from "../../messages/en/marketing";
|
||||||
|
|
||||||
export default function MarketingLayout({ children }: { children: ReactNode }) {
|
export default function MarketingLayout({ children }: { children: ReactNode }) {
|
||||||
return (
|
return (
|
||||||
<MessagesProvider messages={marketingMessages}>
|
<MessagesProvider messages={marketingMessages}>
|
||||||
<AuthModalProvider>
|
<AuthModalProvider privacyEnabled={isPrivacyPolicyEnabled()}>
|
||||||
{/*
|
{/*
|
||||||
* Same session-aware shell as `(app)` / `(admin)`: `ConditionalNavigation`
|
* Same session-aware shell as `(app)` / `(admin)`: `ConditionalNavigation`
|
||||||
* reads the cookie behind Suspense so the static page shell can prerender
|
* reads the cookie behind Suspense so the static page shell can prerender
|
||||||
|
|||||||
@@ -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} />
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -3,8 +3,10 @@
|
|||||||
* https://www.figma.com/design/agv0VBLiBlcnSAaiAORgPR/Community-Rule-System?node-id=19003-23305
|
* https://www.figma.com/design/agv0VBLiBlcnSAaiAORgPR/Community-Rule-System?node-id=19003-23305
|
||||||
*/
|
*/
|
||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
|
import { notFound } from "next/navigation";
|
||||||
import messages from "../../../messages/en/index";
|
import messages from "../../../messages/en/index";
|
||||||
import { legalPathForSlug } from "../../../lib/legalSyntheticPost";
|
import { legalPathForSlug } from "../../../lib/legalSyntheticPost";
|
||||||
|
import { isPrivacyPolicyEnabled } from "../../../lib/privacyPolicyEnabled";
|
||||||
import { routeMetadata } from "../../../lib/siteMetadata";
|
import { routeMetadata } from "../../../lib/siteMetadata";
|
||||||
import LegalDocumentPage, {
|
import LegalDocumentPage, {
|
||||||
legalPageMetadata,
|
legalPageMetadata,
|
||||||
@@ -14,6 +16,7 @@ const SLUG = "privacy" as const;
|
|||||||
const PATH = legalPathForSlug(SLUG);
|
const PATH = legalPathForSlug(SLUG);
|
||||||
|
|
||||||
export function generateMetadata(): Metadata {
|
export function generateMetadata(): Metadata {
|
||||||
|
if (!isPrivacyPolicyEnabled()) notFound();
|
||||||
return routeMetadata(
|
return routeMetadata(
|
||||||
PATH,
|
PATH,
|
||||||
legalPageMetadata(messages.metadata.privacy, messages.pages.privacy),
|
legalPageMetadata(messages.metadata.privacy, messages.pages.privacy),
|
||||||
@@ -21,6 +24,7 @@ export function generateMetadata(): Metadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function PrivacyPage() {
|
export default function PrivacyPage() {
|
||||||
|
if (!isPrivacyPolicyEnabled()) notFound();
|
||||||
return (
|
return (
|
||||||
<LegalDocumentPage
|
<LegalDocumentPage
|
||||||
slug={SLUG}
|
slug={SLUG}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import type { ReactNode } from "react";
|
|||||||
import { MessagesProvider } from "../contexts/MessagesContext";
|
import { MessagesProvider } from "../contexts/MessagesContext";
|
||||||
import { AuthModalProvider } from "../contexts/AuthModalContext";
|
import { AuthModalProvider } from "../contexts/AuthModalContext";
|
||||||
import { MAIN_CONTENT_ID } from "../../lib/mainContent";
|
import { MAIN_CONTENT_ID } from "../../lib/mainContent";
|
||||||
|
import { isPrivacyPolicyEnabled } from "../../lib/privacyPolicyEnabled";
|
||||||
import marketingMessages from "../../messages/en/marketing";
|
import marketingMessages from "../../messages/en/marketing";
|
||||||
|
|
||||||
/** Full-viewport case-study surfaces (completed rule demos) — no marketing footer. */
|
/** Full-viewport case-study surfaces (completed rule demos) — no marketing footer. */
|
||||||
@@ -12,7 +13,7 @@ export default function MarketingCaseStudyLayout({
|
|||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<MessagesProvider messages={marketingMessages}>
|
<MessagesProvider messages={marketingMessages}>
|
||||||
<AuthModalProvider>
|
<AuthModalProvider privacyEnabled={isPrivacyPolicyEnabled()}>
|
||||||
<main
|
<main
|
||||||
id={MAIN_CONTENT_ID}
|
id={MAIN_CONTENT_ID}
|
||||||
tabIndex={-1}
|
tabIndex={-1}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
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 { rateLimitKey } from "../../../lib/server/rateLimit";
|
||||||
import {
|
import {
|
||||||
errorJson,
|
errorJson,
|
||||||
@@ -66,7 +69,7 @@ export const POST = apiRoute(SCOPE, async (request: NextRequest, _ctx, { request
|
|||||||
return serverMisconfigured("ORGANIZER_INQUIRY_TO is not configured");
|
return serverMisconfigured("ORGANIZER_INQUIRY_TO is not configured");
|
||||||
}
|
}
|
||||||
|
|
||||||
const from = process.env.SMTP_FROM ?? "noreply@localhost";
|
const from = resolveMailFrom();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await sendOrganizerInquiryNotification({
|
await sendOrganizerInquiryNotification({
|
||||||
|
|||||||
@@ -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)}`;
|
const verifyUrl = `${origin}/api/user/email-change/verify?token=${encodeURIComponent(token)}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await sendEmailChangeEmail(newEmail, verifyUrl);
|
await sendEmailChangeEmail(newEmail, verifyUrl, origin);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logRouteError(SCOPE, requestId, err, { phase: "sendEmailChangeEmail" });
|
logRouteError(SCOPE, requestId, err, { phase: "sendEmailChangeEmail" });
|
||||||
await prisma.emailChangeToken.deleteMany({ where: { userId: user.id } });
|
await prisma.emailChangeToken.deleteMany({ where: { userId: user.id } });
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ export type LoginFormProps = {
|
|||||||
variant?: LoginFormVariant;
|
variant?: LoginFormVariant;
|
||||||
/** Overrides URL `next` for `requestMagicLink` (e.g. create-flow exit modal). */
|
/** Overrides URL `next` for `requestMagicLink` (e.g. create-flow exit modal). */
|
||||||
magicLinkNextPath?: string;
|
magicLinkNextPath?: string;
|
||||||
|
/** When false, the login legal line links terms only. */
|
||||||
|
privacyEnabled?: boolean;
|
||||||
/** `keepRule`: Continue without saving. */
|
/** `keepRule`: Continue without saving. */
|
||||||
onDismiss?: () => void;
|
onDismiss?: () => void;
|
||||||
/** Sent-state Close, and the dialog chrome close. */
|
/** Sent-state Close, and the dialog chrome close. */
|
||||||
@@ -120,6 +122,7 @@ export type LoginFormProps = {
|
|||||||
export default function LoginForm({
|
export default function LoginForm({
|
||||||
variant = "default",
|
variant = "default",
|
||||||
magicLinkNextPath,
|
magicLinkNextPath,
|
||||||
|
privacyEnabled = false,
|
||||||
onDismiss,
|
onDismiss,
|
||||||
onClose,
|
onClose,
|
||||||
}: LoginFormProps) {
|
}: LoginFormProps) {
|
||||||
@@ -365,6 +368,8 @@ export default function LoginForm({
|
|||||||
>
|
>
|
||||||
{tFooter("legal.termsOfService")}
|
{tFooter("legal.termsOfService")}
|
||||||
</Link>
|
</Link>
|
||||||
|
{privacyEnabled ? (
|
||||||
|
<>
|
||||||
{t("legalAnd")}
|
{t("legalAnd")}
|
||||||
<Link
|
<Link
|
||||||
href={tFooter("legal.privacyPolicyHref")}
|
href={tFooter("legal.privacyPolicyHref")}
|
||||||
@@ -372,6 +377,8 @@ export default function LoginForm({
|
|||||||
>
|
>
|
||||||
{tFooter("legal.privacyPolicy")}
|
{tFooter("legal.privacyPolicy")}
|
||||||
</Link>
|
</Link>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
{t("legalSuffix")}
|
{t("legalSuffix")}
|
||||||
</p>
|
</p>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -13,7 +13,13 @@ import { PRODUCTION_SITE_ORIGIN } from "../../../lib/siteMetadata";
|
|||||||
* Tiers: smallest viewports (below `md`), `md` through `lg`, `lg` and up.
|
* Tiers: smallest viewports (below `md`), `md` through `lg`, `lg` and up.
|
||||||
* Matches `--breakpoint-md: 640px`, `--breakpoint-lg: 1024px` in `app/tailwind.css`.
|
* 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 t = useTranslation("footer");
|
||||||
const tChrome = useTranslation("controlsChrome");
|
const tChrome = useTranslation("controlsChrome");
|
||||||
|
|
||||||
@@ -213,9 +219,11 @@ const Footer = memo(({ siteOrigin = PRODUCTION_SITE_ORIGIN }: { siteOrigin?: str
|
|||||||
<Link href={t("takeawayHref")} className={legalLinkClass}>
|
<Link href={t("takeawayHref")} className={legalLinkClass}>
|
||||||
{t("takeaway")}
|
{t("takeaway")}
|
||||||
</Link>
|
</Link>
|
||||||
|
{privacyEnabled ? (
|
||||||
<Link href={t("legal.privacyPolicyHref")} className={legalLinkClass}>
|
<Link href={t("legal.privacyPolicyHref")} className={legalLinkClass}>
|
||||||
{t("legal.privacyPolicy")}
|
{t("legal.privacyPolicy")}
|
||||||
</Link>
|
</Link>
|
||||||
|
) : null}
|
||||||
<Link href={t("legal.termsOfServiceHref")} className={legalLinkClass}>
|
<Link href={t("legal.termsOfServiceHref")} className={legalLinkClass}>
|
||||||
{t("legal.termsOfService")}
|
{t("legal.termsOfService")}
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
import Footer from "./Footer";
|
import Footer from "./Footer";
|
||||||
|
import { isPrivacyPolicyEnabled } from "../../../lib/privacyPolicyEnabled";
|
||||||
import { getRequestSiteOrigin } from "../../../lib/requestSiteOrigin";
|
import { getRequestSiteOrigin } from "../../../lib/requestSiteOrigin";
|
||||||
|
|
||||||
/** Footer JSON-LD uses the request origin, same host as the page canonical. */
|
/** Footer JSON-LD uses the request origin, same host as the page canonical. */
|
||||||
export default async function FooterWithOrigin() {
|
export default async function FooterWithOrigin() {
|
||||||
const siteOrigin = await getRequestSiteOrigin();
|
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}
|
{copy.body}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<Button href={href} size="small">
|
<Button href={href} size="small" className="self-start">
|
||||||
{copy.button}
|
{copy.button}
|
||||||
</Button>
|
</Button>
|
||||||
<p className="border-t border-[var(--color-border-default-secondary)] pt-6 text-[12px] leading-4 text-[var(--color-content-default-tertiary)]">
|
<p className="border-t border-[var(--color-border-default-secondary)] pt-6 text-[12px] leading-4 text-[var(--color-content-default-tertiary)]">
|
||||||
|
|||||||
@@ -39,7 +39,13 @@ type AuthModalContextValue = {
|
|||||||
|
|
||||||
const AuthModalContext = createContext<AuthModalContextValue | null>(null);
|
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 tLogin = useTranslation("pages.login");
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [opts, setOpts] = useState<OpenLoginOptions>({});
|
const [opts, setOpts] = useState<OpenLoginOptions>({});
|
||||||
@@ -93,6 +99,7 @@ export function AuthModalProvider({ children }: { children: ReactNode }) {
|
|||||||
<LoginForm
|
<LoginForm
|
||||||
variant={opts.variant ?? "default"}
|
variant={opts.variant ?? "default"}
|
||||||
magicLinkNextPath={opts.nextPath}
|
magicLinkNextPath={opts.nextPath}
|
||||||
|
privacyEnabled={privacyEnabled}
|
||||||
onDismiss={keepRuleDismiss}
|
onDismiss={keepRuleDismiss}
|
||||||
onClose={closeLogin}
|
onClose={closeLogin}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -75,8 +75,14 @@ per-app in the manifest and provisioned at install time.
|
|||||||
- `SESSION_SECRET` — long random (`openssl rand -hex 32`). Required,
|
- `SESSION_SECRET` — long random (`openssl rand -hex 32`). Required,
|
||||||
≥ 16 chars. Rotating it logs everyone out.
|
≥ 16 chars. Rotating it logs everyone out.
|
||||||
- `SMTP_FROM` — visible "From:" address on sign-in emails. Cloudron
|
- `SMTP_FROM` — visible "From:" address on sign-in emails. Cloudron
|
||||||
does not inject this. Use `hello@communityrule.info` (continuity
|
does not inject this. Use `CommunityRule <hello@communityrule.info>`
|
||||||
with the legacy service; SES relay accepts it).
|
(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
|
- `NEXT_PUBLIC_ENABLE_BACKEND_SYNC=true` — turns on Postgres draft
|
||||||
persistence for signed-in users. Required in production.
|
persistence for signed-in users. Required in production.
|
||||||
- `UPLOAD_ROOT` — absolute path to a writable directory on the Cloudron
|
- `UPLOAD_ROOT` — absolute path to a writable directory on the Cloudron
|
||||||
@@ -445,6 +451,7 @@ production env vars, and verify the vertical slice before apex cutover
|
|||||||
cloudron env set --app staging.communityrule.info \
|
cloudron env set --app staging.communityrule.info \
|
||||||
SESSION_SECRET="$(openssl rand -hex 32)" \
|
SESSION_SECRET="$(openssl rand -hex 32)" \
|
||||||
SMTP_FROM="CommunityRule <hello@communityrule.info>" \
|
SMTP_FROM="CommunityRule <hello@communityrule.info>" \
|
||||||
|
ENABLE_PRIVACY_POLICY=true \
|
||||||
NEXT_PUBLIC_ENABLE_BACKEND_SYNC=true \
|
NEXT_PUBLIC_ENABLE_BACKEND_SYNC=true \
|
||||||
UPLOAD_ROOT=/app/data/uploads
|
UPLOAD_ROOT=/app/data/uploads
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -246,7 +246,8 @@ persist across image updates unless changed:
|
|||||||
| Variable | Purpose |
|
| Variable | Purpose |
|
||||||
| -------- | ------- |
|
| -------- | ------- |
|
||||||
| `SESSION_SECRET` | Session cookie signing (≥ 16 chars). Rotating logs everyone out. |
|
| `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. |
|
| `NEXT_PUBLIC_ENABLE_BACKEND_SYNC` | `true` in staging/production — Postgres draft persistence. |
|
||||||
| `UPLOAD_ROOT` | `/app/data/uploads` on Cloudron — required for file uploads. |
|
| `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. |
|
| `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. |
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# Privacy policy facts
|
# Privacy policy facts
|
||||||
|
|
||||||
Numbers and hosting details the new privacy policy leaves in brackets.
|
Numbers and hosting details the new privacy policy leaves in brackets.
|
||||||
Live `/privacy` stays on the current page until university counsel has
|
Live `/privacy` stays behind `ENABLE_PRIVACY_POLICY` until university
|
||||||
read this text. Do not switch the route on from this file.
|
counsel has read this text. Do not switch the route on from this file.
|
||||||
|
|
||||||
## How long things are kept
|
## 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
|
- `/privacy` can show the new policy only after university counsel has
|
||||||
read it, including the Colorado Open Records Act line, Terms, Cookies,
|
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
|
- 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.
|
is after launch. Nothing about who can read Rules changes at launch.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { BlogPost } from "./content";
|
import type { BlogPost } from "./content";
|
||||||
|
|
||||||
export type LegalDocumentSlug = "privacy" | "terms" | "cookies";
|
export type LegalDocumentSlug = "privacy" | "terms" | "cookies" | "kit" | "press";
|
||||||
|
|
||||||
export type LegalDocumentSection = {
|
export type LegalDocumentSection = {
|
||||||
heading: string;
|
heading: string;
|
||||||
@@ -23,6 +23,8 @@ const PATH_BY_SLUG: Record<LegalDocumentSlug, string> = {
|
|||||||
privacy: "/privacy",
|
privacy: "/privacy",
|
||||||
terms: "/terms",
|
terms: "/terms",
|
||||||
cookies: "/cookies",
|
cookies: "/cookies",
|
||||||
|
kit: "/kit",
|
||||||
|
press: "/press",
|
||||||
};
|
};
|
||||||
|
|
||||||
export function legalPathForSlug(slug: LegalDocumentSlug): string {
|
export function legalPathForSlug(slug: LegalDocumentSlug): string {
|
||||||
|
|||||||
@@ -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`;
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { MetadataRoute } from "next";
|
import type { MetadataRoute } from "next";
|
||||||
import { getAllBlogPosts } from "./content";
|
import { getAllBlogPosts } from "./content";
|
||||||
|
import { isPrivacyPolicyEnabled } from "./privacyPolicyEnabled";
|
||||||
import { sitemapUrl } from "./siteMetadata";
|
import { sitemapUrl } from "./siteMetadata";
|
||||||
import { USE_CASE_DETAIL_SLUGS } from "./useCaseSyntheticPost";
|
import { USE_CASE_DETAIL_SLUGS } from "./useCaseSyntheticPost";
|
||||||
|
|
||||||
@@ -11,6 +12,8 @@ const STATIC_PUBLIC_PATHS = [
|
|||||||
"/templates",
|
"/templates",
|
||||||
"/blog",
|
"/blog",
|
||||||
"/how-it-works",
|
"/how-it-works",
|
||||||
|
"/kit",
|
||||||
|
"/press",
|
||||||
"/privacy",
|
"/privacy",
|
||||||
"/terms",
|
"/terms",
|
||||||
"/cookies",
|
"/cookies",
|
||||||
@@ -24,7 +27,9 @@ const STATIC_PUBLIC_PATHS = [
|
|||||||
export function buildPublicSitemap(
|
export function buildPublicSitemap(
|
||||||
listedRules: ReadonlyArray<{ id: string; updatedAt: Date }> = [],
|
listedRules: ReadonlyArray<{ id: string; updatedAt: Date }> = [],
|
||||||
): MetadataRoute.Sitemap {
|
): 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),
|
url: sitemapUrl(path),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
+75
-30
@@ -1,5 +1,6 @@
|
|||||||
import { ASSETS, getAssetPath } from "../assetUtils";
|
import { ASSETS, getAssetPath } from "../assetUtils";
|
||||||
import { MAGIC_LINK_TTL_MINUTES } from "../privacyRetention";
|
import { MAGIC_LINK_TTL_MINUTES } from "../privacyRetention";
|
||||||
|
import { mailLegalFooterHtml, mailLegalFooterUrls } from "./mailLegalFooter";
|
||||||
|
|
||||||
export const MAGIC_LINK_LOGO_PATH = getAssetPath(ASSETS.LOGO_MARK);
|
export const MAGIC_LINK_LOGO_PATH = getAssetPath(ASSETS.LOGO_MARK);
|
||||||
|
|
||||||
@@ -31,51 +32,54 @@ function originHost(origin: string): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildMagicLinkMail(
|
type BrandedVerifyMailCopy = {
|
||||||
input: MagicLinkMailInput,
|
verifyUrl: string;
|
||||||
|
origin: string;
|
||||||
|
subject: string;
|
||||||
|
previewText: string;
|
||||||
|
heading: string;
|
||||||
|
intro: string;
|
||||||
|
buttonLabel: string;
|
||||||
|
ignore: string;
|
||||||
|
why: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
function buildBrandedVerifyMail(
|
||||||
|
copy: BrandedVerifyMailCopy,
|
||||||
): MagicLinkMailContent {
|
): MagicLinkMailContent {
|
||||||
const origin = input.origin.replace(/\/$/, "");
|
const origin = copy.origin.replace(/\/$/, "");
|
||||||
const minutes = MAGIC_LINK_TTL_MINUTES;
|
const { aboutUrl, privacyUrl } = mailLegalFooterUrls(origin);
|
||||||
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 madeBy =
|
const madeBy =
|
||||||
"CommunityRule is made by the Media Economies Design Lab at the University of Colorado Boulder.";
|
"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 logoUrl = `${origin}${MAGIC_LINK_LOGO_PATH}`;
|
||||||
const host = originHost(origin);
|
const href = escapeHtml(copy.verifyUrl);
|
||||||
|
|
||||||
const text = [
|
const text = [
|
||||||
heading,
|
copy.heading,
|
||||||
"",
|
"",
|
||||||
intro,
|
copy.intro,
|
||||||
"",
|
"",
|
||||||
`Log in: ${input.verifyUrl}`,
|
`${copy.buttonLabel}: ${copy.verifyUrl}`,
|
||||||
"",
|
"",
|
||||||
ignore,
|
copy.ignore,
|
||||||
"",
|
"",
|
||||||
madeBy,
|
madeBy,
|
||||||
`Privacy ${privacyUrl}`,
|
...(privacyUrl ? [`Privacy ${privacyUrl}`] : []),
|
||||||
`About CommunityRule ${aboutUrl}`,
|
`About CommunityRule ${aboutUrl}`,
|
||||||
"",
|
"",
|
||||||
`Sent because you asked to log in at ${host}.`,
|
copy.why,
|
||||||
].join("\n");
|
].join("\n");
|
||||||
|
|
||||||
const href = escapeHtml(input.verifyUrl);
|
|
||||||
const html = `<!DOCTYPE html>
|
const html = `<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||||
<title>${escapeHtml(subject)}</title>
|
<title>${escapeHtml(copy.subject)}</title>
|
||||||
</head>
|
</head>
|
||||||
<body style="margin:0;padding:0;background:#e4e4e4;">
|
<body style="margin:0;padding:0;background:#e4e4e4;">
|
||||||
<div style="display:none;max-height:0;overflow:hidden;mso-hide:all;">${escapeHtml(
|
<div style="display:none;max-height:0;overflow:hidden;mso-hide:all;">${escapeHtml(
|
||||||
previewText,
|
copy.previewText,
|
||||||
)}</div>
|
)}</div>
|
||||||
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:#e4e4e4;">
|
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:#e4e4e4;">
|
||||||
<tr>
|
<tr>
|
||||||
@@ -95,19 +99,17 @@ export function buildMagicLinkMail(
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding:40px 32px 56px;">
|
<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>
|
<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(intro)}</p>
|
<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;">
|
<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>
|
</p>
|
||||||
<div style="height:1px;background:#e4e4e4;margin:0 0 32px;"></div>
|
<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;">
|
<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 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;">
|
<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>
|
${mailLegalFooterHtml(origin)}
|
||||||
|
|
||||||
<a href="${escapeHtml(aboutUrl)}" style="color:#464646;text-decoration:underline;">About CommunityRule</a>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@@ -119,5 +121,48 @@ export function buildMagicLinkMail(
|
|||||||
</body>
|
</body>
|
||||||
</html>`;
|
</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
@@ -5,8 +5,7 @@ import {
|
|||||||
buildWorkshopInboxMail,
|
buildWorkshopInboxMail,
|
||||||
type WorkshopInquiryMailInput,
|
type WorkshopInquiryMailInput,
|
||||||
} from "../workshopSignupMail";
|
} from "../workshopSignupMail";
|
||||||
import { MAGIC_LINK_TTL_MINUTES } from "../privacyRetention";
|
import { buildEmailChangeMail, buildMagicLinkMail } from "./magicLinkMail";
|
||||||
import { buildMagicLinkMail } from "./magicLinkMail";
|
|
||||||
import { getSmtpUrl } from "./env";
|
import { getSmtpUrl } from "./env";
|
||||||
import {
|
import {
|
||||||
buildRuleStakeholderInviteMail,
|
buildRuleStakeholderInviteMail,
|
||||||
@@ -26,12 +25,22 @@ function escapeHtml(value: string): string {
|
|||||||
.replace(/"/g, """);
|
.replace(/"/g, """);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 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 {
|
export function resolveMailFrom(): string {
|
||||||
return (
|
const raw =
|
||||||
process.env.SMTP_FROM?.trim() ||
|
process.env.SMTP_FROM?.trim() ||
|
||||||
process.env.CLOUDRON_MAIL_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. */
|
/** 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(
|
export async function sendEmailChangeEmail(
|
||||||
to: string,
|
to: string,
|
||||||
verifyUrl: string,
|
verifyUrl: string,
|
||||||
|
origin: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { text, html } = buildVerifyLinkParts(
|
const { subject, text, html } = buildEmailChangeMail({ verifyUrl, origin });
|
||||||
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",
|
|
||||||
);
|
|
||||||
await sendHtmlMail({
|
await sendHtmlMail({
|
||||||
to,
|
to,
|
||||||
subject: "Confirm your new Community Rule email",
|
subject,
|
||||||
text,
|
text,
|
||||||
html,
|
html,
|
||||||
devLog: `[dev] Email change verify for ${to}: ${verifyUrl}`,
|
devLog: `[dev] Email change verify for ${to}: ${verifyUrl}`,
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import { privacyPolicyUrl } from "../privacyPolicyEnabled";
|
||||||
|
|
||||||
|
function escapeHtml(value: string): string {
|
||||||
|
return value
|
||||||
|
.replace(/&/g, "&")
|
||||||
|
.replace(/</g, "<")
|
||||||
|
.replace(/>/g, ">")
|
||||||
|
.replace(/"/g, """);
|
||||||
|
}
|
||||||
|
|
||||||
|
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>
|
||||||
|
|
||||||
|
${about}`;
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { ASSETS, getAssetPath } from "../assetUtils";
|
import { ASSETS, getAssetPath } from "../assetUtils";
|
||||||
import { communityPossessive } from "../create/ruleInviteCardMeta";
|
import { communityPossessive } from "../create/ruleInviteCardMeta";
|
||||||
import { RULE_MD_FILENAME } from "../create/ruleExportModel";
|
import { RULE_MD_FILENAME } from "../create/ruleExportModel";
|
||||||
|
import { mailLegalFooterHtml, mailLegalFooterUrls } from "./mailLegalFooter";
|
||||||
|
|
||||||
export const RULE_FOLLOW_UP_LOGO_PATH = getAssetPath(ASSETS.LOGO_MARK);
|
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 why = `Sent because you finished a Rule at ${host}.`;
|
||||||
const madeBy =
|
const madeBy =
|
||||||
"CommunityRule is made by the Media Economies Design Lab at the University of Colorado Boulder.";
|
"CommunityRule is made by the Media Economies Design Lab at the University of Colorado Boulder.";
|
||||||
const privacyUrl = `${origin}/privacy`;
|
const { privacyUrl } = mailLegalFooterUrls(origin);
|
||||||
const aboutUrl = `${origin}/about`;
|
|
||||||
const logoUrl = `${origin}${RULE_FOLLOW_UP_LOGO_PATH}`;
|
const logoUrl = `${origin}${RULE_FOLLOW_UP_LOGO_PATH}`;
|
||||||
|
|
||||||
const text = [
|
const text = [
|
||||||
@@ -82,7 +82,7 @@ export function buildRuleFollowUpMail(
|
|||||||
why,
|
why,
|
||||||
"",
|
"",
|
||||||
madeBy,
|
madeBy,
|
||||||
`Privacy ${privacyUrl}`,
|
...(privacyUrl ? [`Privacy ${privacyUrl}`] : []),
|
||||||
].join("\n");
|
].join("\n");
|
||||||
|
|
||||||
const html = followUpHtml({
|
const html = followUpHtml({
|
||||||
@@ -98,8 +98,7 @@ export function buildRuleFollowUpMail(
|
|||||||
signOff,
|
signOff,
|
||||||
why,
|
why,
|
||||||
madeBy,
|
madeBy,
|
||||||
privacyUrl,
|
origin,
|
||||||
aboutUrl,
|
|
||||||
logoUrl,
|
logoUrl,
|
||||||
kitHostPath: `${host}/kit`,
|
kitHostPath: `${host}/kit`,
|
||||||
});
|
});
|
||||||
@@ -120,8 +119,7 @@ function followUpHtml(opts: {
|
|||||||
signOff: string;
|
signOff: string;
|
||||||
why: string;
|
why: string;
|
||||||
madeBy: string;
|
madeBy: string;
|
||||||
privacyUrl: string;
|
origin: string;
|
||||||
aboutUrl: string;
|
|
||||||
logoUrl: string;
|
logoUrl: string;
|
||||||
kitHostPath: string;
|
kitHostPath: string;
|
||||||
}): 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.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 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;">
|
<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>
|
${mailLegalFooterHtml(opts.origin)}
|
||||||
|
|
||||||
<a href="${escapeHtml(opts.aboutUrl)}" style="color:#464646;text-decoration:underline;">About CommunityRule</a>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ASSETS, getAssetPath } from "../assetUtils";
|
import { ASSETS, getAssetPath } from "../assetUtils";
|
||||||
|
import { mailLegalFooterHtml, mailLegalFooterUrls } from "./mailLegalFooter";
|
||||||
import {
|
import {
|
||||||
clipCommunityInviteDescription,
|
clipCommunityInviteDescription,
|
||||||
communityInviteInitials,
|
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 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 =
|
const madeBy =
|
||||||
"CommunityRule is made by the Media Economies Design Lab at the University of Colorado Boulder.";
|
"CommunityRule is made by the Media Economies Design Lab at the University of Colorado Boulder.";
|
||||||
const privacyUrl = `${origin}/privacy`;
|
const { privacyUrl } = mailLegalFooterUrls(origin);
|
||||||
const aboutUrl = `${origin}/about`;
|
|
||||||
const logoUrl = `${origin}${RULE_STAKEHOLDER_INVITE_LOGO_PATH}`;
|
const logoUrl = `${origin}${RULE_STAKEHOLDER_INVITE_LOGO_PATH}`;
|
||||||
|
|
||||||
const text = [
|
const text = [
|
||||||
@@ -106,7 +106,7 @@ export function buildRuleStakeholderInviteMail(
|
|||||||
why,
|
why,
|
||||||
"",
|
"",
|
||||||
madeBy,
|
madeBy,
|
||||||
`Privacy ${privacyUrl}`,
|
...(privacyUrl ? [`Privacy ${privacyUrl}`] : []),
|
||||||
].join("\n");
|
].join("\n");
|
||||||
|
|
||||||
const html = inviteHtml({
|
const html = inviteHtml({
|
||||||
@@ -123,8 +123,7 @@ export function buildRuleStakeholderInviteMail(
|
|||||||
copyLead,
|
copyLead,
|
||||||
why,
|
why,
|
||||||
madeBy,
|
madeBy,
|
||||||
privacyUrl,
|
origin,
|
||||||
aboutUrl,
|
|
||||||
logoUrl,
|
logoUrl,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -145,8 +144,7 @@ function inviteHtml(opts: {
|
|||||||
copyLead: string;
|
copyLead: string;
|
||||||
why: string;
|
why: string;
|
||||||
madeBy: string;
|
madeBy: string;
|
||||||
privacyUrl: string;
|
origin: string;
|
||||||
aboutUrl: string;
|
|
||||||
logoUrl: string;
|
logoUrl: string;
|
||||||
}): string {
|
}): string {
|
||||||
const heading = escapeHtml(opts.subject);
|
const heading = escapeHtml(opts.subject);
|
||||||
@@ -165,8 +163,6 @@ function inviteHtml(opts: {
|
|||||||
` of this one and change what does not fit.`;
|
` of this one and change what does not fit.`;
|
||||||
const why = escapeHtml(opts.why);
|
const why = escapeHtml(opts.why);
|
||||||
const madeBy = escapeHtml(opts.madeBy);
|
const madeBy = escapeHtml(opts.madeBy);
|
||||||
const privacyUrl = escapeHtml(opts.privacyUrl);
|
|
||||||
const aboutUrl = escapeHtml(opts.aboutUrl);
|
|
||||||
const logoUrl = escapeHtml(opts.logoUrl);
|
const logoUrl = escapeHtml(opts.logoUrl);
|
||||||
const cardBody = description
|
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>`
|
? `<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;">${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 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;">
|
<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>
|
${mailLegalFooterHtml(opts.origin)}
|
||||||
|
|
||||||
<a href="${aboutUrl}" style="color:#464646;text-decoration:underline;">About CommunityRule</a>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import useCasesDetail from "./pages/useCasesDetail.json";
|
|||||||
import useCasesCompletedRules from "./pages/useCasesCompletedRules.json";
|
import useCasesCompletedRules from "./pages/useCasesCompletedRules.json";
|
||||||
import useCasesCompletedRule from "./pages/useCasesCompletedRule.json";
|
import useCasesCompletedRule from "./pages/useCasesCompletedRule.json";
|
||||||
import howItWorks from "./pages/howItWorks.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 privacy from "./pages/privacy.json";
|
||||||
import terms from "./pages/terms.json";
|
import terms from "./pages/terms.json";
|
||||||
import cookies from "./pages/cookies.json";
|
import cookies from "./pages/cookies.json";
|
||||||
@@ -112,6 +114,8 @@ export default {
|
|||||||
useCasesCompletedRules,
|
useCasesCompletedRules,
|
||||||
useCasesCompletedRule,
|
useCasesCompletedRule,
|
||||||
howItWorks,
|
howItWorks,
|
||||||
|
kit,
|
||||||
|
press,
|
||||||
privacy,
|
privacy,
|
||||||
terms,
|
terms,
|
||||||
cookies,
|
cookies,
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ import useCasesDetail from "./pages/useCasesDetail.json";
|
|||||||
import useCasesCompletedRules from "./pages/useCasesCompletedRules.json";
|
import useCasesCompletedRules from "./pages/useCasesCompletedRules.json";
|
||||||
import useCasesCompletedRule from "./pages/useCasesCompletedRule.json";
|
import useCasesCompletedRule from "./pages/useCasesCompletedRule.json";
|
||||||
import howItWorks from "./pages/howItWorks.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 privacy from "./pages/privacy.json";
|
||||||
import terms from "./pages/terms.json";
|
import terms from "./pages/terms.json";
|
||||||
import cookies from "./pages/cookies.json";
|
import cookies from "./pages/cookies.json";
|
||||||
@@ -84,6 +86,8 @@ const marketingMessages = {
|
|||||||
useCasesCompletedRules,
|
useCasesCompletedRules,
|
||||||
useCasesCompletedRule,
|
useCasesCompletedRule,
|
||||||
howItWorks,
|
howItWorks,
|
||||||
|
kit,
|
||||||
|
press,
|
||||||
privacy,
|
privacy,
|
||||||
terms,
|
terms,
|
||||||
cookies,
|
cookies,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
},
|
},
|
||||||
"create": {
|
"create": {
|
||||||
"title": "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": {
|
"blog": {
|
||||||
"title": "Blog",
|
"title": "Blog",
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"title": "Profile",
|
"title": "Profile",
|
||||||
"description": "Manage your CommunityRules, saved progress, and account."
|
"description": "Manage the Rules you have finished, saved progress, and your account."
|
||||||
},
|
},
|
||||||
"monitor": {
|
"monitor": {
|
||||||
"title": "Monitor",
|
"title": "Monitor",
|
||||||
@@ -117,8 +117,8 @@
|
|||||||
},
|
},
|
||||||
"useCasesCompletedRule": {
|
"useCasesCompletedRule": {
|
||||||
"mutualAidColorado": {
|
"mutualAidColorado": {
|
||||||
"title": "Mutual Aid Colorado community rule",
|
"title": "Mutual Aid Colorado CommunityRule",
|
||||||
"description": "Read the completed community rule Mutual Aid Colorado built with CommunityRule.",
|
"description": "Read the completed Rule Mutual Aid Colorado built with CommunityRule.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"mutual aid",
|
"mutual aid",
|
||||||
"community rule",
|
"community rule",
|
||||||
@@ -127,8 +127,8 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"foodNotBombs": {
|
"foodNotBombs": {
|
||||||
"title": "Food Not Bombs Boulder community rule",
|
"title": "Food Not Bombs Boulder CommunityRule",
|
||||||
"description": "Read the completed community rule Food Not Bombs Boulder built with CommunityRule.",
|
"description": "Read the completed Rule Food Not Bombs Boulder built with CommunityRule.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"food not bombs",
|
"food not bombs",
|
||||||
"community rule",
|
"community rule",
|
||||||
@@ -137,8 +137,8 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"boulderCountyStreetMedics": {
|
"boulderCountyStreetMedics": {
|
||||||
"title": "Boulder Street Medics community rule",
|
"title": "Boulder Street Medics CommunityRule",
|
||||||
"description": "Read the completed community rule Boulder Street Medics built with CommunityRule.",
|
"description": "Read the completed Rule Boulder Street Medics built with CommunityRule.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"street medics",
|
"street medics",
|
||||||
"community rule",
|
"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": {
|
"howItWorks": {
|
||||||
"title": "When your community sits down to write its Rule",
|
"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.",
|
"description": "Sketch your Rule in CommunityRule, then make it your community's own over five short meetings.",
|
||||||
@@ -169,7 +179,7 @@
|
|||||||
},
|
},
|
||||||
"cookies": {
|
"cookies": {
|
||||||
"title": "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"]
|
"keywords": ["cookies", "session", "privacy", "communityrule"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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.",
|
"_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": {
|
"banner": {
|
||||||
"title": "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.",
|
||||||
"author": "Media Economies Design Lab",
|
"author": "Media Economies Design Lab",
|
||||||
"date": "2026-08-15"
|
"date": "2026-08-15"
|
||||||
},
|
},
|
||||||
"updated": "Last updated August 15, 2026.",
|
"updated": "Last updated August 15, 2026.",
|
||||||
"intro": [
|
"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": [
|
"sections": [
|
||||||
{
|
{
|
||||||
"heading": "The session cookie",
|
"heading": "The session cookie",
|
||||||
"paragraphs": [
|
"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.",
|
"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."
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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)."
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -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."
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -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": {
|
"banner": {
|
||||||
"title": "Privacy Policy",
|
"title": "Privacy Policy",
|
||||||
"description": "What we collect, where it is stored, and how template recommendations work.",
|
"description": "What we collect, where it is stored, and how template recommendations work.",
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
{
|
{
|
||||||
"heading": "What we collect",
|
"heading": "What we collect",
|
||||||
"paragraphs": [
|
"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."
|
"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",
|
"heading": "Recommendations",
|
||||||
"paragraphs": [
|
"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."
|
"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
|
// Interactive story for testing user interactions
|
||||||
export const Interactive = {
|
export const Interactive = {
|
||||||
|
args: {
|
||||||
|
privacyEnabled: true,
|
||||||
|
},
|
||||||
parameters: {
|
parameters: {
|
||||||
docs: {
|
docs: {
|
||||||
description: {
|
description: {
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ describe("Footer (behavioral tests)", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("renders legal links to privacy and terms pages", () => {
|
it("renders legal links to privacy and terms pages", () => {
|
||||||
render(<Footer />);
|
render(<Footer privacyEnabled />);
|
||||||
expect(
|
expect(
|
||||||
screen.getAllByRole("link", { name: "Privacy Policy" })[0],
|
screen.getAllByRole("link", { name: "Privacy Policy" })[0],
|
||||||
).toHaveAttribute("href", "/privacy");
|
).toHaveAttribute("href", "/privacy");
|
||||||
@@ -129,4 +129,14 @@ describe("Footer (behavioral tests)", () => {
|
|||||||
screen.queryByRole("link", { name: "Cookies Settings" }),
|
screen.queryByRole("link", { name: "Cookies Settings" }),
|
||||||
).not.toBeInTheDocument();
|
).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");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@@ -78,7 +78,11 @@ describe("LoginForm", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("links terms and privacy to the legal pages", () => {
|
it("links terms and privacy to the legal pages", () => {
|
||||||
renderLoginForm();
|
renderWithProviders(
|
||||||
|
<Suspense fallback={null}>
|
||||||
|
<LoginForm privacyEnabled />
|
||||||
|
</Suspense>,
|
||||||
|
);
|
||||||
expect(
|
expect(
|
||||||
screen.getByRole("link", { name: "Terms of Service" }),
|
screen.getByRole("link", { name: "Terms of Service" }),
|
||||||
).toHaveAttribute("href", "/terms");
|
).toHaveAttribute("href", "/terms");
|
||||||
@@ -87,6 +91,16 @@ describe("LoginForm", () => {
|
|||||||
).toHaveAttribute("href", "/privacy");
|
).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 () => {
|
it("shows validation error when email is invalid", async () => {
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
renderLoginForm();
|
renderLoginForm();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ describe("Workshops page sections", () => {
|
|||||||
for (const link of links) {
|
for (const link of links) {
|
||||||
expect(link).toHaveAttribute("href", "#workshop-signup");
|
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", () => {
|
it("shows the full field set, one optional marker, and the settled challenge line", () => {
|
||||||
|
|||||||
@@ -17,4 +17,7 @@ vi.mock("next/navigation", () => ({
|
|||||||
useRouter: () => testRouter,
|
useRouter: () => testRouter,
|
||||||
usePathname: () => testPathname(),
|
usePathname: () => testPathname(),
|
||||||
useSearchParams: vi.fn(() => new URLSearchParams()),
|
useSearchParams: vi.fn(() => new URLSearchParams()),
|
||||||
|
notFound: () => {
|
||||||
|
throw new Error("NEXT_NOT_FOUND");
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
@@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -2,10 +2,14 @@ import { describe, expect, test, vi } from "vitest";
|
|||||||
import { screen } from "@testing-library/react";
|
import { screen } from "@testing-library/react";
|
||||||
import { renderWithProviders as render } from "../utils/test-utils";
|
import { renderWithProviders as render } from "../utils/test-utils";
|
||||||
import PrivacyPage from "../../app/(marketing)/privacy/page";
|
import PrivacyPage from "../../app/(marketing)/privacy/page";
|
||||||
import TermsPage from "../../app/(marketing)/terms/page";
|
import LegalDocumentPage from "../../app/(marketing)/_components/LegalDocumentPage";
|
||||||
import CookiesPage from "../../app/(marketing)/cookies/page";
|
import { legalPathForSlug } from "../../lib/legalSyntheticPost";
|
||||||
import messages from "../../messages/en/index";
|
import messages from "../../messages/en/index";
|
||||||
|
|
||||||
|
vi.mock("../../lib/requestSiteOrigin", () => ({
|
||||||
|
getRequestSiteOrigin: async () => "https://communityrule.info",
|
||||||
|
}));
|
||||||
|
|
||||||
vi.mock("../../app/components/sections/ContentBanner", () => ({
|
vi.mock("../../app/components/sections/ContentBanner", () => ({
|
||||||
default: ({ post, variant, updatedLabel }) => (
|
default: ({ post, variant, updatedLabel }) => (
|
||||||
<section data-testid="content-banner" data-variant={variant}>
|
<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", () => {
|
describe("legal document pages", () => {
|
||||||
test("privacy copy names Umami and cookieless counts", () => {
|
test("privacy copy names Umami and cookieless counts", () => {
|
||||||
const collect = messages.pages.privacy.sections.find(
|
const collect = messages.pages.privacy.sections.find(
|
||||||
@@ -30,8 +46,32 @@ describe("legal document pages", () => {
|
|||||||
expect(collect?.paragraphs.join(" ")).toMatch(/sets no cookies/);
|
expect(collect?.paragraphs.join(" ")).toMatch(/sets no cookies/);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("privacy page covers hosting, recommendations, and campus privacy", () => {
|
test("privacy copy does not say stakeholder or wizard", () => {
|
||||||
render(<PrivacyPage />);
|
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;
|
const page = messages.pages.privacy;
|
||||||
|
|
||||||
expect(screen.getByTestId("content-banner")).toHaveAttribute(
|
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", () => {
|
test("terms page covers licenses and the templates API, not ranking", async () => {
|
||||||
render(<TermsPage />);
|
await renderLegalPage("terms", messages.pages.terms);
|
||||||
const page = messages.pages.terms;
|
const page = messages.pages.terms;
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
@@ -105,8 +145,8 @@ describe("legal document pages", () => {
|
|||||||
).toHaveAttribute("href", "/api/templates");
|
).toHaveAttribute("href", "/api/templates");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("cookies settings page explains there are no optional cookies", () => {
|
test("cookies settings page explains there are no optional cookies", async () => {
|
||||||
render(<CookiesPage />);
|
await renderLegalPage("cookies", messages.pages.cookies);
|
||||||
const page = messages.pages.cookies;
|
const page = messages.pages.cookies;
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
@@ -115,11 +155,15 @@ describe("legal document pages", () => {
|
|||||||
expect(
|
expect(
|
||||||
screen.getByRole("heading", { level: 2, name: "The session cookie" }),
|
screen.getByRole("heading", { level: 2, name: "The session cookie" }),
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
|
expect(
|
||||||
|
screen.getByRole("heading", { level: 2, name: "The claim cookie" }),
|
||||||
|
).toBeInTheDocument();
|
||||||
expect(
|
expect(
|
||||||
screen.getByText(/There are no advertising or analytics cookies to turn off/),
|
screen.getByText(/There are no advertising or analytics cookies to turn off/),
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
expect(screen.getByText(/cr_session/)).toBeInTheDocument();
|
expect(screen.getByText(/cr_session/)).toBeInTheDocument();
|
||||||
expect(screen.getByText(/cr_rule_claim/)).toBeInTheDocument();
|
expect(screen.getByText(/cr_rule_claim/)).toBeInTheDocument();
|
||||||
|
expect(JSON.stringify(page)).not.toMatch(/magic link/i);
|
||||||
expect(
|
expect(
|
||||||
screen.getAllByRole("link", { name: "Privacy Policy" })[0],
|
screen.getAllByRole("link", { name: "Privacy Policy" })[0],
|
||||||
).toHaveAttribute("href", "/privacy");
|
).toHaveAttribute("href", "/privacy");
|
||||||
|
|||||||
@@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -9,6 +9,8 @@ describe("legalSyntheticPost", () => {
|
|||||||
expect(legalPathForSlug("privacy")).toBe("/privacy");
|
expect(legalPathForSlug("privacy")).toBe("/privacy");
|
||||||
expect(legalPathForSlug("terms")).toBe("/terms");
|
expect(legalPathForSlug("terms")).toBe("/terms");
|
||||||
expect(legalPathForSlug("cookies")).toBe("/cookies");
|
expect(legalPathForSlug("cookies")).toBe("/cookies");
|
||||||
|
expect(legalPathForSlug("kit")).toBe("/kit");
|
||||||
|
expect(legalPathForSlug("press")).toBe("/press");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("builds a guide-shaped post from page messages", () => {
|
it("builds a guide-shaped post from page messages", () => {
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import { MAGIC_LINK_TTL_MINUTES } from "../../lib/privacyRetention";
|
import { MAGIC_LINK_TTL_MINUTES } from "../../lib/privacyRetention";
|
||||||
import { buildMagicLinkMail } from "../../lib/server/magicLinkMail";
|
import {
|
||||||
|
buildEmailChangeMail,
|
||||||
|
buildMagicLinkMail,
|
||||||
|
} from "../../lib/server/magicLinkMail";
|
||||||
|
|
||||||
const VERIFY_URL =
|
const VERIFY_URL =
|
||||||
"https://communityrule.info/api/auth/magic-link/verify?token=abc";
|
"https://communityrule.info/api/auth/magic-link/verify?token=abc";
|
||||||
@@ -32,4 +35,46 @@ describe("buildMagicLinkMail", () => {
|
|||||||
expect(mail.html).not.toContain("Hi ");
|
expect(mail.html).not.toContain("Hi ");
|
||||||
expect(mail.text).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/);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
+10
-2
@@ -100,14 +100,22 @@ describe("resolveMailFrom", () => {
|
|||||||
it("prefers SMTP_FROM, then CLOUDRON_MAIL_FROM", () => {
|
it("prefers SMTP_FROM, then CLOUDRON_MAIL_FROM", () => {
|
||||||
delete process.env.SMTP_FROM;
|
delete process.env.SMTP_FROM;
|
||||||
delete process.env.CLOUDRON_MAIL_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";
|
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>";
|
process.env.SMTP_FROM = "Community Rule <hello@communityrule.info>";
|
||||||
expect(resolveMailFrom()).toBe(
|
expect(resolveMailFrom()).toBe(
|
||||||
"CommunityRule <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", () => ({
|
vi.mock("../../lib/server/mail", () => ({
|
||||||
sendOrganizerInquiryNotification: (...args: unknown[]) =>
|
sendOrganizerInquiryNotification: (...args: unknown[]) =>
|
||||||
sendOrganizerInquiryNotificationMock(...args),
|
sendOrganizerInquiryNotificationMock(...args),
|
||||||
|
resolveMailFrom: () => "CommunityRule <noreply@localhost>",
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const rateLimitKeyMock = vi.hoisted(() =>
|
const rateLimitKeyMock = vi.hoisted(() =>
|
||||||
@@ -54,6 +55,7 @@ describe("POST /api/organizer-inquiry", () => {
|
|||||||
expect(body).toEqual({ ok: true });
|
expect(body).toEqual({ ok: true });
|
||||||
expect(sendOrganizerInquiryNotificationMock).toHaveBeenCalledTimes(1);
|
expect(sendOrganizerInquiryNotificationMock).toHaveBeenCalledTimes(1);
|
||||||
const arg = sendOrganizerInquiryNotificationMock.mock.calls[0][0];
|
const arg = sendOrganizerInquiryNotificationMock.mock.calls[0][0];
|
||||||
|
expect(arg.fromEmail).toBe("CommunityRule <noreply@localhost>");
|
||||||
expect(arg.visitorEmail).toBe("visitor@example.com");
|
expect(arg.visitorEmail).toBe("visitor@example.com");
|
||||||
expect(arg.message).toBe("How do we run consensus meetings?");
|
expect(arg.message).toBe("How do we run consensus meetings?");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -16,6 +16,8 @@ describe("buildPublicSitemap", () => {
|
|||||||
expect(urls).toContain(sitemapUrl("/blog"));
|
expect(urls).toContain(sitemapUrl("/blog"));
|
||||||
expect(urls).not.toContain(sitemapUrl("/use-cases"));
|
expect(urls).not.toContain(sitemapUrl("/use-cases"));
|
||||||
expect(urls).toContain(sitemapUrl("/how-it-works"));
|
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("/privacy"));
|
||||||
expect(urls).toContain(sitemapUrl("/terms"));
|
expect(urls).toContain(sitemapUrl("/terms"));
|
||||||
expect(urls).toContain(sitemapUrl("/cookies"));
|
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("/create"))).toBe(false);
|
||||||
expect(urls.some((url) => url.includes("/monitor"))).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("/rule-counts"))).toBe(false);
|
||||||
expect(urls.some((url) => url.includes("/kit"))).toBe(false);
|
|
||||||
expect(urls.some((url) => url.includes("/api/"))).toBe(false);
|
expect(urls.some((url) => url.includes("/api/"))).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -54,4 +55,24 @@ describe("buildPublicSitemap", () => {
|
|||||||
lastModified: updatedAt,
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@@ -153,6 +153,7 @@ describe("POST /api/user/email-change/request", () => {
|
|||||||
expect(sendEmailChangeEmailMock).toHaveBeenCalledWith(
|
expect(sendEmailChangeEmailMock).toHaveBeenCalledWith(
|
||||||
"new@x.com",
|
"new@x.com",
|
||||||
expect.stringContaining("/api/user/email-change/verify?token="),
|
expect.stringContaining("/api/user/email-change/verify?token="),
|
||||||
|
"https://x.test",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import "@testing-library/jest-dom/vitest";
|
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 "./tests/mocks/navigation";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { afterAll, afterEach, beforeAll, vi } from "vitest";
|
import { afterAll, afterEach, beforeAll, vi } from "vitest";
|
||||||
|
|||||||
Reference in new issue
Block a user