Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "moshcode.sh",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"description": "moshcode.sh \u2014 the home page for moshcode, a metal wrapper CLI for agentic coding",
"description": "moshcode.sh — the home page for moshcode, a metal wrapper CLI for agentic coding",
"type": "module",
"license": "MIT",
"scripts": {
Expand All @@ -13,7 +13,6 @@
"check": "bun scripts/sync-commands.mjs --check"
},
"dependencies": {
"@profullstack/footer": "latest",
"express": "5.1.0"
},
"packageManager": "bun@1.4.0"
Expand Down
23 changes: 8 additions & 15 deletions public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,12 @@ h1 {
}

/* ── footer ──────────────────────────────────────────────────────── */
.foot { padding: 52px 0 44px; background: var(--bg-alt); border-top: 1px solid var(--line-soft); }
.foot-grid { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: 32px; }
.foot-brand .brand { font-size: 16px; margin: 0 0 10px; }
.creed { font-family: var(--mono); font-size: 12.5px; color: var(--lime-dim); margin: 0 0 12px; max-width: 34ch; }
.foot-brand .muted { font-size: 13.5px; margin: 0; }
.foot-col { display: flex; flex-direction: column; gap: 9px; }
.foot-head { font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 2px; text-transform: uppercase; }
.foot-col a { font-size: 14px; color: var(--ink-2); text-decoration: none; }
.foot-col a:hover { color: var(--lime); }
.webring { display: flex; gap: 10px; margin: 12px 0 0; font-family: var(--mono); font-size: 12.5px; }
.webring a { color: var(--muted); text-decoration: none; }
.webring a:hover { color: var(--lime); }
@media (max-width: 760px) { .foot-grid { grid-template-columns: 1fr 1fr; } }
.foot { padding: 22px 0; background: var(--bg-alt); border-top: 1px solid var(--line-soft); }
.foot-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px; }
.foot-row .brand { font-size: 14px; margin: 0; }
.foot-row nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.foot-row nav a { font-size: 14px; color: var(--ink-2); text-decoration: none; }
.foot-row nav a:hover { color: var(--lime); }

/* ── blog ────────────────────────────────────────────────────────── */
.post-list { display: grid; gap: 26px; max-width: 760px; }
Expand Down Expand Up @@ -277,7 +270,7 @@ h1 {
.prose .term { margin: 26px 0 28px; }
@media (min-width: 900px) { .prose .term-wide { width: calc(100% + 160px); max-width: none; } }

/* CrawlProof text_link frame above the footer: fluid, 40px, carries its own
/* CrawlProof text_link frame at the top of the content: fluid, 40px, carries its own
"Sponsored" mark. */
.cp-ad { margin-top: 40px; margin-bottom: 40px; }
.cp-ad { margin-top: 24px; margin-bottom: 24px; }
.cp-ad iframe { display: block; width: 100%; height: 40px; border: 0; }
34 changes: 5 additions & 29 deletions src/content.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -265,33 +265,9 @@ while (alive) {
];

export const FOOTER_LINKS = [
{
heading: 'moshcode',
links: [
{ label: 'GitHub', href: 'https://github.com/moshcoder/moshcode' },
{ label: 'Commands', href: '/commands' },
{ label: 'Blog', href: '/blog' },
{ label: 'Install script', href: '/install.sh' },
{ label: 'For agents (llms.txt)', href: '/llms.txt' },
],
},
{
heading: 'the Pit',
links: [
{ label: 'Moshpit Manager', href: 'https://app.moshcode.sh/pit' },
{ label: 'pit.moshcode.sh', href: 'https://pit.moshcode.sh' },
{ label: 'app.moshcode.sh', href: 'https://app.moshcode.sh' },
{ label: 'Moshpit DNS', href: 'https://dns.moshcode.sh/dns-query' },
{ label: 'moshcoding.com', href: 'https://moshcoding.com' },
],
},
{
heading: 'elsewhere',
links: [
{ label: 'X / chovy', href: 'https://x.com/chovy' },
{ label: 'Bluesky', href: 'https://bsky.app/profile/moshcoding.bsky.social' },
{ label: 'YouTube', href: 'https://youtube.com/@moshcoding' },
{ label: 'Twitch', href: 'https://www.twitch.tv/chovyo' },
],
},
{ label: 'GitHub', href: 'https://github.com/moshcoder/moshcode' },
{ label: 'Commands', href: '/commands' },
{ label: 'Blog', href: '/blog' },
{ label: 'install.sh', href: '/install.sh' },
{ label: 'llms.txt', href: '/llms.txt' },
];
45 changes: 35 additions & 10 deletions src/server.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import express from 'express';
import { randomBytes } from 'node:crypto';
import { footerHtml } from '@profullstack/footer';
import { readFileSync } from 'node:fs';
import { resolve, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
Expand All @@ -27,13 +26,40 @@ const PAGES = [
{ path: '/blog', changefreq: 'weekly', priority: '0.8' },
];

const PIT_FOOTER_URL = 'https://pit.world/snippets/footer.html?site=moshcode.sh';
const PIT_FOOTER_TTL_MS = 60 * 60 * 1000;
const pitCache = { html: '', fetchedAt: 0, pending: null };

async function refreshPitFooter() {
try {
const res = await fetch(PIT_FOOTER_URL, { signal: AbortSignal.timeout(3000) });
if (!res.ok) return;
const html = await res.text();
if (html.includes('data-pit-footer')) pitCache.html = html;
} catch {
// keep the last good copy
} finally {
pitCache.fetchedAt = Date.now();
pitCache.pending = null;
}
}

async function pitFooter() {
if (Date.now() - pitCache.fetchedAt > PIT_FOOTER_TTL_MS) {
pitCache.pending ??= refreshPitFooter();
// Only the very first render waits (bounded by the 3 s timeout).
if (!pitCache.html) await pitCache.pending;
}
return pitCache.html;
}

export function createApp() {
const app = express();
app.disable('x-powered-by');
app.set('etag', 'strong');

app.use((_req, res, next) => {
// Per-response nonce for the one inline <style> the shared footer carries.
// Per-response nonce for the one inline <style> the pit.world footer carries.
res.locals.nonce = randomBytes(16).toString('base64');
res.set({
'X-Content-Type-Options': 'nosniff',
Expand All @@ -50,14 +76,13 @@ export function createApp() {
res.json({ status: 'ok', version: VERSION, commands: COMMANDS.commands.length }),
);

// The shared Profullstack footer (copyright + webring), rendered per request
// from @profullstack/footer's @latest template (cached 1 h by the package)
// into the <!--pfs-footer--> slot every page's foot() leaves.
const withFooter = async (res, body) =>
body.replace(
'<!--pfs-footer-->',
await footerHtml({ site: 'https://moshcode.sh/', nonce: res.locals.nonce }),
);
// The pit.world global footer, fetched server-side (cached 1 h, served stale
// or as nothing when pit.world is slow or down) into the <!--pit-footer-->
// slot every page's foot() leaves. Its <style> gets this response's nonce.
const withFooter = async (res, body) => {
const snippet = (await pitFooter()).replace(/<style>/g, `<style nonce="${res.locals.nonce}">`);
return body.replace('<!--pit-footer-->', () => snippet);
};

const html = async (res, body) =>
res
Expand Down
25 changes: 8 additions & 17 deletions src/site.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ ${extraHead}
<a class="nav-cta" href="${esc(SITE.repo)}">GitHub&nbsp;↗</a>
</div>
</header>
<main id="main">`;
<main id="main">
${adUnit()}`;
}

// One CrawlProof ad unit (slot 71955dcb, https://crawlproof.com/ads/slots) on
// every public page, above the footer. This site's CSP allows no inline style
// every public page, at the top of the content (never against the footer). This site's CSP allows no inline style
// and only 'self' images, and ad.js renders into a srcdoc iframe that would
// inherit that policy, so it uses the script-free cross-origin frame instead:
// one frame-src entry, no third-party JS, nothing written to localStorage.
Expand All @@ -104,25 +105,15 @@ export function adUnit() {
}

export function foot() {
return `${adUnit()}
</main>
return `</main>
<footer class="foot">
<div class="wrap foot-grid">
<div class="foot-brand">
<p class="brand"><span class="brand-mark" aria-hidden="true">▚</span> moshcode</p>
<p class="creed">${esc(SITE.creed)}</p>
<p class="muted">MIT licensed. Built by <a href="https://github.com/moshcoder">moshcoder</a>.</p>
</div>
${FOOTER_LINKS.map(
(col) => `<div class="foot-col">
<p class="foot-head">${esc(col.heading)}</p>
${col.links.map((l) => `<a href="${esc(l.href)}">${esc(l.label)}</a>`).join('\n ')}
</div>`,
).join('\n ')}
<div class="wrap foot-row">
<p class="brand"><span class="brand-mark" aria-hidden="true">▚</span> moshcode <span class="muted">· MIT licensed</span></p>
<nav aria-label="Footer">${FOOTER_LINKS.map((l) => `<a href="${esc(l.href)}">${esc(l.label)}</a>`).join('')}</nav>
</div>
</footer>
<!--pfs-footer-->
<script src="/app.js" defer></script>
<!--pit-footer-->
</body>
</html>`;
}
Expand Down
Loading