Manual
Almnck.
Price: 50ⓐ

Membership Pages Implementation Plan

For Claude: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.

Goal: Implement three membership pages (Letter, Dossier, Standing) with navigation changes to create the “inherited membership” experience.

Architecture: Editorial markdown pages with custom CSS for theatrical styling, Django template partials for reusable components (margin-box, standing widget), client-side JavaScript hydration using existing identity.js API. Stripe integration deferred to separate API task.

Tech Stack: Django 5.0 + django-distill, HTMX (already loaded), existing identity.js, custom CSS with paper textures and transforms.

Design Doc: doc/process/plans/2026-01-19-membership-pages-design.md


Phase 1: Navigation Refactor

Task 1.1: Create Membership Margin-Box Partial

Files: - Create: src/almnck/templates/partials/_membership_margin.html - Create: web/static/css/membership-margin.css

Step 1: Write the partial template

Create src/almnck/templates/partials/_membership_margin.html:

<div class="membership-box" id="membership-box">
    <p class="membership-greeting">Welcome back,</p>
    <p class="membership-name" id="margin-member-name">stranger</p>

    <nav class="membership-links">
        <a href="/profile/">Your Dossier</a>
        <a href="/standing/">Your Standing</a>
    </nav>

    <p class="membership-nudge" id="membership-nudge" hidden>
        <a href="/membership/" id="nudge-link">Not <span id="nudge-name">stranger</span>?</a>
    </p>
</div>

Step 2: Write the CSS

Create web/static/css/membership-margin.css:

.membership-box {
    font-family: var(--font-body);
    font-size: 0.9rem;
    padding: 1rem;
    border: 1px solid var(--color-bg-edge);
    background: var(--color-bg);
    margin-bottom: 1.5rem;
}

.membership-greeting {
    margin: 0 0 0.25rem 0;
    font-style: italic;
    color: #666;
}

.membership-name {
    margin: 0 0 1rem 0;
    font-family: var(--font-display);
    font-size: 1.1rem;
    line-height: 1.2;
}

.membership-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.membership-links a {
    color: var(--color-text);
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
}

.membership-links a:hover {
    border-bottom-style: solid;
}

.membership-nudge {
    font-size: 0.85rem;
    margin: 0;
    padding-top: 0.5rem;
    border-top: 1px solid var(--color-bg-edge);
}

.membership-nudge a {
    color: #8b0000;
}

.membership-nudge.in-debt a {
    color: #8b0000;
    font-weight: bold;
}

.membership-nudge.good-standing {
    display: none;
}

Step 3: Commit

git add src/almnck/templates/partials/_membership_margin.html web/static/css/membership-margin.css
git commit -m "feat: add membership margin-box partial and styles"

Task 1.2: Update Base Template - Remove Dropdown, Add Margin-Box

Files: - Modify: src/almnck/templates/base.html - Modify: web/static/js/identity-dropdown.js (rename to identity-margin.js)

Step 1: Read current base.html to understand structure

Read src/almnck/templates/base.html lines 1-60 to see current masthead and identity widget.

Step 2: Modify masthead to remove dropdown trigger

In base.html, replace the identity-widget div (around lines 21-34) with simpler masthead:

<!-- Old: identity-greeting div with dropdown -->
<!-- New: Just the name as a link -->
<div class="identity-name-link">
    For: <a href="/profile/" id="member-name-link"><span id="member-name">stranger</span></a>
</div>

Step 3: Add margin-box include to margins-layout

In templates that use margins-layout, add to left margin:

<aside class="margin margin-left">
    {% include "partials/_membership_margin.html" %}
</aside>

Step 4: Link new CSS in base.html head

<link rel="stylesheet" href="{% static 'css/membership-margin.css' %}">

Step 5: Rename and simplify identity-dropdown.js to identity-margin.js

Rename web/static/js/identity-dropdown.js to web/static/js/identity-margin.js and simplify to update margin-box instead of dropdown:

// identity-margin.js - Updates membership margin-box with member data
(function() {
    'use strict';

    function updateMarginBox(profile) {
        const nameEl = document.getElementById('margin-member-name');
        const nudgeEl = document.getElementById('membership-nudge');
        const nudgeNameEl = document.getElementById('nudge-name');
        const nudgeLinkEl = document.getElementById('nudge-link');
        const headerNameEl = document.getElementById('member-name');

        const name = profile.name || 'stranger';
        const balance = profile.balance || 0;
        const hasPaid = profile.has_paid || false;

        // Update names
        if (nameEl) nameEl.textContent = name;
        if (headerNameEl) headerNameEl.textContent = name.split(' ')[0]; // First name only in header
        if (nudgeNameEl) nudgeNameEl.textContent = name.split(' ')[0];

        // Show/configure nudge based on state
        if (nudgeEl) {
            if (balance >= 0) {
                // Good standing - hide nudge
                nudgeEl.hidden = true;
            } else if (!hasPaid) {
                // Never paid, in debt - "Not X?" -> /membership/
                nudgeEl.hidden = false;
                nudgeLinkEl.href = '/membership/';
                nudgeLinkEl.innerHTML = 'Not <span id="nudge-name">' + name.split(' ')[0] + '</span>?';
            } else {
                // Paid before, in debt - "Not in good standing" -> /standing/
                nudgeEl.hidden = false;
                nudgeEl.classList.add('in-debt');
                nudgeLinkEl.href = '/standing/';
                nudgeLinkEl.textContent = 'Not in good standing';
            }
        }
    }

    async function init() {
        try {
            await Identity.init();
            const visitResult = await Identity.visit();
            const profile = Identity.getProfile();
            updateMarginBox(profile);
        } catch (e) {
            console.error('Identity init failed:', e);
        }
    }

    // Wait for crypto libs
    document.addEventListener('noble-crypto-ready', init);
})();

Step 6: Update base.html script tag

Change identity-dropdown.js to identity-margin.js.

Step 7: Commit

git add src/almnck/templates/base.html web/static/js/identity-margin.js
git rm web/static/js/identity-dropdown.js
git commit -m "refactor: replace identity dropdown with margin-box"

Phase 2: The Letter (/membership/)

Task 2.1: Create Letter Page Markdown

Files: - Create: editorial/pages/membership/page.md

Step 1: Create directory

mkdir -p editorial/pages/membership

Step 2: Write the page markdown with frontmatter

Create editorial/pages/membership/page.md:

---
almanac-day: '2026-01-19'
path: /membership/
status: published
title: A Letter from the Membership Secretary
template: membership_letter
---

<div class="letter-container">

<div class="letter-header">
<p class="letterhead">From the Office of the Membership Secretary</p>
<p class="letterhead-sub">Grand Assembly of Almanack, est. 4000 BCE, Girsu, Sumer</p>
<div class="wax-seal"></div>
<div class="urgent-stamp">URGENT</div>
</div>

<p class="salutation">Dear <span class="computer-font" id="letter-member-name">Lord Desiree Fauntleroy-Thomas</span>, Current Resident, or Next of Kin,</p>

I thank you for finally reading this letter. We attempted to contact you without success regarding your minor debt to our institution, which currently stands at: <span class="computer-font" id="letter-balance">-50</span> Almanickels.

We understand if this minor tally has slipped your mind: times are hard for us all — especially those devoted, as we and you are, to the often unremunerative search for pure knowledge.

As you know, our periodical, *The Almanack of Days* (known variously through the ages as 𒀭𒊬 in Sumerian, المناخ in Arabic, and countless other names), has been selflessly dedicated to the refinement and documentation of intellectual tidbits to persons such as yourself. We have always been honored to count you among our number, and have, until recently, been able to put to one side such fripperies as your accumulated debt.

Yet, I am humiliated to confess that we, too, are suffering the present predicament. Without your support, we estimate we have only <span id="runway-days">XXX</span> days remaining before we must commence selling our holdings in Antarctica, our remaining copper mines — and even relinquish the Gizzard of Lol.

**BUT:** could you see yourself able to make good on your existing debt, and to purchase a small supply of *additional* almanickels?

Then you would do more than merely save our editorial staff from the workhouse OR WORSE. You would also resume all the benefits, credentials, and luxuries of a **FULL MEMBER IN STANDING WITH THE ALMANACK ANARCHIST COLLECTIVE**.

<div class="letter-section-header">BUT WHAT IF I AM NOT <span id="letter-name-question">LORD DESIREE FAUNTLEROY-THOMAS</span>?</div>

If this is the case, I once again most deeply apologise for the error. However, may I contrive to suggest that, with a small bending of the rules, and an assumption of the current balance, we may permit a transferral of the right to membership from <span id="letter-old-name">Lord Desiree</span> to... whoever you are.

<div class="letter-section-header">A REMINDER OF WHAT AWAITS YOU:</div>

With just <span id="restore-cost">51</span> Almanickels (roughly $<span id="restore-dollars">1</span> at current rates), you will attain:

* **Membership in the World's Oldest and Most Intellectually-Rigorous Secret Society.** Imagine the look on your friends' faces when you tell them you have joined the likes of Mozart, Leonardo da Vinci, Picasso, and Clamrit Feldspar! Then savor the fact that you can NEVER TELL THEM — without first, that is, finagling them to also buy Almanickels.

* **Exclusive content** on our online publication at almnck.com. Discounted offers, additional materials, and sneak previews await all members in good standing.

* **Covert gatherings**, off and online. Maybe with cuties!

* **A permanent discount** on the printed edition of Almanack, should this ever become available again. (Due to recent exigencies and recent changes to intellectual property law, the collective behind Almanack has been unable to ship a printed version since 1804. But whenever we have sufficient funds to resume printing, you will be first in line!)

* **A thousand opportunities** to spend your excess Almanickels on cosmetic baubles of all kinds. Gaudy flair, "skins," and an inventory fit for Pharaohs await you.

* **Access to the inner workings** of our eldritch conspiracy, including, we imagine, video chats with the mysterious editorial staff, access to some kind of incomprehensible chat system, and probably a bloody podcast at some point.

But most importantly, by paying your dues and ceasing to bring shame on your family name, you will **ENSURE** the continuing existence of our august institution.

Almanack, as befits our radical heritage, operates an entirely transparent business, and you can see [our current finances here](/llc/). Our budget is roughly $2000 of editorial costs per month. (Almanickels are not legal tender, cannot be exchanged for such, are not securities, and may not be used at Dave & Buster's to refuel Power Bracelets.)

Your membership guarantees Almanack will continue for another 4000 years, give or take.

<div class="letter-section-header">SO WHAT WILL IT BE?</div>

Will you continue to run up debt in the name of some random stranger, whose family is probably very powerful and may at this moment be preparing a VAST BATTERY OF LAWYERS to investigate your IDENTITY THEFT?

Or will you join us, our merry band of <span id="subscriber-count">XXXX</span> subscribers, in our pursuit of pure knowledge, optimistic inquiry, the formulation of a sustainable, autonomous post-scarcity society, and the chance to have some sort of "flair" next to your name?

I know you will make the right decision, and if not, expect more letters.

<p class="signature">Yr Obdnt Srvnt,<br><br><em>Clamrit Feldspar Jr.</em><br>Membership Secretary</p>

<div class="standing-embed" hx-get="/api/standing-widget/" hx-trigger="load" hx-swap="innerHTML">
    <noscript>Visit <a href="/standing/">Your Standing</a> to view your balance.</noscript>
</div>

<div class="fine-print">
<p>Please note that under U.S. custom, bombastic advertorial cannot guarantee future results. Almanickels' sentimental value may go up and down. Void where prohibited by law. Void where permitted by law. As anarchists, we challenge even the idea behind coercive "law."</p>
<p>Do you need to actually recover your account, or merge this one with your old Almanack account? See <a href="/profile/">your Dossier</a>.</p>
</div>

</div>

Step 3: Commit

git add editorial/pages/membership/page.md
git commit -m "feat: add Letter membership page content"

Task 2.2: Create Letter Page CSS

Files: - Create: web/static/css/letter.css

Step 1: Write the theatrical letter styles

Create web/static/css/letter.css:

/* The Letter - Direct mail solicitation styling */

.letter-container {
    max-width: 42rem;
    margin: 0 auto;
    padding: 3rem 2.5rem;
    background:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E"),
        linear-gradient(to bottom, #faf8f5 0%, #f5f2ed 100%);
    background-blend-mode: overlay;
    border: 2px dashed #ccc;
    border-radius: 2px;
    position: relative;
    font-family: var(--font-body);
    line-height: 1.7;
}

/* Fake perforated edges */
.letter-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: -1px;
    right: -1px;
    height: 8px;
    background: repeating-linear-gradient(
        90deg,
        transparent 0,
        transparent 8px,
        #ccc 8px,
        #ccc 10px
    );
}

.letter-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #ddd;
    position: relative;
}

.letterhead {
    font-family: var(--font-display);
    font-size: 1.3rem;
    margin: 0 0 0.25rem 0;
    letter-spacing: 0.05em;
}

.letterhead-sub {
    font-size: 0.85rem;
    font-style: italic;
    color: #666;
    margin: 0;
}

.wax-seal {
    position: absolute;
    top: -0.5rem;
    right: 1rem;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 40% 40%, #a52a2a, #8b0000);
    border-radius: 50%;
    box-shadow:
        2px 2px 4px rgba(0,0,0,0.3),
        inset -2px -2px 4px rgba(0,0,0,0.2);
    /* TODO: Add almanack dingbat as background-image */
}

.urgent-stamp {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: #cc0000;
    color: white;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: bold;
    letter-spacing: 0.1em;
    transform: rotate(-8deg);
    box-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.salutation {
    margin-top: 1.5rem;
}

.computer-font {
    font-family: var(--font-mono);
    background: #f0f0f0;
    padding: 0.1em 0.3em;
    border-radius: 2px;
}

.letter-section-header {
    font-family: var(--font-display);
    font-size: 1.1rem;
    margin: 2rem 0 1rem 0;
    padding-top: 1rem;
    border-top: 1px solid #ddd;
}

.signature {
    margin-top: 2rem;
    padding-top: 1rem;
}

.standing-embed {
    margin: 2rem 0;
    padding: 1.5rem;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.fine-print {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px dashed #ccc;
    font-size: 0.8rem;
    color: #666;
    font-style: italic;
}

.fine-print p {
    margin: 0.5rem 0;
}

Step 2: Commit

git add web/static/css/letter.css
git commit -m "feat: add Letter page theatrical CSS styles"

Task 2.3: Create Letter Page JavaScript Hydration

Files: - Create: web/static/js/letter.js

Step 1: Write JS to populate letter with member data

Create web/static/js/letter.js:

// letter.js - Hydrates the Letter page with member data
(function() {
    'use strict';

    function hydrateLetterPage(profile) {
        const name = profile.name || 'Lord Desiree Fauntleroy-Thomas';
        const balance = profile.balance || -50;
        const firstName = name.split(' ')[0];

        // Update all name placeholders
        const nameEls = document.querySelectorAll('#letter-member-name, #letter-name-question');
        nameEls.forEach(el => el.textContent = name);

        const firstNameEl = document.getElementById('letter-old-name');
        if (firstNameEl) firstNameEl.textContent = firstName;

        // Update balance
        const balanceEl = document.getElementById('letter-balance');
        if (balanceEl) balanceEl.textContent = balance;

        // Calculate restore cost (debt + 1)
        const restoreCost = Math.abs(balance) + 1;
        const restoreDollars = Math.ceil(restoreCost / 1000);

        const restoreCostEl = document.getElementById('restore-cost');
        if (restoreCostEl) restoreCostEl.textContent = restoreCost;

        const restoreDollarsEl = document.getElementById('restore-dollars');
        if (restoreDollarsEl) restoreDollarsEl.textContent = restoreDollars;
    }

    async function init() {
        // Only run on /membership/ page
        if (!window.location.pathname.startsWith('/membership')) return;

        try {
            await Identity.init();
            const profile = Identity.getProfile();
            hydrateLetterPage(profile);
        } catch (e) {
            console.error('Letter hydration failed:', e);
        }
    }

    document.addEventListener('noble-crypto-ready', init);
})();

Step 2: Commit

git add web/static/js/letter.js
git commit -m "feat: add Letter page JavaScript hydration"

Phase 3: The Dossier (/profile/)

Task 3.1: Create Dossier Page Markdown

Files: - Create: editorial/pages/profile/page.md

Step 1: Create directory

mkdir -p editorial/pages/profile

Step 2: Write the page markdown

Create editorial/pages/profile/page.md:

---
almanac-day: '2026-01-19'
path: /profile/
status: published
title: Your Dossier
template: profile
---

<div class="dossier-container">

<section class="dossier-section">
<h2 class="section-heading">Identity</h2>

<dl class="dossier-fields">
    <dt>Name</dt>
    <dd><span id="profile-name" class="editable-field">stranger</span> <button class="edit-btn" id="edit-name-btn" aria-label="Edit name">✎</button></dd>

    <dt>Member Since</dt>
    <dd id="profile-member-since">—</dd>

    <dt>Your Almanack Key</dt>
    <dd><code id="profile-pubkey" class="truncated-key">—</code> <button class="copy-btn" id="copy-pubkey-btn" aria-label="Copy key">⎘</button></dd>

    <dt>Email</dt>
    <dd><span id="profile-email" class="editable-field">not set</span> <button class="edit-btn" id="edit-email-btn" aria-label="Edit email">✎</button></dd>
</dl>
</section>

<section class="dossier-section">
<h2 class="section-heading">Standing</h2>

<p class="balance-display">
    Current Balance: <strong id="profile-balance">0</strong> ℵ
</p>

<p class="standing-status">
    <span id="good-standing" class="status-good" hidden>IN GOOD STANDING</span>
    <span id="shameful-debt" class="status-debt" hidden>IN SHAMEFUL DEBT</span>
</p>

<p><a href="/standing/">View full transaction history →</a></p>
</section>

<section class="dossier-section">
<h2 class="section-heading">Activity</h2>

<div id="activity-heatmap" class="activity-heatmap">
    <noscript>Activity heatmap requires JavaScript.</noscript>
</div>

<p class="activity-summary">
    <span id="visit-count">0</span> visits · <span id="current-streak">0</span> day streak
</p>
</section>

<section class="dossier-section dossier-serious">
<h2 class="section-heading">Security & Recovery</h2>

<div class="serious-warning">
<p><strong>Important:</strong> These credentials control your Almanack identity and balance. Keep them safe.</p>
</div>

<dl class="dossier-fields">
    <dt>Secret Key</dt>
    <dd>
        <code id="profile-secret" class="secret-key">••••••••••••••••••••</code>
        <button class="reveal-btn" id="reveal-secret-btn">Reveal</button>
        <button class="copy-btn" id="copy-secret-btn" hidden aria-label="Copy secret">⎘</button>
    </dd>
</dl>

<p class="recovery-note">Copy this key and store it somewhere safe. It cannot be recovered if lost.</p>

<h3>Transfer to Another Device</h3>

<p>To access your account from another browser:</p>

<button class="action-btn" id="generate-link-btn">Generate Transfer Link</button>

<div id="transfer-link-container" hidden>
    <p class="warning-text">⚠️ This link grants full access to your account. Do not share publicly.</p>
    <input type="text" id="transfer-link" readonly class="transfer-link-input">
    <button class="copy-btn" id="copy-link-btn">Copy Link</button>
</div>

<h3>Need Help?</h3>

<p>Email support: <a href="mailto:hello@almnck.com">hello@almnck.com</a></p>

</section>

</div>

Step 3: Commit

git add editorial/pages/profile/page.md
git commit -m "feat: add Dossier profile page content"

Task 3.2: Create Dossier CSS

Files: - Create: web/static/css/dossier.css

Step 1: Write the ledger-style dossier CSS

Create web/static/css/dossier.css:

/* The Dossier - Archival ledger styling */

.dossier-container {
    max-width: 42rem;
    margin: 0 auto;
    padding: 2rem;
    font-family: var(--font-body);
}

.dossier-section {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #ddd;
}

.dossier-section:last-child {
    border-bottom: none;
}

.section-heading {
    font-family: var(--font-display);
    font-size: 1rem;
    font-variant: small-caps;
    letter-spacing: 0.1em;
    color: #666;
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

.dossier-fields {
    display: grid;
    grid-template-columns: 8rem 1fr;
    gap: 0.75rem 1rem;
    margin: 0;
}

.dossier-fields dt {
    font-size: 0.85rem;
    color: #666;
    padding-top: 0.2rem;
}

.dossier-fields dd {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.editable-field {
    font-family: var(--font-body);
}

.truncated-key {
    font-size: 0.8rem;
    max-width: 20ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.edit-btn, .copy-btn, .reveal-btn {
    background: none;
    border: 1px solid #ddd;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    border-radius: 2px;
}

.edit-btn:hover, .copy-btn:hover, .reveal-btn:hover {
    background: #f0f0f0;
}

/* Standing display */
.balance-display {
    font-size: 1.2rem;
    margin: 0 0 0.5rem 0;
}

.balance-display strong {
    font-family: var(--font-mono);
}

.standing-status {
    margin: 0;
}

.status-good {
    color: #228b22;
    font-weight: bold;
}

.status-debt {
    color: #8b0000;
    font-weight: bold;
}

.status-good[hidden], .status-debt[hidden] {
    display: none;
}

/* Activity heatmap */
.activity-heatmap {
    height: 100px;
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.activity-summary {
    font-size: 0.85rem;
    color: #666;
    margin: 0;
}

/* Security section */
.dossier-serious {
    background: #fafafa;
    margin-left: -2rem;
    margin-right: -2rem;
    padding: 1.5rem 2rem;
}

.serious-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.secret-key {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: #333;
    color: #333;
    padding: 0.3rem 0.5rem;
    border-radius: 2px;
}

.secret-key.revealed {
    color: #fff;
}

.recovery-note {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

.action-btn {
    background: var(--color-text);
    color: var(--color-bg);
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.9rem;
}

.action-btn:hover {
    opacity: 0.9;
}

.transfer-link-container {
    margin-top: 1rem;
    padding: 1rem;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.warning-text {
    color: #856404;
    font-size: 0.85rem;
    margin: 0 0 0.5rem 0;
}

.transfer-link-input {
    width: 100%;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 0.5rem;
    border: 1px solid #ddd;
    margin-bottom: 0.5rem;
}

Step 2: Commit

git add web/static/css/dossier.css
git commit -m "feat: add Dossier page ledger-style CSS"

Task 3.3: Create Dossier JavaScript

Files: - Create: web/static/js/dossier.js

Step 1: Write the dossier JS for profile hydration and interactions

Create web/static/js/dossier.js:

// dossier.js - Profile page hydration and interactions
(function() {
    'use strict';

    function hydrateProfile(profile) {
        // Identity section
        const nameEl = document.getElementById('profile-name');
        if (nameEl) nameEl.textContent = profile.name || 'stranger';

        const memberSinceEl = document.getElementById('profile-member-since');
        if (memberSinceEl && profile.created_at) {
            memberSinceEl.textContent = new Date(profile.created_at).toLocaleDateString('en-US', {
                year: 'numeric', month: 'long', day: 'numeric'
            });
        }

        const pubkeyEl = document.getElementById('profile-pubkey');
        if (pubkeyEl) pubkeyEl.textContent = profile.pubkey || '—';

        const emailEl = document.getElementById('profile-email');
        if (emailEl) emailEl.textContent = profile.email || 'not set';

        // Standing section
        const balance = profile.balance || 0;
        const balanceEl = document.getElementById('profile-balance');
        if (balanceEl) balanceEl.textContent = balance;

        const goodEl = document.getElementById('good-standing');
        const debtEl = document.getElementById('shameful-debt');
        if (balance >= 0) {
            if (goodEl) goodEl.hidden = false;
            if (debtEl) debtEl.hidden = true;
        } else {
            if (goodEl) goodEl.hidden = true;
            if (debtEl) debtEl.hidden = false;
        }

        // Activity
        const visitCountEl = document.getElementById('visit-count');
        if (visitCountEl) visitCountEl.textContent = profile.visit_count || 0;

        const streakEl = document.getElementById('current-streak');
        if (streakEl) streakEl.textContent = profile.streak || 0;
    }

    function setupRevealSecret() {
        const revealBtn = document.getElementById('reveal-secret-btn');
        const secretEl = document.getElementById('profile-secret');
        const copySecretBtn = document.getElementById('copy-secret-btn');

        if (!revealBtn || !secretEl) return;

        revealBtn.addEventListener('click', function() {
            const secret = localStorage.getItem('almanack:identity');
            if (secret) {
                secretEl.textContent = secret;
                secretEl.classList.add('revealed');
                revealBtn.hidden = true;
                if (copySecretBtn) copySecretBtn.hidden = false;
            }
        });
    }

    function setupCopyButtons() {
        // Copy pubkey
        const copyPubkeyBtn = document.getElementById('copy-pubkey-btn');
        const pubkeyEl = document.getElementById('profile-pubkey');
        if (copyPubkeyBtn && pubkeyEl) {
            copyPubkeyBtn.addEventListener('click', function() {
                navigator.clipboard.writeText(pubkeyEl.textContent);
                copyPubkeyBtn.textContent = '✓';
                setTimeout(() => copyPubkeyBtn.textContent = '⎘', 1500);
            });
        }

        // Copy secret
        const copySecretBtn = document.getElementById('copy-secret-btn');
        const secretEl = document.getElementById('profile-secret');
        if (copySecretBtn && secretEl) {
            copySecretBtn.addEventListener('click', function() {
                navigator.clipboard.writeText(secretEl.textContent);
                copySecretBtn.textContent = '✓';
                setTimeout(() => copySecretBtn.textContent = '⎘', 1500);
            });
        }
    }

    function setupTransferLink() {
        const generateBtn = document.getElementById('generate-link-btn');
        const container = document.getElementById('transfer-link-container');
        const linkInput = document.getElementById('transfer-link');
        const copyLinkBtn = document.getElementById('copy-link-btn');

        if (!generateBtn || !container || !linkInput) return;

        generateBtn.addEventListener('click', function() {
            const secret = localStorage.getItem('almanack:identity');
            if (secret) {
                // Create transfer URL with secret as fragment (not sent to server)
                const transferUrl = window.location.origin + '/profile/#recover=' + encodeURIComponent(secret);
                linkInput.value = transferUrl;
                container.hidden = false;
                generateBtn.hidden = true;
            }
        });

        if (copyLinkBtn) {
            copyLinkBtn.addEventListener('click', function() {
                linkInput.select();
                navigator.clipboard.writeText(linkInput.value);
                copyLinkBtn.textContent = 'Copied!';
                setTimeout(() => copyLinkBtn.textContent = 'Copy Link', 1500);
            });
        }
    }

    function checkForRecovery() {
        // Check URL fragment for recovery secret
        const hash = window.location.hash;
        if (hash.startsWith('#recover=')) {
            const secret = decodeURIComponent(hash.slice(9));
            if (secret && secret.startsWith('AGE-SECRET-KEY-1')) {
                if (confirm('Import this identity? This will replace your current identity.')) {
                    localStorage.setItem('almanack:identity', secret);
                    window.location.hash = '';
                    window.location.reload();
                }
            }
        }
    }

    async function init() {
        // Only run on /profile/ page
        if (!window.location.pathname.startsWith('/profile')) return;

        checkForRecovery();

        try {
            await Identity.init();
            const profile = Identity.getProfile();
            hydrateProfile(profile);
            setupRevealSecret();
            setupCopyButtons();
            setupTransferLink();

            // TODO: Render activity heatmap
            // renderHeatmap(profile.activity_data);
        } catch (e) {
            console.error('Dossier hydration failed:', e);
        }
    }

    document.addEventListener('noble-crypto-ready', init);
})();

Step 2: Commit

git add web/static/js/dossier.js
git commit -m "feat: add Dossier page JavaScript for profile interactions"

Phase 4: Your Standing (/standing/)

Task 4.1: Create Standing Page Markdown

Files: - Create: editorial/pages/standing/page.md

Step 1: Create directory

mkdir -p editorial/pages/standing

Step 2: Write the page markdown

Create editorial/pages/standing/page.md:

---
almanac-day: '2026-01-19'
path: /standing/
status: published
title: Your Standing
template: standing
---

<div class="standing-container">

<section class="standing-section standing-balance">
<p class="balance-amount">
    <span id="standing-balance">0</span> <span class="currency-symbol">ℵ</span>
</p>

<p class="standing-status">
    <span id="standing-good" class="status-good" hidden>IN GOOD STANDING</span>
    <span id="standing-debt" class="status-debt" hidden>IN SHAMEFUL DEBT</span>
</p>
</section>

<section class="standing-section">
<h2 class="section-heading">Contribute</h2>

<p class="contribute-intro">Restore your good name and support our continuing mission:</p>

<div class="payment-options">
    <button class="payment-btn" data-amount="1000" data-price="1">
        <span class="payment-amount">1,000 ℵ</span>
        <span class="payment-price">$1</span>
        <span class="payment-desc">A worthy attempt to restore your good name</span>
    </button>

    <button class="payment-btn" data-amount="5000" data-price="4">
        <span class="payment-amount">5,000 ℵ</span>
        <span class="payment-price">$4</span>
        <span class="payment-desc">A casual nod to our furious efforts</span>
    </button>

    <button class="payment-btn" data-amount="10000" data-price="7">
        <span class="payment-amount">10,000 ℵ</span>
        <span class="payment-price">$7</span>
        <span class="payment-desc">A reasonable investment in a trusted name</span>
    </button>

    <button class="payment-btn payment-subscription" data-amount="14000" data-price="7" data-recurring="monthly">
        <span class="payment-amount">14,000 ℵ/mo</span>
        <span class="payment-price">$7/month</span>
        <span class="payment-desc">Our equal, our companion: our friend</span>
        <span class="payment-badge">SUBSCRIBER</span>
    </button>
</div>
</section>

<section class="standing-section" id="subscription-section" hidden>
<h2 class="section-heading">Your Subscription</h2>

<div class="subscription-status">
    <p>Status: <strong id="sub-status">Active</strong></p>
    <p>Next payment: <span id="sub-next-date">—</span></p>
</div>

<div class="subscription-actions">
    <button class="action-btn action-secondary" id="pause-sub-btn">Pause Subscription</button>
    <button class="action-btn action-danger" id="cancel-sub-btn">Cancel Subscription</button>
</div>
</section>

<section class="standing-section">
<h2 class="section-heading">Gift a Membership</h2>

<p>Should someone else be thrown in with us?</p>

<p>Buy almanickels for another member:</p>

<div class="gift-form">
    <label for="gift-pubkey">Their Almanack Key:</label>
    <input type="text" id="gift-pubkey" placeholder="age1..." class="gift-input">
    <p class="gift-hint">They can find their key at the top of their <a href="/profile/">Dossier</a>.</p>

    <button class="action-btn" id="gift-btn" disabled>Choose Amount</button>
</div>
</section>

<section class="standing-section">
<h2 class="section-heading">Transaction History</h2>

<table class="transaction-table">
    <thead>
        <tr>
            <th>Date</th>
            <th>Description</th>
            <th class="amount-col">Amount</th>
            <th class="balance-col">Balance</th>
        </tr>
    </thead>
    <tbody id="transaction-body">
        <tr class="empty-row">
            <td colspan="4">No transactions yet.</td>
        </tr>
    </tbody>
</table>
</section>

</div>

Step 3: Commit

git add editorial/pages/standing/page.md
git commit -m "feat: add Standing page content"

Task 4.2: Create Standing CSS

Files: - Create: web/static/css/standing.css

Step 1: Write the ledger/accounts-book CSS

Create web/static/css/standing.css:

/* Your Standing - Ledger/accounts book styling */

.standing-container {
    max-width: 42rem;
    margin: 0 auto;
    padding: 2rem;
    font-family: var(--font-body);
}

.standing-section {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #ddd;
}

.section-heading {
    font-family: var(--font-display);
    font-size: 1rem;
    font-variant: small-caps;
    letter-spacing: 0.1em;
    color: #666;
    margin: 0 0 1rem 0;
}

/* Balance display */
.standing-balance {
    text-align: center;
    padding: 2rem 0;
    background: linear-gradient(to bottom, #fafafa, #fff);
}

.balance-amount {
    font-size: 3rem;
    font-family: var(--font-mono);
    margin: 0;
    line-height: 1;
}

.currency-symbol {
    font-size: 2rem;
    vertical-align: super;
    color: #666;
}

.standing-status {
    margin: 1rem 0 0 0;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
}

.status-good {
    color: #228b22;
    font-weight: bold;
}

.status-debt {
    color: #8b0000;
    font-weight: bold;
}

/* Payment options */
.contribute-intro {
    color: #666;
    font-style: italic;
}

.payment-options {
    display: grid;
    gap: 1rem;
}

.payment-btn {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 0.25rem 1rem;
    padding: 1rem 1.25rem;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    text-align: left;
    font-family: var(--font-body);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.payment-btn:hover {
    border-color: var(--color-text);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.payment-amount {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: bold;
}

.payment-price {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    text-align: right;
}

.payment-desc {
    grid-column: 1 / -1;
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

.payment-subscription {
    border-color: #228b22;
    position: relative;
}

.payment-badge {
    position: absolute;
    top: -0.5rem;
    right: 1rem;
    background: #228b22;
    color: white;
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    border-radius: 2px;
    letter-spacing: 0.05em;
}

/* Subscription management */
.subscription-status {
    background: #f0fff0;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.subscription-status p {
    margin: 0.25rem 0;
}

.subscription-actions {
    display: flex;
    gap: 1rem;
}

.action-btn {
    background: var(--color-text);
    color: var(--color-bg);
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.9rem;
}

.action-secondary {
    background: #666;
}

.action-danger {
    background: #8b0000;
}

/* Gift form */
.gift-form {
    max-width: 24rem;
}

.gift-form label {
    display: block;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.gift-input {
    width: 100%;
    padding: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    border: 1px solid #ddd;
    margin-bottom: 0.5rem;
}

.gift-hint {
    font-size: 0.8rem;
    color: #666;
    margin: 0 0 1rem 0;
}

/* Transaction table */
.transaction-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.transaction-table th,
.transaction-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.transaction-table th {
    font-family: var(--font-display);
    font-variant: small-caps;
    font-weight: normal;
    color: #666;
    border-bottom: 2px solid #ddd;
}

.amount-col,
.balance-col {
    text-align: right;
    font-family: var(--font-mono);
}

.empty-row td {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 2rem;
}

/* Positive/negative amounts */
.amount-positive {
    color: #228b22;
}

.amount-negative {
    color: #8b0000;
}

Step 2: Commit

git add web/static/css/standing.css
git commit -m "feat: add Standing page ledger-style CSS"

Task 4.3: Create Standing JavaScript

Files: - Create: web/static/js/standing.js

Step 1: Write the standing page JS

Create web/static/js/standing.js:

// standing.js - Standing page hydration and payment interactions
(function() {
    'use strict';

    const API_BASE = document.querySelector('meta[name="almanack-api"]')?.content || '';

    function hydrateStanding(profile) {
        const balance = profile.balance || 0;

        // Update balance display
        const balanceEl = document.getElementById('standing-balance');
        if (balanceEl) balanceEl.textContent = balance.toLocaleString();

        // Update status
        const goodEl = document.getElementById('standing-good');
        const debtEl = document.getElementById('standing-debt');
        if (balance >= 0) {
            if (goodEl) goodEl.hidden = false;
            if (debtEl) debtEl.hidden = true;
        } else {
            if (goodEl) goodEl.hidden = true;
            if (debtEl) debtEl.hidden = false;
        }

        // Show subscription section if subscribed
        if (profile.subscription_status === 'active') {
            const subSection = document.getElementById('subscription-section');
            if (subSection) subSection.hidden = false;

            const statusEl = document.getElementById('sub-status');
            if (statusEl) statusEl.textContent = 'Active';

            const nextDateEl = document.getElementById('sub-next-date');
            if (nextDateEl && profile.subscription_next_date) {
                nextDateEl.textContent = new Date(profile.subscription_next_date).toLocaleDateString();
            }
        }
    }

    function renderTransactions(transactions) {
        const tbody = document.getElementById('transaction-body');
        if (!tbody || !transactions || transactions.length === 0) return;

        tbody.innerHTML = transactions.map(tx => `
            <tr>
                <td>${new Date(tx.date).toLocaleDateString()}</td>
                <td>${tx.description}</td>
                <td class="amount-col ${tx.amount >= 0 ? 'amount-positive' : 'amount-negative'}">
                    ${tx.amount >= 0 ? '+' : ''}${tx.amount.toLocaleString()}
                </td>
                <td class="balance-col">${tx.running_balance.toLocaleString()}</td>
            </tr>
        `).join('');
    }

    function setupPaymentButtons() {
        const buttons = document.querySelectorAll('.payment-btn');

        buttons.forEach(btn => {
            btn.addEventListener('click', async function() {
                const amount = this.dataset.amount;
                const price = this.dataset.price;
                const recurring = this.dataset.recurring;

                try {
                    // Create Stripe checkout session via API
                    const pubkey = Identity.getSigningPublicKey();
                    const timestamp = Date.now();
                    const signature = await Identity.sign(`checkout:${timestamp}`);

                    const response = await fetch(`${API_BASE}/checkout`, {
                        method: 'POST',
                        headers: { 'Content-Type': 'application/json' },
                        body: JSON.stringify({
                            pubkey,
                            timestamp,
                            signature,
                            amount: parseInt(amount),
                            price_cents: parseInt(price) * 100,
                            recurring: recurring || null
                        })
                    });

                    if (!response.ok) throw new Error('Checkout failed');

                    const { checkout_url } = await response.json();
                    window.location.href = checkout_url;
                } catch (e) {
                    console.error('Payment error:', e);
                    alert('Payment initialization failed. Please try again.');
                }
            });
        });
    }

    function setupGiftForm() {
        const pubkeyInput = document.getElementById('gift-pubkey');
        const giftBtn = document.getElementById('gift-btn');

        if (!pubkeyInput || !giftBtn) return;

        pubkeyInput.addEventListener('input', function() {
            // Enable button if input looks like a pubkey
            giftBtn.disabled = !this.value.startsWith('age1');
        });

        giftBtn.addEventListener('click', function() {
            // TODO: Open gift amount modal
            alert('Gift purchasing coming soon!');
        });
    }

    async function fetchTransactions() {
        try {
            const pubkey = Identity.getSigningPublicKey();
            const timestamp = Date.now();
            const signature = await Identity.sign(`transactions:${timestamp}`);

            const response = await fetch(
                `${API_BASE}/transactions?pubkey=${pubkey}&ts=${timestamp}&sig=${signature}`
            );

            if (response.ok) {
                const data = await response.json();
                renderTransactions(data.transactions);
            }
        } catch (e) {
            console.error('Failed to fetch transactions:', e);
        }
    }

    async function init() {
        // Only run on /standing/ page
        if (!window.location.pathname.startsWith('/standing')) return;

        try {
            await Identity.init();
            const profile = Identity.getProfile();
            hydrateStanding(profile);
            setupPaymentButtons();
            setupGiftForm();
            fetchTransactions();
        } catch (e) {
            console.error('Standing page init failed:', e);
        }
    }

    document.addEventListener('noble-crypto-ready', init);
})();

Step 2: Commit

git add web/static/js/standing.js
git commit -m "feat: add Standing page JavaScript for payments"

Phase 5: Standing Widget Partial

Task 5.1: Create HTMX-Loadable Standing Widget

Files: - Create: src/almnck/templates/partials/_standing_widget.html - Create: web/static/css/standing-widget.css

Step 1: Write the widget partial

Create src/almnck/templates/partials/_standing_widget.html:

<div class="standing-widget" id="standing-widget">
    <p class="widget-balance">
        Balance: <strong id="widget-balance-value">0</strong> ℵ
    </p>

    <div class="widget-buttons">
        <a href="/standing/" class="widget-btn">Top Up</a>
        <a href="/standing/" class="widget-btn widget-btn-primary">Restore Standing</a>
    </div>
</div>

<script>
(function() {
    // Hydrate widget with current balance
    if (typeof Identity !== 'undefined' && Identity.getBalance) {
        const balance = Identity.getBalance();
        const el = document.getElementById('widget-balance-value');
        if (el) el.textContent = balance;

        // Show/hide restore button based on debt
        const restoreBtn = document.querySelector('.widget-btn-primary');
        if (restoreBtn && balance >= 0) {
            restoreBtn.style.display = 'none';
        }
    }
})();
</script>

Step 2: Write the widget CSS

Create web/static/css/standing-widget.css:

/* Standing widget - embeddable balance display */

.standing-widget {
    text-align: center;
    padding: 1rem;
}

.widget-balance {
    font-size: 1.1rem;
    margin: 0 0 1rem 0;
}

.widget-balance strong {
    font-family: var(--font-mono);
}

.widget-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.widget-btn {
    padding: 0.5rem 1rem;
    text-decoration: none;
    border: 1px solid var(--color-text);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}

.widget-btn:hover {
    background: var(--color-text);
    color: var(--color-bg);
}

.widget-btn-primary {
    background: var(--color-text);
    color: var(--color-bg);
}

.widget-btn-primary:hover {
    background: #333;
}

Step 3: Commit

git add src/almnck/templates/partials/_standing_widget.html web/static/css/standing-widget.css
git commit -m "feat: add HTMX-loadable standing widget partial"

Phase 6: Integration & Wiring

Task 6.1: Update Base Template to Load All New Assets

Files: - Modify: src/almnck/templates/base.html

Step 1: Read current base.html

Read src/almnck/templates/base.html to see current structure.

Step 2: Add CSS links in head

Add after existing CSS:

<link rel="stylesheet" href="{% static 'css/membership-margin.css' %}">
<link rel="stylesheet" href="{% static 'css/letter.css' %}">
<link rel="stylesheet" href="{% static 'css/dossier.css' %}">
<link rel="stylesheet" href="{% static 'css/standing.css' %}">
<link rel="stylesheet" href="{% static 'css/standing-widget.css' %}">

Step 3: Add JS scripts before closing body

Add after existing scripts:

<script src="{% static 'js/identity-margin.js' %}"></script>
<script src="{% static 'js/letter.js' %}"></script>
<script src="{% static 'js/dossier.js' %}"></script>
<script src="{% static 'js/standing.js' %}"></script>

Step 4: Commit

git add src/almnck/templates/base.html
git commit -m "feat: wire up all membership page assets in base template"

Task 6.2: Sync and Test

Step 1: Sync editorial content

make sync

Expected: Pages created in database.

Step 2: Run development server

make serve

Step 3: Test each page

Visit: - http://localhost:1969/membership/ - http://localhost:1969/profile/ - http://localhost:1969/standing/

Verify: - Pages render without errors - CSS styles load correctly - JavaScript hydrates member data - Margin-box appears on all pages

Step 4: Commit any fixes

git add -A
git commit -m "fix: resolve integration issues from testing"

Phase 7: Deferred / Future Tasks

These are noted but not implemented in this plan:

  1. Activity Heatmap - Needs library selection (cal-heatmap, custom SVG, etc.) and API endpoint for activity data.

  2. Stripe Integration - Requires:

  3. Stripe account setup
  4. API endpoints in FastAPI backend (/checkout, /webhook)
  5. Subscription management endpoints

  6. Gift Purchasing Flow - Needs modal UI and API support.

  7. Name Editing - In-place edit on /profile/ needs API endpoint.

  8. Email Setting - Recovery email feature needs API support.


Summary

Total tasks: 17 discrete steps across 6 phases

Files created: - 3 editorial pages (markdown) - 4 CSS files - 4 JavaScript files - 2 template partials

Files modified: - src/almnck/templates/base.html - Renamed identity-dropdown.js → identity-margin.js

Testing: - Manual browser testing at each phase - make sync to update database - make serve for development


Plan complete and saved to doc/process/plans/2026-01-19-membership-pages-implementation.md.

Two execution options:

1. Subagent-Driven (this session) - I dispatch fresh subagent per task, review between tasks, fast iteration

2. Parallel Session (separate) - Open new session with executing-plans, batch execution with checkpoints

Which approach?