saturn
- 187 commits
- 2 branches
- 0 tags
- updated
- CI 2/2
feat: add likes, comments back - part3
SignedGitea couldn't verify the signature.
Showing 27 changed files with 1046 additions and 51 deletions.
.gitignore
+5 −0
@@ -4,3 +4,8 @@4455# deploy staging66dist/78# social: local d1, secrets, deps9social/.wrangler/10social/.dev.vars11social/node_modules/
.tangled/workflows/deploy.yml
+4 −2
@@ -25,10 +25,12 @@ steps:2525 set -euo pipefail2626 mkdir dist2727 git ls-files -z \28 | grep -zv -e '^internal/' -e '^scripts/' -e '^\.tangled/' -e '^\.gitignore$' -e '^mise\.toml$' \28 | grep -zv -e '^internal/' -e '^scripts/' -e '^social/' -e '^\.tangled/' -e '^\.gitignore$' -e '^mise\.toml$' \2929 | xargs -0 cp --parents -t dist303031 # from social/ so wrangler finds its functions and wrangler.toml3132 - name: "Deploy to Cloudflare Pages"3233 command: |3334 set -euo pipefail34 npx --yes wrangler@4 pages deploy dist --project-name=saturn --branch=main35 cd social36 npx --yes wrangler@4 pages deploy ../dist --project-name=saturn --branch=main
_routes.jsonadded
+5 −0
@@ -0,0 +1,5 @@1{2 "version": 1,3 "include": ["/about/*", "/now/*", "/blog/*", "/projects/*", "/api/*"],4 "exclude": []5}
about/index.html
+4 −0
@@ -198,6 +198,10 @@198198 food, or video games. My email is in the footer below.199199 </p>200200 </section>201202 <section class="post-social" id="comments" data-social aria-label="likes and comments">203 <p class="meta">likes and comments unavailable</p>204 </section>201205 </article>202206203207 <nav class="pager" aria-label="post navigation">
blog/index.html
+7 −0
@@ -115,6 +115,13 @@115115 <section aria-labelledby="blog-writing">116116 <h2 class="section-label" id="blog-writing">writing</h2>117117 <ol class="archive">118 <li>119 <a class="archive-row" href="/projects/saturn/">120 <span class="archive-title">Saturn</span>121 <span class="archive-tag">#projects</span>122 <time class="archive-date" datetime="2026-10-15">15 Oct 26</time>123 </a>124 </li>118125 <li>119126 <a class="archive-row" href="/now/sep-2026/">120127 <span class="archive-title">Wake Me Up When September Ends</span>
feed.xml
+56 −1
@@ -7,7 +7,7 @@77 <link rel="alternate" type="text/html" href="https://danieldaum.net/" />88 <link rel="self" type="application/atom+xml" href="https://danieldaum.net/feed.xml" />99 <icon>https://danieldaum.net/assets/favicon/android-chrome-192x192.png</icon>10 <updated>2026-09-03T09:00:00-07:00</updated>10 <updated>2026-10-15T09:00:00-07:00</updated>1111 <author>1212 <name>daniel daum</name>1313 <uri>https://danieldaum.net/</uri>@@ -15,6 +15,61 @@15151616 <!-- NEWEST FIRST. content: post body in CDATA, absolute URLs, no classes. -->171718 <entry>19 <title>Saturn</title>20 <link rel="alternate" type="text/html" href="https://danieldaum.net/projects/saturn/" />21 <id>https://danieldaum.net/projects/saturn/</id>22 <published>2026-10-15T09:00:00-07:00</published>23 <updated>2026-10-15T09:00:00-07:00</updated>24 <category term="projects" />25 <summary type="text">saturn - daniel daum's personal website, a minimalist redesign built with html and css</summary>26 <content type="html"><![CDATA[27 <figure>28 <img src="https://assets.danieldaum.net/img/misc/saturn-moss.webp" alt="screenshot of the saturn personal website" /></figure>29 <p>This is the project page for my personal website, <a href="https://danieldaum.net">this website</a> - called saturn.</p>30 <p>I have never been completely satisfied with the look of my website. I've always been drawn to simple, minimal pages, but I've struggled to find a design that feels entirely my own. In my efforts to improve the things I didn’t like, I’ve remade this site several times until its become what is is today: my cozy minimal personal website.</p>31 <p>Under the hood, the implementation is deliberately kept simple: static HTML and CSS, no JavaScript framework, and a domain registered and hosted on Cloudflare. I write HTML and CSS locally on my machine, when changes hit main a CI pipeline pushes them to Cloudflare Pages.</p>32 <p>I chose the name Saturn because it's my favorite planet. It has <a href="https://science.nasa.gov/saturn/">rings!</a></p>33 <figure>34 <img src="https://assets.danieldaum.net/img/meme/saturn-neat.webp" alt="Marge Simpson holding Saturn on a plate, captioned “I just think they're neat!”" /></figure>35 <h2>Evolution | version history</h2>36 <p>Feeling nostalgic, I decided to go through the previous evolutions of my site's design. Easy to do since the entire history of the website (back to my first commit in 2021) exists in <a href="https://tangled.org/danieldaum.net/saturn">this repository</a>.</p>37 <h3>I like food and building stuff (Nov 2021)</h3>38 <figure>39 <img src="https://assets.danieldaum.net/img/misc/v1-original.webp" alt="the site in november 2021: “I'm Daniel” centered on a white page in Lato, above “I like food and building stuff”" /></figure>40 <p>This was my first website, two days after my first commit. It had one HTML file and one stylesheet, used Lato from Google Fonts, and was hosted on GitHub Pages. At the time, I was learning how to write HTML and CSS, figuring out how hosting worked, and trying to decide what a personal site should be. I remember feeling proud that I had a website, and proud that I built it myself. I still feel proud.</p>41 <h3>create-react-app (Jan 2022)</h3>42 <figure>43 <img src="https://assets.danieldaum.net/img/misc/v2-react-grey.webp" alt="the react version in january 2022: “Daniel Daum” in bold on a dark page, above outlined cards for projects and a digital garden" /></figure>44 <p>You know what proves you're a real software engineer? Rebuilding your static four-page website in React. I remember thinking at the time, "Oh yeah, baby! This is what real developers do." It used React 17 and TypeScript, and came with a 120,000-line package-lock.json. Of its five routes, four rendered the same 'coming-soon' page. Addtionally, If you hover over one of those boxes, they turn pink! If you ever hear me tell someone I am good at design, feel free to bring this up for discussion.</p>45 <h3>Back to plain HTML (Apr 2022)</h3>46 <figure>47 <img src="https://assets.danieldaum.net/img/misc/v3-vanilla-white.webp" alt="the april 2022 version: “/daniel-daum.com” centered on a white page, above github and linkedin icons and an about link" /></figure>48 <p>Thankfully, I must've encountered <a href="https://motherfuckingwebsite.com">motherfuckingwebsite</a> sometime in early 2022. I got rid of React and went back to vanilla HTML and CSS. Unfortunately, I still didn't know how to make a <s>real website</s> landing page look great. So, while the React app was out, it was replaced with this beauty. Two hand-written pages set in Unica One and Open Sans. This stayed up until September 2023.</p>49 <h3>Clean slate (Jun 2026)</h3>50 <figure>51 <img src="https://assets.danieldaum.net/img/misc/v4-clean.webp" alt="the june 2026 version: lowercase monospace text on a near-black page, with the writing and garden links struck through" /></figure>52 <p>After a few more redesigns between 2023 and 2026, I felt I needed to reset my CSS. I had lost the plot. This reset helped me focus on figuring out what I truly wanted on a website, and put me on the path of iterating towards a design I truly enjoyed. Initially, everything was lowercase (which got annoying), and it was set in Ioskeley Mono. I then added a now page, a garden page, and a <a href="https://danieldaum.net/pgp.asc">PGP key</a>. I appreciate that my work here helped bring the design to where it is today.</p>53 <h2>Which brings us to now</h2>54 <p>There's an old misquote: "A good artist borrows, a great artist steals." I never really learned design, but I did learn how to steal. Every so often I would find a font I liked or some cool CSS on the web, and I'd bring it home to try on. Eventually I figured out what worked and what didn't, keeping the things I loved most.</p>55 <p>So I wanted to acknowledge the people who's websites inspired me, and whose work I stole from.</p>56 <ul>57 <li>The current iteration of the site is set in <a href="https://vercel.com/blog/introducing-geist-pixel">Geist Pixel</a>, which I mercilessly ripped from <a href="https://royfish.dev">royfish.dev</a> after reading their excellent <a href="https://royfish.dev/fingerprints-are-the-new-cookies">Fingerprints are the new cookies</a> post.</li>58 <li>I got the idea for themes from <a href="https://rmv.fyi">rmv.fyi</a>. I visited Ruby's blog some time ago, and it shows a new color theme on every page load. I loved it. I then added themes to this site using color combinations from <a href="https://stephango.com/flexoki">Flexoki</a> by <a href="https://stephango.com">Steph Ango</a>.</li>59 <li>Comments, likes, and theme switcher in theme.js was written by an60 LLM. I’m counting that as stealing too.</li></ul>61 <p>I have also taken design, code, and ideas from these sites and developers, including many others I've certainly forgotten:</p>62 <ul>63 <li><a href="https://vale.rocks">vale.rocks</a></li>64 <li><a href="https://textlog.cc/">textlog.cc</a></li>65 <li><a href="https://catskull.net">catskull.net</a></li>66 <li><a href="https://motherfuckingwebsite.com">motherfuckingwebsite</a> and its derivatives, like <a href="https://modernmotherfuckingwebsite.dreamstation.systems">modernmotherfuckingwebsite</a></li></ul>67 <p>Thank you all.</p>68 <p>I don’t know if this site is actually any better than my first version and I’ll probably want to redesign it again someday soon. But like that first one, I like it, I made (most of) it, and I’m proud.</p>69 <p>- Daniel</p>70 ]]></content>71 </entry>721873 <entry>1974 <title>Wake Me Up When September Ends</title>2075 <link rel="alternate" type="text/html" href="https://danieldaum.net/now/sep-2026/" />
global.css
+166 −4
@@ -702,6 +702,164 @@ nav p {702702 padding: 0;703703}704704705/*============================*/706/* components - likes + comments */707/*============================*/708709/* written in by social/functions/_middleware.js */710.post-social {711 margin-top: 3rem;712 padding-top: 1.25rem;713 border-top: 1px dashed var(--borders);714}715716.post-social > .meta {717 margin: 0;718}719720.social-head {721 display: flex;722 justify-content: space-between;723 align-items: center;724 gap: 1rem;725 margin-bottom: 0.5rem;726}727728.social-title {729 margin: 0;730 font-size: 0.78rem;731 letter-spacing: 0.12em;732 color: var(--text-secondary);733}734735.comment-thread {736 list-style: none;737 margin: 0;738 padding: 0;739}740741.comment-thread li {742 margin: 0;743}744745/* replies: one level, on a rule */746.comment-thread .comment-thread {747 margin-top: 0.25rem;748 padding-left: 1rem;749 border-left: 1px solid var(--borders);750}751752.comment {753 padding: 1rem 0;754}755756.comment .meta {757 display: flex;758 flex-wrap: wrap;759 gap: 0.25rem 0.75rem;760 margin: 0 0 0.5rem;761 font-size: 0.78rem;762 letter-spacing: 0.04em;763}764765.comment-name {766 color: var(--text-headings);767}768769.comment-author {770 padding: 0 0.35rem;771 border: 1px solid var(--borders);772 font-size: 0.7rem;773 letter-spacing: 0.08em;774 color: var(--accent);775}776777.comment-time,778.comment-link {779 color: var(--text-secondary);780 transition: color 150ms ease;781}782783.comment-time:hover,784.comment-link:hover {785 color: var(--accent);786}787788.comment-body p {789 margin: 0 0 0.5rem;790}791792.comment-link {793 font-size: 0.75rem;794 letter-spacing: 0.08em;795}796797.social-foot {798 display: flex;799 flex-wrap: wrap;800 justify-content: space-between;801 align-items: baseline;802 gap: 0.5rem 1rem;803 margin-top: 1.5rem;804}805806.social-foot .meta {807 margin: 0;808 font-size: 0.8rem;809}810811.like-form {812 margin: 0;813}814815.like-button {816 display: inline-flex;817 align-items: center;818 gap: 0.4rem;819 min-height: 2.25rem;820 padding: 0 0.85rem;821 border: 1px solid var(--borders);822 background: none;823 color: var(--text-secondary);824 font-size: 0.85rem;825 letter-spacing: 0.06em;826 cursor: pointer;827 transition:828 color 150ms ease,829 border-color 150ms ease;830}831832.like-button:hover {833 color: var(--accent);834 border-color: var(--accent);835}836837/* already liked today */838.like-button:disabled {839 color: var(--accent);840 border-color: var(--borders);841 cursor: default;842}843844.like-icon {845 width: 0.95em;846 height: 0.95em;847 fill: none;848 stroke: currentColor;849 stroke-width: 2;850 stroke-linejoin: round;851}852853.like-button:disabled .like-icon {854 fill: currentColor;855}856857/* /api/moderate */858.moderate-actions {859 display: flex;860 gap: 0.75rem;861}862705863/*============================*/706864/* components - pager */707865/*============================*/@@ -1084,11 +1242,11 @@ nav p {10841242 white-space: nowrap;10851243}108612441087/* fixed width so the dates line up whatever the tag; the widest (#about,1088 #album) are ~7.4ch in the pixel font's caps */1245/* fixed width so the dates line up whatever the tag; the widest1246 (#projects) is ~11.1ch in the pixel font's caps */10891247.archive-tag {10901248 order: 2;1091 width: 8ch;1249 width: 11.5ch;10921250}1093125110941252.archive-date {@@ -2183,7 +2341,11 @@ footer nav a,21832341.pill,21842342.commit-log-head,21852343.commit-log-date,2186.version-date {2344.version-date,2345.social-title,2346.comment-author,2347.comment-time,2348.comment-link {21872349 text-transform: uppercase;21882350}21892351
index.html
+7 −0
@@ -116,6 +116,13 @@116116 <section aria-labelledby="home-writing">117117 <h2 class="section-label" id="home-writing">writing</h2>118118 <ol class="archive">119 <li>120 <a class="archive-row" href="/projects/saturn/">121 <span class="archive-title">Saturn</span>122 <span class="archive-tag">#projects</span>123 <time class="archive-date" datetime="2026-10-15">15 Oct 26</time>124 </a>125 </li>119126 <li>120127 <a class="archive-row" href="/now/sep-2026/">121128 <span class="archive-title">Wake Me Up When September Ends</span>
internal/styles.html
+40 −0
@@ -420,6 +420,46 @@420420 </nav>421421 </div>422422423 <div class="demo">424 <p class="demo-label">.post-social (last in the article; written by social/functions/_middleware.js)</p>425 <section class="post-social" aria-label="likes and comments demo">426 <div class="social-head">427 <h2 class="social-title">2 comments</h2>428 <form class="like-form">429 <button type="button" class="like-button" aria-label="you liked this post, 3 likes" disabled aria-pressed="true"><svg class="like-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z" /></svg> 3</button>430 </form>431 </div>432 <ol class="comment-thread">433 <li>434 <article class="comment" id="demo-comment-1">435 <p class="meta">436 <span class="comment-name">sam</span>437 <a class="comment-time" href="#demo-comment-1"><time datetime="2026-09-04T16:12:00Z">4 Sep 2026 · 09:12</time></a>438 </p>439 <div class="comment-body"><p>Mother Tongue is great, try the cortado.</p></div>440 <a class="comment-link" href="#post">reply →</a>441 <ol class="comment-thread">442 <li>443 <article class="comment" id="demo-comment-2">444 <p class="meta">445 <span class="comment-name">daniel</span><span class="comment-author">author</span>446 <a class="comment-time" href="#demo-comment-2"><time datetime="2026-09-04T18:30:00Z">4 Sep 2026 · 11:30</time></a>447 </p>448 <div class="comment-body"><p>Will do!</p></div>449 <a class="comment-link" href="#post">reply →</a>450 </article>451 </li>452 </ol>453 </article>454 </li>455 </ol>456 <div class="social-foot">457 <a class="comment-link" href="#post">comment by email →</a>458 <p class="meta">Start with a "name:" line for your display name. Your email is never shown or stored</p>459 </div>460 </section>461 </div>462423463 <div class="demo">424464 <p class="demo-label">.post-banner (optional, first in the article; --high / --low / --left / --right move the crop, on the banner or one photo)</p>425465 <article>
internal/template.html
+5 −0
@@ -78,6 +78,11 @@7878 Body text.7979 </p>8080 </section>8182 <!-- filled in by social/functions/_middleware.js -->83 <section class="post-social" id="comments" data-social aria-label="likes and comments">84 <p class="meta">likes and comments unavailable</p>85 </section>8186 </article>82878388 <!-- remove whichever card has no post yet -->
mise.toml
+16 −0
@@ -1,8 +1,24 @@11[tools]22node = "latest"33"npm:five-server" = "latest"4"npm:wrangler" = "4"4556# mise run serve67[tasks.serve]78description = "Run the site in live-reload mode"89run = "five-server --port=8080"1011# mise run social-dev12[tasks.social-dev]13description = "Run the site with likes and comments, on a local d1"14dir = "social"15run = [16 "wrangler d1 execute saturn-social --local --file schema.sql",17 "wrangler pages dev --port=8788",18]1920# mise run social-email21[tasks.social-email]22description = "Deploy the comment email worker"23dir = "social"24run = ["npm ci", "wrangler deploy -c email.toml"]
now/index.html
+4 −0
@@ -264,6 +264,10 @@264264 near future! Come back soon265265 </p>266266 </section>267268 <section class="post-social" id="comments" data-social="/now/sep-2026/" aria-label="likes and comments">269 <p class="meta">likes and comments unavailable</p>270 </section>267271 </article>268272269273 <nav class="pager" aria-label="post navigation">
now/jan-2026/index.html
+4 −0
@@ -177,6 +177,10 @@177177178178 <p>So here's to 2026</p>179179 </section>180181 <section class="post-social" id="comments" data-social aria-label="likes and comments">182 <p class="meta">likes and comments unavailable</p>183 </section>180184 </article>181185182186 <nav class="pager" aria-label="post navigation">
now/sep-2026/index.html
+4 −0
@@ -151,6 +151,10 @@151151 in the near future! Come back soon152152 </p>153153 </section>154155 <section class="post-social" id="comments" data-social aria-label="likes and comments">156 <p class="meta">likes and comments unavailable</p>157 </section>154158 </article>155159156160 <nav class="pager" aria-label="post navigation">
privacy/index.html
+69 −43
@@ -5,7 +5,7 @@55 <meta name="viewport" content="width=device-width, initial-scale=1.0" />66 <meta77 name="description"8 content="daniel daum - software engineer based in oakland, ca"8 content="What danieldaum.net keeps about you: no tracking, a daily like code, and the comments you send"99 />1010 <meta1111 http-equiv="Content-Security-Policy"@@ -46,14 +46,14 @@4646 title="daniel daum"4747 href="https://danieldaum.net/feed.xml"4848 />49 <title>daniel daum</title>49 <title>daniel daum - privacy</title>50505151 <meta property="og:type" content="website" />5252 <meta property="og:site_name" content="daniel daum" />53 <meta property="og:title" content="daniel daum" />53 <meta property="og:title" content="daniel daum - privacy" />5454 <meta5555 property="og:description"56 content="daniel daum - software engineer based in oakland, ca"56 content="What danieldaum.net keeps about you: no tracking, a daily like code, and the comments you send"5757 />5858 <meta property="og:url" content="https://danieldaum.net/privacy/" />5959 <meta@@ -69,10 +69,10 @@6969 />70707171 <meta name="twitter:card" content="summary_large_image" />72 <meta name="twitter:title" content="daniel daum" />72 <meta name="twitter:title" content="daniel daum - privacy" />7373 <meta7474 name="twitter:description"75 content="daniel daum - software engineer based in oakland, ca"75 content="What danieldaum.net keeps about you: no tracking, a daily like code, and the comments you send"7676 />7777 <meta7878 name="twitter:image"@@ -100,56 +100,82 @@100100101101 <!-- ===== MAIN ===== -->102102 <main id="main">103 <header class="page-header">104 <h1><span aria-hidden="true">/</span>privacy</h1>105 <p class="meta meta-split">106 <span>the privacy policy</span107 ><span class="meta-sep" aria-hidden="true"> | </span108 ><span>13 October 2026</span>109 </p>110 </header>111 <section>112 <p>113 There are no analytics, no tracking, no cookies, and no ads.114 I don't know who visits this site.115 </p>103 <article>104 <header class="page-header page-header--post">105 <p class="page-header-kicker">106 <span aria-hidden="true">/</span>privacy107 </p>108 <h1>Privacy Policy</h1>109 <p class="meta caps">110 <time datetime="2026-10-15">15 October 2026</time>111 </p>112 </header>116113117 <p>118 The one thing kept on your device is the name of the colour119 theme you last saw, in your browser's storage, so your next120 visit can get a different one. It isn't a cookie, it never121 leaves your browser, and clearing this site's data resets122 it.123 </p>114 <section>115 <h2 class="caps">Trackers and analytics</h2>116 <p>117 There are no analytics, no tracking, no cookies, and no118 ads. I don't know who visits this site.119 </p>124120125 <p>126 This site is hosted on Cloudflare Pages, so Cloudflare sees127 your IP address and the page you asked for. I haven't128 enabled request logging, so I never see your IP. Cloudflare's129 privacy policy is130 <a href="https://www.cloudflare.com/privacypolicy/">here</a131 >.132 </p>133 <p>If you email me, I have your email. That's it.</p>121 <p>122 The one thing kept on your device is the name of the123 colour theme you last saw, in your browser's storage, so124 your next visit can get a different one. It isn't a125 cookie, it never leaves your browser, and clearing this126 site's data resets it.127 </p>134128135 <p>Daniel</p>136 </section>129 <p>130 This site is hosted on Cloudflare Pages, so Cloudflare131 sees your IP address and the page you asked for. I132 haven't enabled request logging, so I never see your IP.133 Cloudflare's privacy policy is134 <a href="https://www.cloudflare.com/privacypolicy/"135 >here</a136 >.137 </p>138139 <h2 class="caps">Likes</h2>140 <p>141 If you like a post, I store a count for that page, and a142 scrambled code made from your IP, browser, and the date,143 so you can't like twice in a day. It can't be turned144 back into your IP, and it's deleted after two days.145 </p>146147 <h2 class="caps">Comments</h2>148 <p>149 Comments come in by email. Your address is only used to150 check if it's me, then it's gone. I keep your name, your151 comment, and the time, and all of it shows on the post.152 Cloudflare's email log keeps the sender for a bit. Email153 me if you want your comment taken down.154 </p>155156 <h2 class="caps">Email</h2>157 <p>If you email me, I have your email. That's it.</p>158159 <p>Daniel</p>160 </section>161 </article>137162 </main>163138164 <!-- ===== FOOTER ===== -->139165 <footer>140166 <nav aria-label="site links">141167 <p aria-hidden="true">//</p>142 <a href="mailto:daniel@danieldaum.net"> email </a>168 <a href="mailto:daniel@danieldaum.net">email</a>143169 <a144170 href="https://tangled.org/danieldaum.net"145171 aria-label="git (opens in new tab)"146172 target="_blank"147173 rel="noopener noreferrer"148 >git149 </a>150 <a href="/pgp.asc" aria-label="PGP public key (516E97FF)">151 PGP152 </a>174 >git</a175 >176 <a href="/pgp.asc" aria-label="PGP public key (516E97FF)"177 >PGP</a178 >153179 <a href="/changelog/">changelog</a>154180 <a href="/privacy/">privacy</a>155181 <a href="/feed.xml">feed</a>
projects/saturn/index.html
+5 −1
@@ -496,7 +496,7 @@496496 </li>497497 <li>498498 <p>499 The theme switcher in theme.js was written by an499 Comments, likes, and theme switcher in theme.js was written by an500500 LLM. I’m counting that as stealing too.501501 </p>502502 </li>@@ -532,6 +532,10 @@532532 </p>533533 <p>- Daniel</p>534534 </section>535536 <section class="post-social" id="comments" data-social aria-label="likes and comments">537 <p class="meta">likes and comments unavailable</p>538 </section>535539 </main>536540537541 <!-- ===== FOOTER ===== -->
social/README.mdadded
+83 −0
@@ -0,0 +1,83 @@1# social23likes and comments. everything for them lives in this folder, and none of it is served as a file.45## files67| file | what it does |8| --- | --- |9| `lib.js` | shared by everything: which pages are allowed, hashing, the html that gets written into a page |10| `functions/_middleware.js` | runs before a page is served and fills its `data-social` section from d1 |11| `functions/api/like.js` | the like button posts here |12| `functions/api/moderate.js` | the approve/delete page linked from new-comment emails |13| `email.js` | email worker: turns mail sent to `reply@replies.danieldaum.net` into comments |14| `schema.sql` | the d1 tables: `Likes`, `LikeVoters`, `Comments` |15| `wrangler.toml` | pages config (d1 binding) |16| `email.toml` | email worker config (d1 + send-email bindings) |17| `/_routes.json` | at the site root, because pages only reads it there. the paths the functions run on |1819## how it works2021**a page.** a visitor opens `/now/sep-2026/`. the path is in `_routes.json`, so `_middleware.js` runs. it finds `<section data-social>`, reads the like count and approved comments from d1, and writes them in. if anything fails, the page shows its fallback text ("likes and comments unavailable").2223**a like.** the heart is a plain form (no js) that posts the page path to `/api/like`. the visitor is identified by a hash of ip + browser + today's date, so they get one like per page per day. the hash can't be reversed and is deleted after two days. a second like the same day does nothing.2425**a comment.** "comment by email" opens a mailto with the post's url as the subject. cloudflare email routing hands the mail to `email.js`, which:26271. drops it if it fails dkim/spf, or if 20 comments already came in during the last hour (site-wide)282. bounces it if the subject isn't a real post, the `name:` line is missing, or it's empty, too long, or has more than 2 links293. cuts off quoted replies and signatures, then saves the name, comment, page and time. the sender's address is never saved304. comments without links go live straight away. ones with a link wait for approval315. emails me the comment with a signed link to `/api/moderate`3233**moderating.** the link opens a page with approve/delete buttons. deleting removes the comment and its replies. replying to the notification email posts my answer under that comment, marked "author".3435**replies** nest one level deep. a reply to a reply goes under the same top comment.3637## adding likes and comments to a page3839put this at the end of the post, inside `<article>` if it has one. the template already has it:4041```html42<section class="post-social" id="comments" data-social aria-label="likes and comments">43 <p class="meta">likes and comments unavailable</p>44</section>45```4647this works on `/about/`, `/now/<slug>/`, `/blog/<slug>/` and `/projects/<slug>/`. take the section out and the page has none.4849`/now/` is a copy of the newest edition, so it points at that edition: `data-social="/now/<slug>/"`. update it with each new now post. comments always go on the edition, never on `/now/`.5051### a new kind of page (e.g. `/books/<slug>/`)52531. add it to `isLikeable()` in `lib.js`: `(blog|now|projects)` → `(blog|now|projects|books)`542. add `"/books/*"` to `/_routes.json`. every path in there runs a function and isn't cached, so keep it narrow553. add the section to the pages564. `mise run social-email`: the worker uses `isLikeable()` too, so it rejects comments for the new pages until it's redeployed5758## deploying5960- **functions:** automatic. on every push, ci (`.tangled/workflows/deploy.yml`) runs wrangler from this folder61- **email worker:** `mise run social-email`, only when `email.js`, `lib.js` or `email.toml` change62- **secret:** `SOCIAL_SECRET` signs moderation links and like hashes. it's set on both the pages project and the worker:63 - `wrangler pages secret put SOCIAL_SECRET --project-name saturn`64 - `wrangler secret put SOCIAL_SECRET -c email.toml`6566## locally67681. `echo 'SOCIAL_SECRET=anything' > .dev.vars` in this folder (gitignored)692. `mise run social-dev`, then open localhost:87887071this uses a local, empty d1 in `.wrangler/`. comments can't be tested locally, but likes and the moderate page can.7273## looking at the data7475run these from this folder:7677```78wrangler d1 execute saturn-social --remote --command "SELECT page, count FROM Likes"79wrangler d1 execute saturn-social --remote --command "SELECT id, page, name, approved FROM Comments ORDER BY created_at DESC LIMIT 10"80wrangler tail saturn-replies-inbound # live worker logs, for when an email doesn't show up81```8283to take a comment down without the email: `DELETE FROM Comments WHERE id = '...' OR parent = '...'`.
social/email.jsadded
+188 −0
@@ -0,0 +1,188 @@1// email worker: cloudflare email routing hands it everything sent to2// reply@replies.danieldaum.net. a good comment is saved (live, or held if it3// has a link) and daniel gets an email to approve or delete it.4// fixable mistakes bounce; anything that looks like abuse is dropped silently,5// since a bounce would go to a forged address.6// the sender's address is only used for the author check, never stored78import PostalMime from "postal-mime";9import { EmailMessage } from "cloudflare:email";10import { SITE, REPLY_TO, hmac, isLikeable } from "./lib.js";1112const AUTHOR = "daniel@danieldaum.net";13const NOTIFY_FROM = "notify@replies.danieldaum.net";1415// "re: https://danieldaum.net/now/sep-2026/", plus "#comment-<id>" for a reply16const SUBJECT_RE = /^\s*(?:re:\s*)*https:\/\/danieldaum\.net(\/[a-z0-9\/-]*)(?:#comment-([0-9a-f-]{36}))?\s*$/i;1718const MAX_PER_HOUR = 20;19const MAX_BODY = 2000;20const MAX_LINKS = 2;21const MAX_NAME = 40;2223export default {24 async email(message, env) {25 const auth = (message.headers.get("Authentication-Results") || "").toLowerCase();26 if (!auth.includes("dkim=pass") || !(auth.includes("spf=pass") || auth.includes("dmarc=pass"))) {27 console.log("drop: failed authentication");28 return;29 }3031 // site-wide, so nothing per sender is kept32 const since = new Date(Date.now() - 60 * 60 * 1000).toISOString();33 const recent = await env.DB.prepare("SELECT COUNT(*) AS n FROM Comments WHERE created_at > ?").bind(since).first();34 if (recent.n >= MAX_PER_HOUR) {35 console.log("drop: hourly cap");36 return;37 }3839 const email = await PostalMime.parse(message.raw);4041 // /now/ itself moves to the next edition, so comments go on the edition42 const match = (email.subject || "").match(SUBJECT_RE);43 const page = match ? match[1].toLowerCase() : "";44 if (!isLikeable(page) || page === "/now/" || !(await pageExists(env, page))) {45 message.setReject("Please use the reply link on the post, so the subject is the post's address");46 return;47 }4849 // one level of nesting; unknown ids become top-level50 const parent = match[2] ? await topLevelParent(env, match[2].toLowerCase(), page) : null;5152 const { name, body } = cleanBody(email);53 const isAuthor = (email.from?.address || "").trim().toLowerCase() === AUTHOR && fromMyDomain(email);54 if (!name && !isAuthor) {55 message.setReject(`Please start your comment with a line like "name: sam". That name is shown with your comment`);56 return;57 }58 if (body.length < 2 || body.length > MAX_BODY) {59 message.setReject(`Comments must be between 2 and ${MAX_BODY} characters`);60 return;61 }62 const links = (body.match(/https?:\/\//g) || []).length;63 if (links > MAX_LINKS) {64 message.setReject(`Comments can have at most ${MAX_LINKS} links`);65 return;66 }6768 // links are what spam is for, so those wait for approval69 const approved = isAuthor || links === 0;70 const id = crypto.randomUUID();71 const shownName = isAuthor ? "daniel" : name;72 await env.DB.prepare("INSERT INTO Comments (id, page, parent, name, body, is_author, approved, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)")73 .bind(id, page, parent, shownName, body, isAuthor ? 1 : 0, approved ? 1 : 0, new Date().toISOString())74 .run();7576 // every comment, mine too, so each one has a delete link77 try {78 const sig = await hmac(env.SOCIAL_SECRET, "moderate:" + id);79 const link = `${env.SITE_ORIGIN || SITE}/api/moderate?id=${id}&sig=${sig}`;80 await env.NOTIFY.send(new EmailMessage(NOTIFY_FROM, AUTHOR, notification({ page, id, name: shownName, body, approved, link })));81 } catch (err) {82 console.log("notify failed: " + (err?.message || err));83 }84 },85};8687// ===== checks =====8889// only cloudflare's own result counts: it strips forged headers carrying its id90function fromMyDomain(email) {91 return email.headers.some(92 (h) => h.key === "authentication-results" && /^\s*mx\.cloudflare\.net;/i.test(h.value) && /\bdmarc=pass\b[^;]*\bheader\.from=danieldaum\.net\b/i.test(h.value)93 );94}9596// SITE_ORIGIN (.dev.vars) points at wrangler pages dev when testing locally97async function pageExists(env, page) {98 try {99 const res = await fetch((env.SITE_ORIGIN || SITE) + page, { method: "HEAD" });100 return res.status === 200;101 } catch {102 return false;103 }104}105106async function topLevelParent(env, id, page) {107 const row = await env.DB.prepare("SELECT page, parent FROM Comments WHERE id = ? AND approved = 1").bind(id).first();108 if (!row || row.page !== page) return null;109 return row.parent || id;110}111112// ===== text =====113114// plain text without quoted mail or signatures. an optional "name: ..."115// first line sets the display name. escaped later, when rendered116function cleanBody(email) {117 const text = (email.text?.trim() ? email.text : htmlToText(email.html || "")).replace(/\r\n?/g, "\n");118 const lines = text.split("\n");119120 let name = "";121 const kept = [];122 for (let i = 0; i < lines.length; i++) {123 const line = lines[i].trimEnd();124 const t = line.trim();125126 // gmail can wrap "On <date> <name> wrote:" over two lines127 if (128 /^On\s.*wrote:$/.test(t) ||129 (/^On\s/.test(t) && /wrote:$/.test((lines[i + 1] || "").trim())) ||130 /^-{2,}\s*(original|forwarded) message/i.test(t) ||131 /^From:\s/.test(t) ||132 /^_{5,}$/.test(t) ||133 t === "--" ||134 /reply above this line/i.test(t) ||135 /^sent from my /i.test(t)136 ) {137 break;138 }139 if (t.startsWith(">")) continue;140141 const nameLine = t.match(/^name:\s*(.*)$/i);142 if (nameLine && !name && !kept.some((k) => k.trim())) {143 name = nameLine[1];144 continue;145 }146 kept.push(line);147 }148149 name = name.replace(/[\x00-\x1f\x7f]/g, "").replace(/\s+/g, " ").trim().slice(0, MAX_NAME);150 const body = kept.join("\n").replace(/\n{3,}/g, "\n\n").trim();151 return { name, body };152}153154function htmlToText(html) {155 return html156 .replace(/<(script|style)[\s\S]*?<\/\1>/gi, "")157 .replace(/<br\s*\/?>/gi, "\n")158 .replace(/<\/(p|div|li|blockquote|h[1-6]|tr)>/gi, "\n")159 .replace(/<[^>]+>/g, "")160 .replace(/ /g, " ")161 .replace(/</g, "<")162 .replace(/>/g, ">")163 .replace(/"/g, '"')164 .replace(/'/g, "'")165 .replace(/&/g, "&");166}167168// ===== notification =====169170// replying to it posts an answer under the comment. the marker line keeps the171// quoted notification out of that answer172function notification({ page, id, name, body, approved, link }) {173 const headers = [174 `From: ${NOTIFY_FROM}`,175 `To: ${AUTHOR}`,176 `Reply-To: ${REPLY_TO}`,177 `Subject: re: ${SITE}${page}#comment-${id}`,178 `Date: ${new Date().toUTCString().replace(/GMT$/, "+0000")}`,179 `Message-ID: <${crypto.randomUUID()}@replies.danieldaum.net>`,180 `MIME-Version: 1.0`,181 `Content-Type: text/plain; charset=utf-8`,182 `Content-Transfer-Encoding: 8bit`,183 ];184 const status = approved ? "It is live." : "It has a link, so it is waiting for approval.";185 const action = approved ? "Delete" : "Approve or delete";186 const text = [`## reply above this line to answer on the site ##`, ``, `${name} commented on ${page}:`, ``, body, ``, status, `${action}: ${link}`, ``].join("\n");187 return headers.join("\r\n") + "\r\n\r\n" + text.replace(/\n/g, "\r\n");188}
social/email.tomladded
+14 −0
@@ -0,0 +1,14 @@1# email worker. keeps the old name so the email routing rule still points here2name = "saturn-replies-inbound"3main = "email.js"4compatibility_date = "2026-09-01"5workers_dev = false67[[d1_databases]]8binding = "DB"9database_name = "saturn-social"10database_id = "2cc8bddd-d422-4d1e-8480-c1c75c8d02b0"1112[[send_email]]13name = "NOTIFY"14destination_address = "daniel@danieldaum.net"
social/functions/_middleware.jsadded
+49 −0
@@ -0,0 +1,49 @@1// fills [data-social] with likes and comments from d1. if anything fails the2// page keeps its fallback text. runs on the paths in /_routes.json34import { isLikeable, voterId, renderSocial } from "../lib.js";56export async function onRequest(context) {7 const { request, env } = context;8 const { pathname } = new URL(request.url);9 if (!isLikeable(pathname)) return context.next();1011 // the file never changes, so a 304 would show stale counts12 const fresh = new Request(request);13 fresh.headers.delete("If-None-Match");14 fresh.headers.delete("If-Modified-Since");15 const response = await context.next(fresh);16 if (!(response.headers.get("content-type") || "").includes("text/html")) return response;1718 let voter;19 try {20 voter = await voterId(env.SOCIAL_SECRET, request);21 } catch {22 return response;23 }2425 const page = new HTMLRewriter()26 .on("[data-social]", {27 async element(el) {28 // /now/ shows the current edition's, e.g. data-social="/now/sep-2026/"29 const key = el.getAttribute("data-social") || pathname;30 if (!isLikeable(key)) return;31 try {32 const [count, liked, comments] = await env.DB.batch([33 env.DB.prepare("SELECT count FROM Likes WHERE page = ?").bind(key),34 env.DB.prepare("SELECT 1 FROM LikeVoters WHERE page = ? AND voter = ?").bind(key, voter),35 env.DB.prepare("SELECT id, parent, name, body, is_author, created_at FROM Comments WHERE page = ? AND approved = 1 ORDER BY created_at").bind(key),36 ]);37 const likes = { count: Number(count.results[0]?.count ?? 0), liked: liked.results.length > 0 };38 el.setInnerContent(renderSocial(key, likes, comments.results), { html: true });39 } catch {}40 },41 })42 .transform(response);4344 // per visitor, so no shared or back-button copies45 const out = new Response(page.body, page);46 out.headers.set("Cache-Control", "private, no-cache");47 out.headers.delete("ETag");48 return out;49}
social/functions/api/like.jsadded
+37 −0
@@ -0,0 +1,37 @@1// POST /api/like. no GET, so crawlers and prefetchers can't like23import { isLikeable, voterId } from "../../lib.js";45const TWO_DAYS = 2 * 24 * 60 * 60 * 1000;67export async function onRequestPost({ request, env }) {8 let path;9 try {10 path = (await request.formData()).get("path");11 } catch {12 return plain("bad request", 400);13 }14 if (typeof path !== "string" || !isLikeable(path)) return plain("bad request", 400);1516 // no rows for pages that don't exist17 const exists = await env.ASSETS.fetch(new Request(new URL(path, request.url)));18 if (exists.status !== 200) return plain("not found", 404);1920 const now = new Date();21 const voter = await voterId(env.SOCIAL_SECRET, request);22 const [inserted] = await env.DB.batch([23 env.DB.prepare("INSERT OR IGNORE INTO LikeVoters (page, voter, created_at) VALUES (?, ?, ?)").bind(path, voter, now.toISOString()),24 env.DB.prepare("DELETE FROM LikeVoters WHERE created_at < ?").bind(new Date(now - TWO_DAYS).toISOString()),25 ]);2627 // a second like today does nothing28 if (inserted.meta.changes === 1) {29 await env.DB.prepare("INSERT INTO Likes (page, count) VALUES (?, 1) ON CONFLICT(page) DO UPDATE SET count = count + 1").bind(path).run();30 }3132 return new Response(null, { status: 303, headers: { Location: path + "#likes" } });33}3435function plain(body, status) {36 return new Response(body, { status, headers: { "Content-Type": "text/plain; charset=utf-8" } });37}
social/functions/api/moderate.jsadded
+88 −0
@@ -0,0 +1,88 @@1// /api/moderate: where the link in a new-comment email goes. GET only shows2// the comment, since mail apps open links on their own; the buttons POST.3// both need the signature from the email45import { hmacMatches, bodyHtml, escapeHtml } from "../../lib.js";67const ID_RE = /^[0-9a-f-]{36}$/;89export async function onRequestGet({ request, env }) {10 const params = new URL(request.url).searchParams;11 const id = params.get("id");12 const sig = params.get("sig");13 if (!(await authorized(env, id, sig))) return forbidden();1415 const comment = await env.DB.prepare("SELECT page, name, body, approved FROM Comments WHERE id = ?").bind(id).first();16 if (!comment) return page(`<p>This comment has already been deleted.</p>`);1718 const hidden = `<input type="hidden" name="id" value="${id}" /><input type="hidden" name="sig" value="${escapeHtml(sig)}" />`;19 const button = (action) => `<form method="POST">${hidden}<button class="like-button" name="action" value="${action}">${action}</button></form>`;20 return page(`21 <p class="meta">${escapeHtml(comment.name)} on <a href="${comment.page}">${comment.page}</a>, ${comment.approved ? "live" : "waiting for approval"}</p>22 <blockquote>${bodyHtml(comment.body)}</blockquote>23 <div class="moderate-actions">${comment.approved ? "" : button("approve")}${button("delete")}</div>`);24}2526export async function onRequestPost({ request, env }) {27 let form;28 try {29 form = await request.formData();30 } catch {31 return forbidden();32 }33 const id = form.get("id");34 if (!(await authorized(env, id, form.get("sig")))) return forbidden();3536 const comment = await env.DB.prepare("SELECT page FROM Comments WHERE id = ?").bind(id).first();37 if (!comment) return page(`<p>This comment has already been deleted.</p>`);3839 if (form.get("action") === "approve") {40 await env.DB.prepare("UPDATE Comments SET approved = 1 WHERE id = ?").bind(id).run();41 return new Response(null, { status: 303, headers: { Location: `${comment.page}#comment-${id}` } });42 }4344 // replies go with it45 await env.DB.prepare("DELETE FROM Comments WHERE id = ? OR parent = ?").bind(id, id).run();46 return page(`<p>Deleted. <a href="${comment.page}">Back to the post</a></p>`);47}4849async function authorized(env, id, sig) {50 return typeof id === "string" && ID_RE.test(id) && (await hmacMatches(env.SOCIAL_SECRET, "moderate:" + id, sig));51}5253function forbidden() {54 return new Response("forbidden", { status: 403, headers: { "Content-Type": "text/plain; charset=utf-8" } });55}5657// stored pages passed isLikeable(), so they are safe as-is58function page(content) {59 return new Response(60 `<!doctype html>61<html lang="en">6263<head>64 <meta charset="UTF-8" />65 <meta name="viewport" content="width=device-width, initial-scale=1.0" />66 <meta name="robots" content="noindex" />67 <meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'self'; font-src 'self';" />68 <meta name="referrer" content="no-referrer" />69 <link rel="stylesheet" href="/global.css" />70 <link rel="icon" type="image/png" sizes="32x32" href="/assets/favicon/favicon-32x32.png" />71 <title>daniel daum - moderate</title>72</head>7374<body>75 <main id="main">76 <header class="page-header">77 <h1><span aria-hidden="true">/</span>moderate</h1>78 </header>79 <section>${content}80 </section>81 </main>82</body>8384</html>85`,86 { headers: { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store" } }87 );88}
social/lib.jsadded
+122 −0
@@ -0,0 +1,122 @@1// shared by the pages functions and the email worker23export const SITE = "https://danieldaum.net";4export const REPLY_TO = "reply@replies.danieldaum.net";56// /about/, /now/, /now/<slug>/, /blog/<slug>/, /projects/<slug>/7export function isLikeable(path) {8 return /^\/(about|now)\/$|^\/(blog|now|projects)\/[a-z0-9-]+\/$/.test(path);9}1011// ===== hmac =====1213export async function hmac(secret, message) {14 if (!secret) throw new Error("SOCIAL_SECRET is not set");15 const enc = new TextEncoder();16 const key = await crypto.subtle.importKey("raw", enc.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);17 const sig = await crypto.subtle.sign("HMAC", key, enc.encode(message));18 return [...new Uint8Array(sig)].map((b) => b.toString(16).padStart(2, "0")).join("");19}2021// constant time22export async function hmacMatches(secret, message, sig) {23 const expected = await hmac(secret, message);24 if (typeof sig !== "string" || sig.length !== expected.length) return false;25 let diff = 0;26 for (let i = 0; i < sig.length; i++) diff |= sig.charCodeAt(i) ^ expected.charCodeAt(i);27 return diff === 0;28}2930// one like per visitor per page per day: ip + browser + date, hashed.31// no cookies, nothing reversible, stops matching at utc midnight32export function voterId(secret, request) {33 const ip = request.headers.get("CF-Connecting-IP") || "";34 const ua = request.headers.get("User-Agent") || "";35 return hmac(secret, `${ip}|${ua}|${new Date().toISOString().slice(0, 10)}`);36}3738// ===== html =====3940export function escapeHtml(str) {41 return String(str).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);42}4344// blank lines split paragraphs, single newlines become <br>45export function bodyHtml(body) {46 return body47 .split(/\n{2,}/)48 .map((para) => `<p>${escapeHtml(para).replace(/\n/g, "<br />")}</p>`)49 .join("");50}5152// what goes inside [data-social]. key has passed isLikeable(), so it is safe as-is53export function renderSocial(key, likes, rows) {54 const replies = new Map();55 for (const row of rows) {56 if (row.parent) replies.set(row.parent, [...(replies.get(row.parent) || []), row]);57 }58 const top = rows.filter((row) => !row.parent);59 const title = rows.length === 0 ? "no comments yet" : rows.length === 1 ? "1 comment" : `${rows.length} comments`;6061 const thread = (list) => `<ol class="comment-thread">${list.map((row) => `<li>${comment(row)}</li>`).join("")}</ol>`;62 const comment = (row) => {63 const id = `comment-${row.id}`;64 const kids = replies.get(row.id);65 return `<article class="comment" id="${id}">66 <p class="meta">67 <span class="comment-name">${escapeHtml(row.name)}</span>${row.is_author ? `<span class="comment-author">author</span>` : ""}68 <a class="comment-time" href="#${id}"><time datetime="${escapeHtml(row.created_at)}">${when(row.created_at)}</time></a>69 </p>70 <div class="comment-body">${bodyHtml(row.body)}</div>71 <a class="comment-link" href="${mailto(key + "#" + id)}">reply →</a>72 ${kids ? thread(kids) : ""}73</article>`;74 };7576 return `<div class="social-head">77 <h2 class="social-title">${title}</h2>78 ${likeForm(key, likes)}79</div>80${top.length ? thread(top) : ""}81<div class="social-foot">82 <a class="comment-link" href="${mailto(key)}">comment by email →</a>83 <p class="meta">Start with a "name:" line for your display name. Your email is never shown or stored</p>84</div>`;85}8687function likeForm(key, { count, liked }) {88 const noun = count === 1 ? "like" : "likes";89 const label = liked ? `you liked this post, ${count} ${noun}` : `like this post, ${count} ${noun}`;90 const state = liked ? ` disabled aria-pressed="true"` : "";91 return `<form class="like-form" id="likes" method="POST" action="/api/like">92 <input type="hidden" name="path" value="${key}" />93 <button type="submit" class="like-button" aria-label="${label}"${state}>${HEART} ${count}</button>94 </form>`;95}9697// feather icons, mit98const HEART = `<svg class="like-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z" /></svg>`;99100// the email worker reads the subject to know where a comment goes101function mailto(target) {102 const subject = encodeURIComponent(`re: ${SITE}${target}`);103 return `mailto:${REPLY_TO}?subject=${subject}&body=${encodeURIComponent("name: ")}`;104}105106// "4 Sep 2026 · 09:12", oakland time107function when(iso) {108 const p = Object.fromEntries(109 new Intl.DateTimeFormat("en-GB", {110 timeZone: "America/Los_Angeles",111 day: "numeric",112 month: "short",113 year: "numeric",114 hour: "2-digit",115 minute: "2-digit",116 hourCycle: "h23",117 })118 .formatToParts(new Date(iso))119 .map((part) => [part.type, part.value])120 );121 return `${p.day} ${p.month} ${p.year} · ${p.hour}:${p.minute}`;122}
social/package-lock.jsonadded
+19 −0
@@ -0,0 +1,19 @@1{2 "name": "saturn-social",3 "lockfileVersion": 3,4 "requires": true,5 "packages": {6 "": {7 "name": "saturn-social",8 "dependencies": {9 "postal-mime": "2.4.3"10 }11 },12 "node_modules/postal-mime": {13 "version": "2.4.3",14 "resolved": "https://registry.npmjs.org/postal-mime/-/postal-mime-2.4.3.tgz",15 "integrity": "sha512-KT8P+/We7LH48EhjmLRLEiQx+HI6zZ5TTeuzhuZkMbcJnp9mdmxm/FgiRIzmhZm8mxmk8mtisIAelq1wNwumxg==",16 "license": "MIT-0"17 }18 }19}
social/package.jsonadded
+8 −0
@@ -0,0 +1,8 @@1{2 "name": "saturn-social",3 "private": true,4 "type": "module",5 "dependencies": {6 "postal-mime": "2.4.3"7 }8}
social/schema.sqladded
+28 −0
@@ -0,0 +1,28 @@1-- likes: one row per post2CREATE TABLE IF NOT EXISTS Likes (3 page TEXT PRIMARY KEY,4 count INTEGER NOT NULL DEFAULT 05);67-- who liked what today: a daily-rotating hash, never an ip or email8CREATE TABLE IF NOT EXISTS LikeVoters (9 page TEXT NOT NULL,10 voter TEXT NOT NULL,11 created_at TEXT NOT NULL,12 PRIMARY KEY (page, voter)13);1415-- comments: arrive by email. ones with links are hidden until approved.16-- nothing about the sender is kept, not even a hash of their address17CREATE TABLE IF NOT EXISTS Comments (18 id TEXT PRIMARY KEY,19 page TEXT NOT NULL,20 parent TEXT,21 name TEXT NOT NULL,22 body TEXT NOT NULL,23 is_author INTEGER NOT NULL DEFAULT 0,24 approved INTEGER NOT NULL DEFAULT 0,25 created_at TEXT NOT NULL26);2728CREATE INDEX IF NOT EXISTS idx_comments_page ON Comments (page, approved, created_at);
social/wrangler.tomladded
+9 −0
@@ -0,0 +1,9 @@1# pages functions. ci deploys from this folder (see deploy.yml)2name = "saturn"3pages_build_output_dir = ".."4compatibility_date = "2026-09-01"56[[d1_databases]]7binding = "DB"8database_name = "saturn-social"9database_id = "2cc8bddd-d422-4d1e-8480-c1c75c8d02b0"