Skip to content

3D engine that AI agents drive

Take community showcase submissions and feature picked ones on the site (#1980)

Nguyen Xuan An93b5f3e1b897
diff --git a/.github/DISCUSSION_TEMPLATE/show-and-tell.yml b/.github/DISCUSSION_TEMPLATE/show-and-tell.yml
index 70f7b6db..7a27212a 100644
--- a/.github/DISCUSSION_TEMPLATE/show-and-tell.yml
+++ b/.github/DISCUSSION_TEMPLATE/show-and-tell.yml
@@ -4,13 +4,35 @@ body:
- type: markdown
attributes:
value: |
- Show what you made with Crucible.
+ Show what you made with Crucible. We pick posts from here for the Community section of the [showcase](https://crucible.codepawl.com/showcase.html), with credit to you.
Leave out local paths, tokens and personal data: discussions are public. Check the picture and the calls you paste before you post.
- type: textarea
id: picture
attributes:
label: Picture or render
- description: Drag in a still, a short video or a link to a live page.
+ description: Drag in a still or a short video. If we feature it, we show a 16:9 still at least 1280 px wide.
+ validations:
+ required: true
+ - type: input
+ id: credit
+ attributes:
+ label: Credit
+ description: The name or handle to show under the picture, and the link it points to.
+ placeholder: Ada Lovelace, https://x.com/ada
+ validations:
+ required: true
+ - type: input
+ id: link
+ attributes:
+ label: Live page, repo or post
+ description: Where people can see or try it. Leave it empty if there is none.
+ placeholder: https://example.com/my-scene
+ - type: input
+ id: licence
+ attributes:
+ label: Models and assets
+ description: Who made the models, textures and sounds in it, and their licence.
+ placeholder: My own models; HDRI from Poly Haven (CC0)
validations:
required: true
- type: textarea
@@ -24,6 +46,13 @@ body:
attributes:
label: Crucible version
description: Run `npm ls @codepawlhq/crucible`.
- placeholder: 0.16.0
+ placeholder: 0.21.0
validations:
required: true
+ - type: checkboxes
+ id: consent
+ attributes:
+ label: Permission to feature
+ options:
+ - label: CodePawl may show this picture on crucible.codepawl.com and its social accounts, with the credit above. I made it or have the right to share it.
+ required: true
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
index b625159e..8af19db0 100644
--- a/.github/ISSUE_TEMPLATE/config.yml
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -2,7 +2,10 @@ blank_issues_enabled: false
contact_links:
- name: Ask a question
url: https://github.com/codepawl/crucible/discussions/categories/q-a
- about: How to do something with Crucible or its MCP server. Show what you made in Show and tell.
+ about: How to do something with Crucible or its MCP server.
+ - name: Show what you made
+ url: https://github.com/codepawl/crucible/discussions/new?category=show-and-tell
+ about: Post a render or a live scene. Picked work goes on the showcase page, with credit.
- name: Report a security problem
url: https://github.com/codepawl/crucible/security/advisories/new
about: Report it privately. Do not open a public issue for a vulnerability.
diff --git a/README.md b/README.md
index b8828333..2e59cdde 100644
--- a/README.md
+++ b/README.md
@@ -54,6 +54,8 @@ Scenes built with Crucible open live in the browser on the [showcase](https://cr
<a href="https://crucible.codepawl.com/object.html"><img src="https://crucible.codepawl.com/previews/wall-e.webp" alt="A robot model in the object studio, rendered by Crucible" width="49%"></a>
</p>
+Made something with Crucible? [Post it in Show and tell](https://github.com/codepawl/crucible/discussions/new?category=show-and-tell). We feature picked work on the [showcase](https://crucible.codepawl.com/showcase.html#community), with credit.
+
## What it is
Crucible is a 3D engine for AI agents and for pages. It has a real-time rasterizer, a path tracer, addons for terrain, vegetation, characters, liquid, vehicles and media export, and an MCP server. A scene is plain data: each part has a geometry, a matrix and a material.
@@ -271,7 +273,7 @@ They compare matching scenes on the same hardware. They do not show a general sp
Read [CONTRIBUTING.md](https://github.com/codepawl/crucible/blob/main/CONTRIBUTING.md) before you open a pull request. It covers setup, checks, code style and the release flow.
Coding agents start with [AGENTS.md](https://github.com/codepawl/crucible/blob/main/AGENTS.md), and `npm run preflight` runs the pull request checks locally.
-Questions, ideas and what you made go in [Discussions](https://github.com/codepawl/crucible/discussions). Bug reports: [SUPPORT.md](https://github.com/codepawl/crucible/blob/main/.github/SUPPORT.md).
+Questions and ideas go in [Discussions](https://github.com/codepawl/crucible/discussions), and what you made goes in [Show and tell](https://github.com/codepawl/crucible/discussions/new?category=show-and-tell). Bug reports: [SUPPORT.md](https://github.com/codepawl/crucible/blob/main/.github/SUPPORT.md).
## Sponsors
diff --git a/changes/1980.md b/changes/1980.md
new file mode 100644
index 00000000..cd5189c2
--- /dev/null
+++ b/changes/1980.md
@@ -0,0 +1 @@
+- The showcase page has a Made with Crucible section for picked community work, and Show and tell asks for the credit, the licence and permission to feature it (#1980)
diff --git a/docs/community-showcase.md b/docs/community-showcase.md
new file mode 100644
index 00000000..a0c8d81a
--- /dev/null
+++ b/docs/community-showcase.md
@@ -0,0 +1,46 @@
+# Community showcase
+
+The [showcase page](https://crucible.codepawl.com/showcase.html#community) has a section called Made with Crucible. It shows work that other people built with Crucible, and each piece is credited to the person who made it. People submit work in the Show and tell discussions. A maintainer then picks some posts and adds them to the page in a pull request.
+
+## Submit your work
+
+1. Open [Show and tell](https://github.com/codepawl/crucible/discussions/new?category=show-and-tell).
+2. Drag in a still or a short video. If we feature your work, we show a 16:9 still at least 1280 px wide.
+3. Fill in the credit, a link to the live page, repo or post, and who made the models and assets and their licence.
+4. Tick the permission box, then post.
+
+If you have no GitHub account, email the same details to [[email protected]](mailto:[email protected]?subject=Crucible%20showcase%20submission). The **or send it by email** link on the showcase page fills in the subject and the fields for you. A post without the permission line is not featured.
+
+## Feature a submission
+
+Do this as a maintainer.
+
+1. Check that the post ticks the permission box and that the licence allows the work to be shown.
+2. Save the still as `public/community/<name>.webp`. Use a lowercase name with hyphens, 1600 px wide, at about 200 KB. Keep a local copy and never link to the picture on GitHub or another host.
+3. Add an entry to `public/community/featured.json`:
+
+```json
+{
+ "entries": [
+ {
+ "title": "Night market",
+ "author": "Ada Lovelace",
+ "authorUrl": "https://x.com/ada",
+ "discussion": "https://github.com/codepawl/crucible/discussions/12",
+ "link": "https://example.com/night-market",
+ "image": "/community/night-market.webp",
+ "width": 1600,
+ "height": 900,
+ "alt": "A night market street with lanterns, rendered by Crucible",
+ "assets": "Own models; HDRI from Poly Haven (CC0)"
+ }
+ ]
+}
+```
+
+ - `link` is optional. When it is set, the still opens it. When it is not set, the still opens the discussion.
+ - Put the newest entry first.
+4. Run `node --test tests/community-showcase.test.js`. The test checks every field and checks that each still exists. It prints each bad field and the value it expects.
+5. Reply in the discussion with a link to the showcase page, so the author knows their work is up.
+
+The page hides the grid when the list is empty or does not load, and the submit links always stay on the page.
diff --git a/public/community/featured.json b/public/community/featured.json
new file mode 100644
index 00000000..046955d4
--- /dev/null
+++ b/public/community/featured.json
@@ -0,0 +1,3 @@
+{
+ "entries": []
+}
diff --git a/site/index.html b/site/index.html
index e45df721..b0c7742a 100644
--- a/site/index.html
+++ b/site/index.html
@@ -131,7 +131,7 @@ renderer.render({ eye: [58, 31, 84], target: [-8, 3, -18] });</code></pre>
</section>
<section id="examples" class="examples" aria-labelledby="examples-title">
- <div class="section-heading"><h2 id="examples-title">Showcase</h2><a href="./showcase.html">Open the live scenes</a></div>
+ <div class="section-heading"><h2 id="examples-title">Showcase</h2><span class="section-heading-links"><a href="./showcase.html#community">Submit your work</a><a href="./showcase.html">Open the live scenes</a></span></div>
<ul class="capability-list" aria-label="Engine capabilities">
<li>PBR materials</li><li>Shadows</li><li>HDR and bloom</li><li>MSAA</li><li>Mesh blend</li><li>Live cloth</li><li>Volumetric fog</li><li>Skinning and morphs</li><li>Physics</li><li>Spume liquid</li><li>Glass and leaf cutouts</li><li>HDRI lighting</li><li>Textured terrain</li><li>Trees and grass</li><li>Vehicles</li><li>GLB import and export</li><li>Cook path tracer</li>
</ul>
diff --git a/site/showcase.html b/site/showcase.html
index ecdd3c58..22af332c 100644
--- a/site/showcase.html
+++ b/site/showcase.html
@@ -53,6 +53,14 @@
</figure>
</div>
</section>
+ <section id="community" class="showcase-community" aria-labelledby="community-title">
+ <h2 id="community-title">Made with Crucible</h2>
+ <div id="community-grid" class="community-grid" hidden></div>
+ <div class="community-submit">
+ <a class="community-submit-primary" href="https://github.com/codepawl/crucible/discussions/new?category=show-and-tell"><span class="package-logo package-logo-github" aria-hidden="true"></span>Submit yours</a>
+ <a id="community-email" href="mailto:[email protected]">or send it by email</a>
+ </div>
+ </section>
</main>
<footer class="site-footer" aria-label="Site footer">
<p><a class="brand" href="/" aria-label="Crucible home">Crucible</a> by <a href="https://codepawl.com">CodePawl</a></p>
diff --git a/src/community-showcase.js b/src/community-showcase.js
new file mode 100644
index 00000000..078fe191
--- /dev/null
+++ b/src/community-showcase.js
@@ -0,0 +1,111 @@
+// The Community section of the showcase page: work other people made with Crucible, picked from the Show and tell
+// discussions. Each picked entry lives in public/community/featured.json with a local webp still beside it, so the page
+// never loads a picture from another host. docs/community-showcase.md says how to submit and how to feature an entry.
+
+export const SUBMIT_URL = 'https://github.com/codepawl/crucible/discussions/new?category=show-and-tell';
+export const SUBMIT_EMAIL = '[email protected]';
+export const FEATURED_PATH = '/community/featured.json';
+
+const EMAIL_SUBJECT = 'Crucible showcase submission';
+const EMAIL_BODY = [
+ 'Picture or render: attach a still, 16:9 and at least 1280 px wide if you can.',
+ 'Credit (name or handle, and its link):',
+ 'Live page, repo or post:',
+ 'Models and assets (who made them, and their licence):',
+ 'Crucible version:',
+ '',
+ 'CodePawl may show this picture on crucible.codepawl.com and its social accounts, with the credit above. I made it or have the right to share it.',
+].join('\n');
+
+const DISCUSSION_URL = /^https:\/\/github\.com\/codepawl\/crucible\/discussions\/\d+$/;
+const IMAGE_PATH = /^\/community\/[a-z0-9-]+\.webp$/;
+const MAX_TEXT_LENGTH = 160;
+const MAX_ENTRIES = 60;
+const REQUIRED_TEXT_FIELDS = ['title', 'author', 'alt', 'assets'];
+
+export function submitEmailUrl() {
+ const query = `subject=${encodeURIComponent(EMAIL_SUBJECT)}&body=${encodeURIComponent(EMAIL_BODY)}`;
+ return `mailto:${SUBMIT_EMAIL}?${query}`;
+}
+
+function isHttpsUrl(value) {
+ if (typeof value !== 'string') return false;
+ try {
+ return new URL(value).protocol === 'https:';
+ } catch {
+ return false;
+ }
+}
+
+function textProblems(entry, field) {
+ const value = entry[field];
+ if (typeof value !== 'string' || value.trim() === '') return [`"${field}" must be a non-empty string`];
+ if (value.length > MAX_TEXT_LENGTH) return [`"${field}" is ${value.length} characters; keep it to ${MAX_TEXT_LENGTH}`];
+ return [];
+}
+
+// Returns what is wrong with one featured entry, as sentences that say what to pass instead. An empty list means it is valid.
+export function communityEntryProblems(entry) {
+ if (entry === null || typeof entry !== 'object' || Array.isArray(entry)) return ['an entry must be an object'];
+ const problems = REQUIRED_TEXT_FIELDS.flatMap((field) => textProblems(entry, field));
+ if (!isHttpsUrl(entry.authorUrl)) problems.push('"authorUrl" must be an https link to the author');
+ if (typeof entry.discussion !== 'string' || !DISCUSSION_URL.test(entry.discussion)) {
+ problems.push('"discussion" must be the Show and tell link, https://github.com/codepawl/crucible/discussions/<number>');
+ }
+ if (typeof entry.image !== 'string' || !IMAGE_PATH.test(entry.image)) {
+ problems.push('"image" must be a local still such as /community/<lowercase-name>.webp');
+ }
+ for (const side of ['width', 'height']) {
+ if (!Number.isInteger(entry[side]) || entry[side] < 1) problems.push(`"${side}" must be the still's ${side} in pixels`);
+ }
+ if (entry.link !== undefined && !isHttpsUrl(entry.link)) problems.push('"link" must be an https link, or left out');
+ return problems;
+}
+
+// Reads featured.json and returns its entries, or throws an error that names each bad entry and field.
+export function parseFeatured(data) {
+ const entries = data?.entries;
+ if (!Array.isArray(entries)) throw new Error('featured.json must be { "entries": [ ... ] }');
+ if (entries.length > MAX_ENTRIES) throw new Error(`featured.json has ${entries.length} entries; keep it to ${MAX_ENTRIES}`);
+ const problems = entries.flatMap((entry, index) => communityEntryProblems(entry).map((problem) => `entry ${index + 1}: ${problem}`));
+ if (problems.length > 0) throw new Error(`featured.json is not valid: ${problems.join('; ')}`);
+ return entries;
+}
+
+const HTML_ESCAPES = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' };
+
+function escapeHtml(value) {
+ return String(value).replace(/[&<>"']/g, (character) => HTML_ESCAPES[character]);
+}
+
+// The markup of one entry. The still links to the live page when there is one, otherwise to the discussion.
+export function communityFigureMarkup(entry) {
+ const target = escapeHtml(entry.link ?? entry.discussion);
+ const image = `<img src="${escapeHtml(entry.image)}" alt="${escapeHtml(entry.alt)}" width="${entry.width}" height="${entry.height}" loading="lazy" />`;
+ const author = `<a href="${escapeHtml(entry.authorUrl)}">${escapeHtml(entry.author)}</a>`;
+ const discussion = `<a href="${escapeHtml(entry.discussion)}">Discussion</a>`;
+ return `<figure><a class="community-still" href="${target}">${image}</a>`
+ + `<figcaption><strong>${escapeHtml(entry.title)}</strong><span>By ${author}</span>`
+ + `<small>${escapeHtml(entry.assets)} · ${discussion}</small></figcaption></figure>`;
+}
+
+// Fills the Community grid from featured.json. The submit links stay visible whatever happens, so a failed fetch only
+// leaves the grid empty.
+export async function renderCommunity({ grid, emailLink, fetchJson = defaultFetchJson }) {
+ if (emailLink) emailLink.href = submitEmailUrl();
+ let entries = [];
+ try {
+ entries = parseFeatured(await fetchJson(FEATURED_PATH));
+ } catch (error) {
+ console.warn(`Community showcase: ${error.message}`);
+ }
+ grid.innerHTML = entries.map(communityFigureMarkup).join('');
+ grid.hidden = entries.length === 0;
+ return entries.length;
+}
+
+async function defaultFetchJson(path) {
+ const response = await fetch(path);
+ if (!response.ok) throw new Error(`${path} answered ${response.status}`);
+ return response.json();
+}
diff --git a/src/showcase.css b/src/showcase.css
index 223f0a50..9f3bc242 100644
--- a/src/showcase.css
+++ b/src/showcase.css
@@ -82,6 +82,24 @@ body.site.showcase > main { grid-template-columns: minmax(0, 1fr); }
.showcase-cook figcaption strong { color: var(--text); font-weight: 600; }
.showcase-cook figcaption small { font-size: 13px; }
.showcase-cook figcaption a { color: var(--text); text-decoration: underline; }
+/* Community: work other people made, picked from Show and tell (src/community-showcase.js). */
+.showcase-community { display: grid; gap: 20px; }
+.community-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: start; }
+.community-grid[hidden] { display: none; }
+.community-grid figure { margin: 0; display: grid; gap: 12px; }
+.community-grid img { display: block; width: 100%; height: auto; border-radius: 12px; background: var(--surface); box-shadow: 0 0 0 1px var(--line, transparent); }
+.community-grid figcaption { display: grid; gap: 4px; color: var(--muted); font-size: 14px; }
+.community-grid figcaption strong { color: var(--text); font-weight: 600; }
+.community-grid figcaption small { font-size: 13px; }
+.community-grid figcaption a { color: var(--text); text-decoration: underline; }
+.community-submit { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
+.site .community-submit-primary { display: inline-flex; align-items: center; gap: 8px; min-height: var(--control-height); padding: 8px 16px; border-radius: var(--radius); background: var(--primary); color: var(--primary-text); font-size: 15px; font-weight: 600; transition: opacity .12s; }
+.site .community-submit-primary:hover { opacity: .88; }
+.community-submit a:not(.community-submit-primary) { color: var(--muted); font-size: 15px; }
+.community-submit a:not(.community-submit-primary):hover { color: var(--text); text-decoration: underline; }
+@media (max-width: 900px) {
+ .community-grid { grid-template-columns: minmax(0, 1fr); }
+}
@media (max-width: 900px) {
.showcase-cook-grid { grid-template-columns: minmax(0, 1fr); }
}
diff --git a/src/showcase.js b/src/showcase.js
index 173b9b92..fb2be926 100644
--- a/src/showcase.js
+++ b/src/showcase.js
@@ -11,6 +11,7 @@ import { applyWaterReflection, attachWaterReflection } from './water-reflection.
// The mirror redraws every second lit frame while the camera moves: about 1.3 ms off the orbiting port frame
// (issue #504), and An saw no stutter in a side-by-side. A still camera keeps its picture either way.
const WATER_REFLECTION_OPTIONS = { updateEvery: 2 };
+import { renderCommunity } from './community-showcase.js';
import { createDownloadMeter, downloadBlob, inWholeWorldOrder, readByteLength, readPartRanks } from './showcase-download.js';
// Each scene lives in public/showcase/<id>/scene.json: its GLB, sky, camera, renderer and frame options, and credits.
@@ -332,7 +333,7 @@ async function selectScene(id) {
applyLimits(description, asset.parts);
Object.assign(homeView, { yaw: orbit.yaw, pitch: orbit.pitch, distance: orbit.distance, target: [...orbit.target] });
currentId = id;
- history.replaceState(null, '', `?scene=${id}`);
+ history.replaceState(null, '', `?scene=${id}${location.hash}`);
title.textContent = description.title;
blurb.textContent = description.blurb;
showCredits(description.credits);
@@ -425,3 +426,5 @@ window.addEventListener('resize', () => {
renderTabs();
const requested = new URLSearchParams(location.search).get('scene');
selectScene(SCENE_IDS.includes(requested) ? requested : SCENE_IDS[0]);
+
+renderCommunity({ grid: document.querySelector('#community-grid'), emailLink: document.querySelector('#community-email') });
diff --git a/src/site.css b/src/site.css
index c4e3c4f2..9889ecd7 100644
--- a/src/site.css
+++ b/src/site.css
@@ -254,6 +254,7 @@ body.site > main > section { scroll-margin-top: 96px; }
.site .section-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px 20px; }
.site .section-heading a { color: var(--muted); font-size: 15px; }
.site .section-heading a:hover { color: var(--text); text-decoration: underline; }
+.site .section-heading-links { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.site .site-footer { width: var(--page); margin-inline: auto; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 24px; padding-block: 24px 32px; color: var(--muted); font-size: 14px; }
.site .site-footer .brand { font-size: 14px; font-weight: 600; }
diff --git a/tests/community-showcase.test.js b/tests/community-showcase.test.js
new file mode 100644
index 00000000..256e2799
--- /dev/null
+++ b/tests/community-showcase.test.js
@@ -0,0 +1,96 @@
+import { test } from 'node:test';
+import assert from 'node:assert/strict';
+import { readFileSync } from 'node:fs';
+import {
+ communityEntryProblems,
+ communityFigureMarkup,
+ parseFeatured,
+ renderCommunity,
+ submitEmailUrl,
+ SUBMIT_URL,
+} from '../src/community-showcase.js';
+
+const VALID_ENTRY = Object.freeze({
+ title: 'Night market',
+ author: 'Ada Lovelace',
+ authorUrl: 'https://x.com/ada',
+ discussion: 'https://github.com/codepawl/crucible/discussions/12',
+ image: '/community/night-market.webp',
+ width: 1600,
+ height: 900,
+ alt: 'A night market street with lanterns, rendered by Crucible',
+ assets: 'Own models; HDRI from Poly Haven (CC0)',
+});
+
+test('the committed featured.json is valid and every still is on disk', () => {
+ const data = JSON.parse(readFileSync(new URL('../public/community/featured.json', import.meta.url), 'utf8'));
+ for (const entry of parseFeatured(data)) {
+ readFileSync(new URL(`../public${entry.image}`, import.meta.url));
+ }
+});
+
+test('a complete entry has no problems, with or without a live link', () => {
+ assert.deepEqual(communityEntryProblems(VALID_ENTRY), []);
+ assert.deepEqual(communityEntryProblems({ ...VALID_ENTRY, link: 'https://example.com/scene' }), []);
+});
+
+test('each bad field is named with what to pass instead', () => {
+ const problems = communityEntryProblems({
+ ...VALID_ENTRY,
+ title: '',
+ authorUrl: 'http://x.com/ada',
+ discussion: 'https://github.com/other/repo/discussions/1',
+ image: 'https://cdn.example.com/still.webp',
+ width: 0,
+ link: 'javascript:alert(1)',
+ assets: 'x'.repeat(161),
+ });
+ assert.equal(problems.length, 7);
+ assert.match(problems.join(' '), /"title".*"assets".*"authorUrl".*"discussion".*"image".*"width".*"link"/);
+ assert.deepEqual(communityEntryProblems(null), ['an entry must be an object']);
+ assert.deepEqual(communityEntryProblems([]), ['an entry must be an object']);
+});
+
+test('parseFeatured rejects a wrong shape, too many entries and bad entries', () => {
+ assert.throws(() => parseFeatured({}), /must be \{ "entries"/);
+ assert.throws(() => parseFeatured({ entries: Array(61).fill(VALID_ENTRY) }), /keep it to 60/);
+ assert.throws(() => parseFeatured({ entries: [VALID_ENTRY, { ...VALID_ENTRY, height: 1.5 }] }), /entry 2: "height"/);
+ assert.deepEqual(parseFeatured({ entries: [VALID_ENTRY] }), [VALID_ENTRY]);
+});
+
+test('the figure escapes text and links the still to the live page, else the discussion', () => {
+ const markup = communityFigureMarkup({ ...VALID_ENTRY, title: '<b>Night</b> & "market"' });
+ assert.match(markup, /&lt;b&gt;Night&lt;\/b&gt; &amp; &quot;market&quot;/);
+ assert.match(markup, /class="community-still" href="https:\/\/github\.com\/codepawl\/crucible\/discussions\/12"/);
+ const linked = communityFigureMarkup({ ...VALID_ENTRY, link: 'https://example.com/scene' });
+ assert.match(linked, /class="community-still" href="https:\/\/example\.com\/scene"/);
+ assert.match(linked, /By <a href="https:\/\/x\.com\/ada">Ada Lovelace<\/a>/);
+});
+
+test('the email link carries the subject and the permission line', () => {
+ const url = submitEmailUrl();
+ assert.match(url, /^mailto:hello@codepawl\.com\?subject=Crucible%20showcase%20submission&body=/);
+ assert.match(decodeURIComponent(url), /CodePawl may show this picture/);
+ assert.match(SUBMIT_URL, /discussions\/new\?category=show-and-tell$/);
+});
+
+test('renderCommunity fills the grid, and hides it when the list is empty or fails', async () => {
+ const grid = { innerHTML: '', hidden: true };
+ const emailLink = { href: '' };
+ assert.equal(await renderCommunity({ grid, emailLink, fetchJson: async () => ({ entries: [VALID_ENTRY] }) }), 1);
+ assert.equal(grid.hidden, false);
+ assert.match(grid.innerHTML, /Night market/);
+ assert.match(emailLink.href, /^mailto:/);
+
+ const originalWarn = console.warn;
+ const warnings = [];
+ console.warn = (message) => warnings.push(message);
+ try {
+ assert.equal(await renderCommunity({ grid, fetchJson: async () => { throw new Error('offline'); } }), 0);
+ } finally {
+ console.warn = originalWarn;
+ }
+ assert.equal(grid.hidden, true);
+ assert.equal(grid.innerHTML, '');
+ assert.match(warnings[0], /offline/);
+});