Give finished Rules a print path, folded launch counts, and a two-day follow-up.
Export is PDF, RULE.md, and Print on US Letter, with every shared term, no member names, and a takeaway that points at Ask an organizer. Finished Rules keep type and place so the team can read folded counts without a database, Umami can sit beside the app with no cookies, and the person who holds the pen gets working PDF and RULE.md links 48 hours later.
This commit is contained in:
1 parent
0efc907633
commit
d9c475a967
74 files changed
+2401
-630
No files matched your search
@@ -0,0 +1,196 @@
|
||||
import { ASSETS, getAssetPath } from "../assetUtils";
|
||||
import { communityPossessive } from "../create/ruleInviteCardMeta";
|
||||
import { RULE_MD_FILENAME } from "../create/ruleExportModel";
|
||||
|
||||
export const RULE_FOLLOW_UP_LOGO_PATH = getAssetPath(ASSETS.LOGO_MARK);
|
||||
|
||||
export type RuleFollowUpMailInput = {
|
||||
to: string;
|
||||
origin: string;
|
||||
communityName: string;
|
||||
pdfUrl: string;
|
||||
markdownUrl: string;
|
||||
};
|
||||
|
||||
export type RuleFollowUpMailContent = {
|
||||
subject: string;
|
||||
previewText: string;
|
||||
text: string;
|
||||
html: string;
|
||||
};
|
||||
|
||||
function escapeHtml(value: string): string {
|
||||
return value
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """);
|
||||
}
|
||||
|
||||
function originHost(origin: string): string {
|
||||
try {
|
||||
return new URL(origin).host;
|
||||
} catch {
|
||||
return origin.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
||||
}
|
||||
}
|
||||
|
||||
export function buildRuleFollowUpMail(
|
||||
input: RuleFollowUpMailInput,
|
||||
): RuleFollowUpMailContent {
|
||||
const communityName = input.communityName.trim() || "A community";
|
||||
const possessive = communityPossessive(communityName);
|
||||
const origin = input.origin.replace(/\/$/, "");
|
||||
const kitUrl = `${origin}/kit`;
|
||||
const host = originHost(origin);
|
||||
const subject = `${possessive} Rule, printed`;
|
||||
const previewText = `Here is ${possessive} Rule as a PDF, ready to print.`;
|
||||
const intro = `Here is ${possessive} Rule as a PDF, ready to print or drop into your onboarding doc.`;
|
||||
const putIt =
|
||||
"Put it where members will see it, on the wall where you meet or at the top of the doc new members read.";
|
||||
const fixNow =
|
||||
"If anything in it already feels wrong, that is normal, and it is easier to fix now than in a year.";
|
||||
const officeHours = `Bring it to office hours if you want a second read. No signup, and the next one is listed at ${host}/kit.`;
|
||||
const signOff = "CommunityRule";
|
||||
const why = `Sent because you finished a Rule at ${host}.`;
|
||||
const madeBy =
|
||||
"CommunityRule is made by the Media Economies Design Lab at the University of Colorado Boulder.";
|
||||
const privacyUrl = `${origin}/privacy`;
|
||||
const aboutUrl = `${origin}/about`;
|
||||
const logoUrl = `${origin}${RULE_FOLLOW_UP_LOGO_PATH}`;
|
||||
|
||||
const text = [
|
||||
"Your Rule is ready to print",
|
||||
"",
|
||||
intro,
|
||||
"",
|
||||
"Download the PDF",
|
||||
input.pdfUrl,
|
||||
"",
|
||||
`Or download ${RULE_MD_FILENAME} for a wiki or a repository.`,
|
||||
input.markdownUrl,
|
||||
"",
|
||||
putIt,
|
||||
"",
|
||||
fixNow,
|
||||
"",
|
||||
officeHours,
|
||||
kitUrl,
|
||||
"",
|
||||
signOff,
|
||||
"",
|
||||
why,
|
||||
"",
|
||||
madeBy,
|
||||
`Privacy ${privacyUrl}`,
|
||||
].join("\n");
|
||||
|
||||
const html = followUpHtml({
|
||||
subject,
|
||||
previewText,
|
||||
intro,
|
||||
pdfUrl: input.pdfUrl,
|
||||
markdownUrl: input.markdownUrl,
|
||||
putIt,
|
||||
fixNow,
|
||||
officeHours,
|
||||
kitUrl,
|
||||
signOff,
|
||||
why,
|
||||
madeBy,
|
||||
privacyUrl,
|
||||
aboutUrl,
|
||||
logoUrl,
|
||||
kitHostPath: `${host}/kit`,
|
||||
});
|
||||
|
||||
return { subject, previewText, text, html };
|
||||
}
|
||||
|
||||
function followUpHtml(opts: {
|
||||
subject: string;
|
||||
previewText: string;
|
||||
intro: string;
|
||||
pdfUrl: string;
|
||||
markdownUrl: string;
|
||||
putIt: string;
|
||||
fixNow: string;
|
||||
officeHours: string;
|
||||
kitUrl: string;
|
||||
signOff: string;
|
||||
why: string;
|
||||
madeBy: string;
|
||||
privacyUrl: string;
|
||||
aboutUrl: string;
|
||||
logoUrl: string;
|
||||
kitHostPath: string;
|
||||
}): string {
|
||||
const pdfHref = escapeHtml(opts.pdfUrl);
|
||||
const mdHref = escapeHtml(opts.markdownUrl);
|
||||
const kitHref = escapeHtml(opts.kitUrl);
|
||||
const kitHostPath = escapeHtml(opts.kitHostPath);
|
||||
const officeLead = "Bring it to office hours if you want a second read. No signup, and the next one is listed at ";
|
||||
const officeHtml = opts.officeHours.startsWith(officeLead)
|
||||
? `${escapeHtml(officeLead)}<a href="${kitHref}" style="color:#000000;text-decoration:underline;">${kitHostPath}</a>.`
|
||||
: escapeHtml(opts.officeHours);
|
||||
|
||||
return `<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<title>${escapeHtml(opts.subject)}</title>
|
||||
</head>
|
||||
<body style="margin:0;padding:0;background:#e4e4e4;">
|
||||
<div style="display:none;max-height:0;overflow:hidden;mso-hide:all;">${escapeHtml(
|
||||
opts.previewText,
|
||||
)}</div>
|
||||
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:#e4e4e4;">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<table role="presentation" width="600" cellpadding="0" cellspacing="0" style="width:600px;max-width:600px;background:#ffffff;">
|
||||
<tr>
|
||||
<td style="background:#000000;padding:24px 32px;">
|
||||
<table role="presentation" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td style="font-family:'Bricolage Grotesque',Arial,sans-serif;font-size:22px;line-height:27px;color:#ffffff;padding-right:6px;">CommunityRule</td>
|
||||
<td>
|
||||
<img src="${escapeHtml(opts.logoUrl)}" width="27" height="27" alt="" style="display:block;border:0;width:27px;height:27px;" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:40px 32px 56px;">
|
||||
<h1 style="margin:0 0 16px;font-family:'Bricolage Grotesque',Arial,sans-serif;font-size:36px;line-height:44px;font-weight:700;color:#000000;">Your Rule is ready to print</h1>
|
||||
<p style="margin:0 0 32px;font-family:Inter,Arial,sans-serif;font-size:18px;line-height:24px;color:#303030;">${escapeHtml(opts.intro)}</p>
|
||||
<p style="margin:0 0 16px;">
|
||||
<a href="${pdfHref}" 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;">Download the PDF</a>
|
||||
</p>
|
||||
<p style="margin:0 0 32px;font-family:Inter,Arial,sans-serif;font-size:14px;line-height:20px;color:#464646;">
|
||||
Or download <a href="${mdHref}" style="color:#000000;text-decoration:underline;">${RULE_MD_FILENAME}</a> for a wiki or a repository.
|
||||
</p>
|
||||
<div style="height:1px;background:#e4e4e4;margin:0 0 32px;"></div>
|
||||
<p style="margin:0 0 20px;font-family:Inter,Arial,sans-serif;font-size:16px;line-height:24px;color:#303030;">${escapeHtml(opts.putIt)}</p>
|
||||
<p style="margin:0 0 20px;font-family:Inter,Arial,sans-serif;font-size:16px;line-height:24px;color:#303030;">${escapeHtml(opts.fixNow)}</p>
|
||||
<p style="margin:0 0 20px;font-family:Inter,Arial,sans-serif;font-size:16px;line-height:24px;color:#303030;">${officeHtml}</p>
|
||||
<p style="margin:0 0 32px;font-family:Inter,Arial,sans-serif;font-size:16px;line-height:24px;color:#000000;">${escapeHtml(opts.signOff)}</p>
|
||||
<div style="border-top:1px solid #e4e4e4;padding-top:24px;">
|
||||
<p style="margin:0 0 12px;font-family:Inter,Arial,sans-serif;font-size:14px;line-height:20px;color:#464646;">${escapeHtml(opts.why)}</p>
|
||||
<p style="margin:0 0 12px;font-family:Inter,Arial,sans-serif;font-size:14px;line-height:20px;color:#464646;">${escapeHtml(opts.madeBy)}</p>
|
||||
<p style="margin:0;font-family:Inter,Arial,sans-serif;font-size:14px;line-height:20px;color:#464646;">
|
||||
<a href="${escapeHtml(opts.privacyUrl)}" style="color:#464646;text-decoration:underline;">Privacy</a>
|
||||
|
||||
<a href="${escapeHtml(opts.aboutUrl)}" style="color:#464646;text-decoration:underline;">About CommunityRule</a>
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
Reference in new issue
Block a user