tractatus/public/admin/newsletter-management.html
TheFlow 4408b694f9 feat: Add comprehensive visitor retention system
Implemented RSS feeds, newsletter subscriptions, email templates, and admin UI
to encourage repeat visits from self-selected visitors.

## RSS Feeds
- Created RSS 2.0 feed generation (main + topic-specific)
- Endpoints: /feed.xml and /feed/:topic.xml
- Added getPublished() and getPublishedByTag() to BlogPost model

## Newsletter Subscriptions
- Created reusable newsletter modal component
- Added to index, researcher, implementer, leader pages
- Interest selection: research, implementation, governance, project-updates
- Added newsletter trigger button to footer
- Uses existing /api/newsletter/subscribe endpoint

## Email Templates
- Created comprehensive specifications for 4 newsletter tiers
- Research Updates (monthly) - scholarly audience
- Implementation Notes (bi-weekly) - practitioners
- Governance Discussions (sporadic) - stakeholders
- Project Updates (quarterly) - general audience
- Documented template variables, design guidelines

## Admin UI
- Enhanced newsletter management with "Send Newsletter" section
- Tier selection, subject/preview input, JSON content editor
- Preview/test/send buttons (UI ready, email service TBD)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 10:42:43 +13:00

174 lines
8.2 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Newsletter Management | Tractatus Admin</title>
<link rel="stylesheet" href="/css/tailwind.css?v=0.1.0.1761283486841">
<link rel="stylesheet" href="/css/tractatus-theme.min.css?v=0.1.0.1761283486841">
<script src="/js/admin/auth-check.js?v=0.1.0.1761283486841"></script>
</head>
<body class="bg-gray-50">
<!-- Navigation -->
<div id="admin-navbar" data-page-title="Newsletter Management" data-page-icon="newsletter"></div>
<script src="/js/components/navbar-admin.js?v=0.1.0.1761283486841"></script>
<!-- Main Content -->
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<!-- Statistics Cards -->
<div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-8">
<div class="bg-white rounded-lg shadow p-6">
<div class="text-sm text-gray-500">Total Subscribers</div>
<div class="text-3xl font-bold text-gray-900 mt-2" id="stat-total">-</div>
</div>
<div class="bg-white rounded-lg shadow p-6">
<div class="text-sm text-gray-500">Active Subscribers</div>
<div class="text-3xl font-bold text-green-600 mt-2" id="stat-active">-</div>
</div>
<div class="bg-white rounded-lg shadow p-6">
<div class="text-sm text-gray-500">Verified</div>
<div class="text-3xl font-bold text-blue-600 mt-2" id="stat-verified">-</div>
</div>
<div class="bg-white rounded-lg shadow p-6">
<div class="text-sm text-gray-500">Last 30 Days</div>
<div class="text-3xl font-bold text-indigo-600 mt-2" id="stat-recent">-</div>
</div>
</div>
<!-- Send Newsletter -->
<div class="bg-white rounded-lg shadow p-6 mb-8">
<h2 class="text-lg font-medium text-gray-900 mb-4">Send Newsletter</h2>
<form id="send-newsletter-form" class="space-y-4">
<!-- Tier Selection -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Newsletter Tier</label>
<select id="newsletter-tier" class="w-full px-3 py-2 border border-gray-300 rounded-md">
<option value="">Select tier...</option>
<option value="research">Research Updates (Monthly)</option>
<option value="implementation">Implementation Notes (Bi-weekly)</option>
<option value="governance">Governance Discussions (Sporadic)</option>
<option value="project-updates">Project Updates (Quarterly)</option>
</select>
<p class="text-xs text-gray-500 mt-1">Will send to all subscribers interested in this tier</p>
</div>
<!-- Subject Line -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Subject Line</label>
<input type="text" id="newsletter-subject" class="w-full px-3 py-2 border border-gray-300 rounded-md" placeholder="e.g., Tractatus Research Updates - November 2025">
</div>
<!-- Preview Text -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Preview Text</label>
<input type="text" id="newsletter-preview" class="w-full px-3 py-2 border border-gray-300 rounded-md" placeholder="This appears in the inbox preview...">
</div>
<!-- Template Variables -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Content (JSON)</label>
<textarea id="newsletter-content" rows="10" class="w-full px-3 py-2 border border-gray-300 rounded-md font-mono text-xs" placeholder='{"highlight_1_title": "...", "highlight_1_summary": "...", ...}'></textarea>
<p class="text-xs text-gray-500 mt-1">
JSON object with template variables.
<a href="/email-templates/TEMPLATE_SPECS.md" target="_blank" class="text-blue-600 hover:underline">See template specs</a>
</p>
</div>
<!-- Action Buttons -->
<div class="flex gap-3">
<button type="button" id="preview-newsletter-btn" class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50">
Preview
</button>
<button type="button" id="test-newsletter-btn" class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50">
Send Test
</button>
<button type="submit" id="send-newsletter-btn" class="px-4 py-2 bg-blue-600 text-white rounded-md text-sm font-medium hover:bg-blue-700">
Send to Subscribers
</button>
</div>
<!-- Status Messages -->
<div id="send-status" class="hidden"></div>
</form>
</div>
<!-- Actions -->
<div class="bg-white rounded-lg shadow p-6 mb-8">
<div class="flex justify-between items-center">
<h2 class="text-lg font-medium text-gray-900">Subscriber Actions</h2>
<div class="flex gap-3">
<button id="refresh-btn" class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50">
Refresh
</button>
<button id="export-btn" class="px-4 py-2 bg-blue-600 text-white rounded-md text-sm font-medium hover:bg-blue-700">
Export CSV
</button>
</div>
</div>
</div>
<!-- Subscribers List -->
<div class="bg-white rounded-lg shadow">
<div class="px-6 py-4 border-b border-gray-200">
<div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-medium text-gray-900">Subscribers</h3>
<div class="flex gap-2">
<select id="filter-status" class="px-3 py-2 border border-gray-300 rounded-md text-sm">
<option value="active">Active</option>
<option value="all">All</option>
<option value="inactive">Inactive</option>
</select>
<select id="filter-verified" class="px-3 py-2 border border-gray-300 rounded-md text-sm">
<option value="all">All Verification</option>
<option value="verified">Verified</option>
<option value="unverified">Unverified</option>
</select>
</div>
</div>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Source</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Subscribed</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody id="subscribers-table" class="bg-white divide-y divide-gray-200">
<tr>
<td colspan="6" class="px-6 py-8 text-center text-gray-500">Loading subscribers...</td>
</tr>
</tbody>
</table>
</div>
<!-- Pagination -->
<div class="px-6 py-4 border-t border-gray-200 flex justify-between items-center">
<div class="text-sm text-gray-500">
Showing <span id="showing-from">0</span> to <span id="showing-to">0</span> of <span id="total-count">0</span> subscribers
</div>
<div class="flex gap-2">
<button id="prev-page" class="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed">
Previous
</button>
<button id="next-page" class="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed">
Next
</button>
</div>
</div>
</div>
</div>
<script src="/js/admin/newsletter-management.js?v=0.1.2.objectid-to-string"></script>
</body>
</html>