Skip to content

Curated website design inspiration gallery, open zero-auth MCP server for AI agents, and shareable moodboard lists.

Enable live site submissions via Upstash Redis queue, catalog deduplication, and curator CLI

Ethan49c0b9300c5e
diff --git a/api/mcp.js b/api/mcp.js
index 776d5a6..bcf876c 100644
--- a/api/mcp.js
+++ b/api/mcp.js
@@ -835,6 +835,7 @@ async function executeTool(name, args = {}, ctx = {}) {
},
{
clientKey,
+ env,
token: env.GITHUB_SUBMISSIONS_TOKEN || "",
repo: env.GITHUB_SUBMISSIONS_REPO,
fetchImpl,
diff --git a/api/submit.js b/api/submit.js
index 7b918b8..d35b145 100644
--- a/api/submit.js
+++ b/api/submit.js
@@ -1,4 +1,9 @@
+import { randomBytes } from "node:crypto";
+import sites from "../apps/gallery/sites.json" with { type: "json" };
+
const DEFAULT_REPO = "ethanplusai/designtaste";
+const SITE_ORIGIN = "https://designtaste.wtf";
+export const PENDING_SUBMISSIONS_HASH = "designtaste:submissions:pending";
export const CATEGORIES = [
"AI tools",
@@ -43,6 +48,18 @@ function canonicalKeyFromUrl(u) {
u.search;
}
+const CATALOG_BY_CANONICAL_URL = new Map();
+for (const site of sites) {
+ try {
+ CATALOG_BY_CANONICAL_URL.set(
+ canonicalKeyFromUrl(safePublicWebsite(site.url)),
+ site,
+ );
+ } catch {
+ // Ignore malformed catalog entries if any.
+ }
+}
+
export function extractStructuredIssueUrl(body) {
if (typeof body !== "string") return null;
const match = body.match(/^- \*\*URL\*\*:\s*(\S+)\s*$/m);
@@ -238,11 +255,121 @@ export function buildFallbackIssueUrl(sub, repo = DEFAULT_REPO) {
return `https://github.com/${repo}/issues/new?${params.toString()}`;
}
+async function queueSubmissionInRedis(sub, redis, { fetchImpl = fetch } = {}) {
+ const headers = {
+ Authorization: `Bearer ${redis.token}`,
+ "Content-Type": "application/json",
+ };
+ const checkRes = await fetchImpl(`${redis.url}/pipeline`, {
+ method: "POST",
+ headers,
+ body: JSON.stringify([
+ ["HGET", PENDING_SUBMISSIONS_HASH, sub.normalizedUrl],
+ ["HLEN", PENDING_SUBMISSIONS_HASH],
+ ]),
+ });
+ if (!checkRes?.ok) return null;
+ const checkData = await checkRes.json().catch(() => null);
+ if (!Array.isArray(checkData)) return null;
+
+ const existingRaw = checkData[0]?.result;
+ const pendingCount = Number(checkData[1]?.result) || 0;
+
+ if (typeof existingRaw === "string" && existingRaw) {
+ let existing = {};
+ try {
+ existing = JSON.parse(existingRaw);
+ } catch {
+ existing = {};
+ }
+ const updated = {
+ id: existing.id || `sub_${randomBytes(6).toString("base64url")}`,
+ url: existing.url || sub.url,
+ normalizedUrl: sub.normalizedUrl,
+ host: existing.host || sub.host,
+ name: existing.name || sub.name,
+ category:
+ existing.category && existing.category !== "Uncategorized"
+ ? existing.category
+ : sub.category,
+ note: existing.note || sub.note,
+ votes: (Number(existing.votes) || 1) + 1,
+ submittedAt: existing.submittedAt || new Date().toISOString(),
+ lastVotedAt: new Date().toISOString(),
+ };
+ await fetchImpl(`${redis.url}/pipeline`, {
+ method: "POST",
+ headers,
+ body: JSON.stringify([
+ ["HSET", PENDING_SUBMISSIONS_HASH, sub.normalizedUrl, JSON.stringify(updated)],
+ ]),
+ });
+ return {
+ status: 200,
+ body: {
+ ok: true,
+ duplicate: true,
+ submissionId: updated.id,
+ votes: updated.votes,
+ message: "Already in the curation queue — thanks for the vote!",
+ },
+ };
+ }
+
+ if (pendingCount >= MAX_OPEN_QUEUE_ISSUES) {
+ return {
+ status: 429,
+ retryAfter: 600,
+ body: {
+ ok: false,
+ code: "queue_full",
+ message:
+ "The curation queue is full right now while we review pending sites. Please try again later.",
+ },
+ };
+ }
+
+ const submissionId = `sub_${randomBytes(6).toString("base64url")}`;
+ const record = {
+ id: submissionId,
+ url: sub.url,
+ normalizedUrl: sub.normalizedUrl,
+ host: sub.host,
+ name: sub.name,
+ category: sub.category,
+ note: sub.note,
+ votes: 1,
+ submittedAt: new Date().toISOString(),
+ };
+
+ const writeRes = await fetchImpl(`${redis.url}/pipeline`, {
+ method: "POST",
+ headers,
+ body: JSON.stringify([
+ ["HSET", PENDING_SUBMISSIONS_HASH, sub.normalizedUrl, JSON.stringify(record)],
+ ]),
+ });
+ if (!writeRes?.ok) return null;
+ const writeData = await writeRes.json().catch(() => null);
+ if (!Array.isArray(writeData) || writeData[0]?.error) return null;
+
+ return {
+ status: 201,
+ body: {
+ ok: true,
+ queued: true,
+ submissionId,
+ message: "Submitted — added to the curation queue.",
+ },
+ };
+}
+
export async function handleSubmission(
body,
{
- token = process.env.GITHUB_SUBMISSIONS_TOKEN || "",
- repo = process.env.GITHUB_SUBMISSIONS_REPO || DEFAULT_REPO,
+ env = process.env,
+ token = env.GITHUB_SUBMISSIONS_TOKEN || "",
+ repo = env.GITHUB_SUBMISSIONS_REPO || DEFAULT_REPO,
fetchImpl = fetch,
clientKey = "anonymous",
skipRateLimit = false,
@@ -263,7 +390,7 @@ export async function handleSubmission(
}
if (!skipRateLimit) {
- const rate = await checkPersistentRateLimit(clientKey, { fetchImpl });
+ const rate = await checkPersistentRateLimit(clientKey, { env, fetchImpl });
if (!rate.allowed) {
return {
status: 429,
@@ -277,9 +404,43 @@ export async function handleSubmission(
}
}
+ const published = CATALOG_BY_CANONICAL_URL.get(sub.normalizedUrl);
+ if (published) {
+ return {
+ status: 200,
+ body: {
+ ok: true,
+ alreadyListed: true,
+ siteId: published.id,
+ siteUrl: `${SITE_ORIGIN}/sites/${published.id}/`,
+ message: `${published.name} is already featured in DesignTaste!`,
+ },
+ };
+ }
+
const fallbackUrl = buildFallbackIssueUrl(sub, repo);
if (!token) {
+ const redis = getRedisConfig(env);
+ if (redis) {
+ try {
+ const queued = await queueSubmissionInRedis(sub, redis, { fetchImpl });
+ if (queued) return queued;
+ } catch {
+ // Fall through to upstream error with one-click fallback.
+ }
+ return {
+ status: 502,
+ body: {
+ ok: false,
+ code: "upstream_error",
+ message:
+ "Could not queue the submission right now. Try the one-click fallback below.",
+ fallbackUrl,
+ },
+ };
+ }
+
return {
status: 503,
body: {
diff --git a/apps/gallery/gallery.js b/apps/gallery/gallery.js
index 5b64d45..7b40a51 100644
--- a/apps/gallery/gallery.js
+++ b/apps/gallery/gallery.js
@@ -775,6 +775,12 @@ for (const form of document.querySelectorAll("[data-submit-form]")) {
link.rel = "noopener noreferrer";
link.textContent = "View submission →";
status.append(link);
+ } else if (json.siteUrl) {
+ status.append(document.createTextNode(" "));
+ const link = document.createElement("a");
+ link.href = json.siteUrl;
+ link.textContent = "View in gallery →";
+ status.append(link);
}
form.reset();
} else {
diff --git a/package.json b/package.json
index 61c9168..0dbef5c 100644
--- a/package.json
+++ b/package.json
@@ -22,6 +22,7 @@
"site:capture": "node scripts/capture-site.mjs",
"site:recapture": "node scripts/recapture-gallery.mjs",
"site:from-issue": "node scripts/add-from-issue.mjs",
+ "submissions": "node scripts/submissions.mjs",
"og:render": "node scripts/render-og.mjs"
},
"devDependencies": {
diff --git a/scripts/submissions.mjs b/scripts/submissions.mjs
new file mode 100644
index 0000000..0bff085
--- /dev/null
+++ b/scripts/submissions.mjs
@@ -0,0 +1,190 @@
+#!/usr/bin/env node
+/**
+ * Curator CLI for reviewing, approving, or dismissing website submissions
+ * queued in Upstash Redis via https://designtaste.wtf/submit/ or MCP submit_site.
+ *
+ * Usage:
+ * npm run submissions List all pending submissions
+ * npm run submissions -- approve <id> Capture screenshot, add to catalog, remove from queue
+ * npm run submissions -- dismiss <id> Remove submission from pending queue
+ */
+import fs from "node:fs";
+import path from "node:path";
+import { execFileSync } from "node:child_process";
+import { fileURLToPath } from "node:url";
+import { CATEGORIES, safeWebsite } from "./gallery-catalog.mjs";
+import { assertPublicTargetUrl } from "./capture-lib.mjs";
+import { PENDING_SUBMISSIONS_HASH } from "../api/submit.js";
+
+const ROOT = fileURLToPath(new URL("..", import.meta.url));
+
+function loadLocalEnv() {
+ for (const name of [".env.local", ".env"]) {
+ const filePath = path.join(ROOT, name);
+ if (!fs.existsSync(filePath)) continue;
+ const text = fs.readFileSync(filePath, "utf8");
+ for (const line of text.split(/\r?\n/)) {
+ const trimmed = line.trim();
+ if (!trimmed || trimmed.startsWith("#")) continue;
+ const eq = trimmed.indexOf("=");
+ if (eq === -1) continue;
+ const key = trimmed.slice(0, eq).trim();
+ let val = trimmed.slice(eq + 1).trim();
+ if (
+ (val.startsWith('"') && val.endsWith('"')) ||
+ (val.startsWith("'") && val.endsWith("'"))
+ ) {
+ val = val.slice(1, -1);
+ }
+ if (!process.env[key]) process.env[key] = val;
+ }
+ }
+}
+
+function getRedis() {
+ loadLocalEnv();
+ const url = (
+ process.env.KV_REST_API_URL ||
+ process.env.UPSTASH_REDIS_REST_URL ||
+ ""
+ ).replace(/\/+$/, "");
+ const token =
+ process.env.KV_REST_API_TOKEN || process.env.UPSTASH_REDIS_REST_TOKEN || "";
+ if (!url || !token) {
+ console.error(
+ "Missing KV_REST_API_URL / KV_REST_API_TOKEN.\nRun `vercel env pull .env.local` once to load your Upstash Redis credentials locally.",
+ );
+ process.exit(1);
+ }
+ return { url, token };
+}
+
+async function redisCommand(redis, command) {
+ const res = await fetch(`${redis.url}/pipeline`, {
+ method: "POST",
+ headers: {
+ Authorization: `Bearer ${redis.token}`,
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify([command]),
+ });
+ if (!res.ok) {
+ throw new Error(`Upstash Redis HTTP ${res.status}`);
+ }
+ const data = await res.json();
+ if (data?.[0]?.error) throw new Error(data[0].error);
+ return data?.[0]?.result;
+}
+
+async function fetchAllPending(redis) {
+ const raw = await redisCommand(redis, ["HGETALL", PENDING_SUBMISSIONS_HASH]);
+ const items = [];
+ if (Array.isArray(raw)) {
+ for (let i = 0; i < raw.length; i += 2) {
+ const field = raw[i];
+ const val = raw[i + 1];
+ try {
+ const parsed = JSON.parse(val);
+ items.push({ ...parsed, normalizedUrl: parsed.normalizedUrl || field });
+ } catch {
+ // skip malformed
+ }
+ }
+ } else if (raw && typeof raw === "object") {
+ for (const [field, val] of Object.entries(raw)) {
+ try {
+ const parsed = JSON.parse(val);
+ items.push({ ...parsed, normalizedUrl: parsed.normalizedUrl || field });
+ } catch {
+ // skip malformed
+ }
+ }
+ }
+ items.sort(
+ (a, b) =>
+ (b.votes || 1) - (a.votes || 1) ||
+ String(b.submittedAt || "").localeCompare(String(a.submittedAt || "")),
+ );
+ return items;
+}
+
+async function main() {
+ const [, , cmd = "list", arg] = process.argv;
+ const redis = getRedis();
+ const items = await fetchAllPending(redis);
+
+ if (cmd === "list") {
+ if (!items.length) {
+ console.log("No pending submissions in the queue.");
+ return;
+ }
+ console.log(`Pending submissions (${items.length}):\n`);
+ for (const item of items) {
+ const date = item.submittedAt ? item.submittedAt.slice(0, 10) : "—";
+ const votes = item.votes > 1 ? ` [${item.votes} votes]` : "";
+ console.log(` ${item.id}${votes} ${item.name} (${item.category || "Uncategorized"}) — ${date}`);
+ console.log(` URL: ${item.url}`);
+ if (item.note) console.log(` Note: ${item.note}`);
+ console.log("");
+ }
+ console.log("Approve: npm run submissions -- approve <id>");
+ console.log("Dismiss: npm run submissions -- dismiss <id>");
+ return;
+ }
+
+ if (cmd === "dismiss" || cmd === "approve") {
+ if (!arg) {
+ console.error(`Usage: npm run submissions -- ${cmd} <submission-id>`);
+ process.exit(1);
+ }
+ const target = items.find((i) => i.id === arg || i.normalizedUrl === arg);
+ if (!target) {
+ console.error(`Submission not found: ${arg}`);
+ process.exit(1);
+ }
+
+ if (cmd === "approve") {
+ const parsedUrl = safeWebsite(target.url);
+ await assertPublicTargetUrl(parsedUrl.toString());
+ const category = CATEGORIES.includes(target.category)
+ ? target.category
+ : "Product";
+ const cliArgs = [
+ path.join(ROOT, "scripts/capture-site.mjs"),
+ "--url",
+ parsedUrl.toString(),
+ "--name",
+ target.name || parsedUrl.hostname.replace(/^www\./, ""),
+ "--category",
+ category,
+ "--description",
+ target.note
+ ? target.note.slice(0, 220)
+ : `Considered web design from ${target.name || parsedUrl.hostname}.`,
+ "--observation",
+ target.note || "Submitted via designtaste.wtf.",
+ ];
+ execFileSync(process.execPath, cliArgs, { stdio: "inherit" });
+ }
+
+ await redisCommand(redis, [
+ "HDEL",
+ PENDING_SUBMISSIONS_HASH,
+ target.normalizedUrl,
+ ]);
+ console.log(
+ cmd === "approve"
+ ? `Approved ${target.name} (${target.url}) and removed ${target.id} from pending queue.`
+ : `Dismissed ${target.id} (${target.url}) from pending queue.`,
+ );
+ return;
+ }
+
+ console.error(`Unknown command: ${cmd}\nExpected: list | approve <id> | dismiss <id>`);
+ process.exit(1);
+}
+
+main().catch((err) => {
+ console.error(err.message || err);
+ process.exit(1);
+});
diff --git a/tests/gallery.test.mjs b/tests/gallery.test.mjs
index e84ef51..8fc0ff1 100644
--- a/tests/gallery.test.mjs
+++ b/tests/gallery.test.mjs
@@ -281,18 +281,68 @@ test("submission API validates URLs, ignores honeypot spam, deduplicates, rate-l
assert.equal(spam.status, 202);
assert.equal(spam.body.ok, true);
- const unconfigured = await handleSubmission(
+ // Already-published catalog sites return a friendly gallery link immediately
+ const alreadyListed = await handleSubmission(
{ url: "https://linear.app", note: "Crisp dark craft" },
- { token: "", clientKey: "198.51.100.1" },
+ { token: "", env: {}, clientKey: "198.51.100.1" },
+ );
+ assert.equal(alreadyListed.status, 200);
+ assert.equal(alreadyListed.body.ok, true);
+ assert.equal(alreadyListed.body.alreadyListed, true);
+ assert.equal(alreadyListed.body.siteUrl, "https://designtaste.wtf/sites/linear/");
+
+ const unconfigured = await handleSubmission(
+ { url: "https://new-studio.example", note: "Crisp dark craft" },
+ { token: "", env: {}, clientKey: "198.51.100.10" },
);
assert.equal(unconfigured.status, 503);
assert.match(unconfigured.body.fallbackUrl, /github\.com\/.*\/issues\/new/);
+ // Queues directly into Upstash Redis when GITHUB_SUBMISSIONS_TOKEN is unset
+ const redisStore = new Map();
+ const redisEnv = {
+ KV_REST_API_URL: "https://redis.example",
+ KV_REST_API_TOKEN: "redis-secret",
+ };
+ const redisFetch = async (_url, init) => {
+ const cmds = JSON.parse(init.body);
+ const out = cmds.map(([op, _key, field, val]) => {
+ if (op === "INCR") return { result: 1 };
+ if (op === "EXPIRE") return { result: 1 };
+ if (op === "HGET") return { result: redisStore.get(field) ?? null };
+ if (op === "HLEN") return { result: redisStore.size };
+ if (op === "HSET") {
+ redisStore.set(field, val);
+ return { result: 1 };
+ }
+ return { result: null };
+ });
+ return { ok: true, status: 200, json: async () => out };
+ };
+ const queued = await handleSubmission(
+ { url: "https://fresh-craft.example", name: "Fresh Craft", category: "Portfolio", note: "Bold type" },
+ { token: "", env: redisEnv, fetchImpl: redisFetch, clientKey: "198.51.100.11" },
+ );
+ assert.equal(queued.status, 201);
+ assert.equal(queued.body.ok, true);
+ assert.equal(queued.body.queued, true);
+ assert.match(queued.body.submissionId, /^sub_/);
+
+ // Deduplicates in Redis and bumps vote count
+ const queuedDup = await handleSubmission(
+ { url: "https://www.fresh-craft.example/" },
+ { token: "", env: redisEnv, fetchImpl: redisFetch, clientKey: "198.51.100.12" },
+ );
+ assert.equal(queuedDup.status, 200);
+ assert.equal(queuedDup.body.duplicate, true);
+ assert.equal(queuedDup.body.votes, 2);
+
let sent = null;
const created = await handleSubmission(
- { url: "https://rauno.me", name: "Rauno", category: "Portfolio", note: "Tactile motion" },
+ { url: "https://new-portfolio.example", name: "Studio Nova", category: "Portfolio", note: "Tactile motion" },
{
token: "test-token",
+ env: {},
clientKey: "198.51.100.2",
fetchImpl: async (url, init) => {
if (init.method === "GET") {
@@ -312,14 +362,15 @@ test("submission API validates URLs, ignores honeypot spam, deduplicates, rate-l
);
assert.equal(created.status, 201);
assert.equal(created.body.issueNumber, 42);
- assert.match(sent.body.title, /Rauno/);
- assert.match(sent.body.body, /https:\/\/rauno\.me\//);
+ assert.match(sent.body.title, /Studio Nova/);
+ assert.match(sent.body.body, /https:\/\/new-portfolio\.example\//);
// Deduplicates against open issues
const dup = await handleSubmission(
- { url: "https://rauno.me" },
+ { url: "https://new-portfolio.example" },
{
token: "test-token",
+ env: {},
clientKey: "198.51.100.3",
fetchImpl: async () => ({
ok: true,
@@ -328,7 +379,7 @@ test("submission API validates URLs, ignores honeypot spam, deduplicates, rate-l
{
number: 42,
html_url: "https://github.com/ethanplusai/designtaste/issues/42",
- body: "- **URL**: https://rauno.me/",
+ body: "- **URL**: https://new-portfolio.example/",
},
],
}),
@@ -339,9 +390,10 @@ test("submission API validates URLs, ignores honeypot spam, deduplicates, rate-l
// Free-text mentions of another URL inside a note do not suppress legitimate submissions
const notDup = await handleSubmission(
- { url: "https://anywr.ai" },
+ { url: "https://brand-new-craft.example" },
{
token: "test-token",
+ env: {},
clientKey: "198.51.100.4",
fetchImpl: async (_url, init) => {
if (init.method === "GET") {
@@ -352,7 +404,7 @@ test("submission API validates URLs, ignores honeypot spam, deduplicates, rate-l
{
number: 43,
html_url: "https://github.com/ethanplusai/designtaste/issues/43",
- body: "- **URL**: https://other.example/\n- **Why it stood out**: similar to https://anywr.ai/",
+ body: "- **URL**: https://other.example/\n- **Why it stood out**: similar to https://brand-new-craft.example/",
},
],
};
@@ -375,12 +427,12 @@ test("submission API validates URLs, ignores honeypot spam, deduplicates, rate-l
for (let i = 0; i < 5; i++) {
await handleSubmission(
{ url: `https://site${i}.example.com` },
- { token: "", clientKey: "198.51.100.99" },
+ { token: "", env: {}, clientKey: "198.51.100.99" },
);
}
const throttled = await handleSubmission(
{ url: "https://site6.example.com" },
- { token: "", clientKey: "198.51.100.99" },
+ { token: "", env: {}, clientKey: "198.51.100.99" },
);
assert.equal(throttled.status, 429);
assert.equal(throttled.body.code, "rate_limited");