Skip to content

Commit ae6628c

Browse files
committed
feat: support multiple authors for cart manuals
Closes #820 - Support multiple authors for carts on the website. Changes: - Update cart frontmatter format to: author: Name <contact> - Contact can be GitHub username, email, or URL - Multiple authors separated by commas - Remove separate 'github' field from frontmatter - Update PlayCart.js to display multiple author avatars - Update PlayButton.js to show comma-separated author names - Update Internet Archive upload script for multiple creators - Convert all 139 existing cart markdown files to new format - Update documentation with new author format examples New author format examples: author: Alice <alice> # GitHub username author: Alice <alice@example.com> # Email author: Alice <https://alice.dev> # URL author: Alice <alice>, Bob <bob> # Multiple authors
1 parent dae7934 commit ae6628c

146 files changed

Lines changed: 703 additions & 759 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

scripts/upload-internetarchive

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@ for cart in db:
2323
subprocess.run(["npx", "--package=wasm4@latest", "--", "w4", "bundle", site_root+"/static/carts/"+slug+".wasm",
2424
"--html", "/tmp/"+slug+".html", "--windows", "/tmp/"+slug+".exe"]);
2525

26+
# Extract author names from the authors array
27+
creators = [author["name"] for author in cart["authors"]]
28+
2629
metadata = {
2730
"collection": "wasm4",
2831

2932
"mediatype": "software",
3033
"subject": "video game; computer game; game; emulation; console; fantasy console; WASM-4",
3134

3235
"title": cart["title"],
33-
"creator": cart["author"],
36+
"creator": creators, # Internet Archive supports multiple creators as a list
3437
"date": datetime.utcfromtimestamp(cart["date"]/1000).strftime("%Y-%m-%d"),
3538

3639
"notes": "<p>This is a game cartridge for the WASM-4 fantasy console. The <code>"+slug+".wasm</code> file contains the cart data (ROM), in WebAssembly format. Also included are versions compiled to HTML and Windows.</p><p>Originally hosted at <a href=\"https://wasm4.org/play/"+slug+"\">https://wasm4.org/play/"+slug+"</a>.</p>",

site/docs/guides/distribution.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,9 @@ The manual is a
7575
[Markdown](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax)
7676
document that should be in this format:
7777

78-
```md
78+
```markdown
7979
---
80-
author: (Your name or username)
81-
github: (Your github username, used to show a profile pic)
80+
author: Your Name <your_github_username>
8281
date: (When the cart was last updated, in YYYY-MM-DD format)
8382
---
8483

@@ -87,6 +86,19 @@ date: (When the cart was last updated, in YYYY-MM-DD format)
8786
Additional info can go here. It will be displayed on your game's page.
8887
```
8988

89+
### Author Format
90+
91+
The `author` field uses the format `Name <contact>` where contact can be:
92+
- A GitHub username (shows profile picture): `Alice <alice>`
93+
- An email address: `Alice <alice@example.com>`
94+
- A website URL: `Alice <https://alice.dev>`
95+
96+
For multiple authors, separate them with commas:
97+
98+
```yaml
99+
author: Alice <alice>, Bob <bob@example.com>, Chris <https://chris.dev>
100+
```
101+
90102
Now just commit your changes and open a pull request! As soon as it's merged, your game will appear
91103
on the site.
92104

site/docusaurus.config.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,38 @@ module.exports = {
176176
throw new Error("Missing content title in markdown");
177177
}
178178

179-
const author = markdown.frontMatter.author;
180-
if (!author) {
179+
const authorRaw = markdown.frontMatter.author;
180+
if (!authorRaw) {
181181
throw new Error("Missing author");
182182
}
183183

184-
const github = markdown.frontMatter.github;
185-
if (!github) {
186-
throw new Error("Missing github");
184+
// Parse author field: "Name <contact>, Name2 <contact2>"
185+
// Contact can be: GitHub username, email, or URL
186+
const authors = authorRaw.split(/,\s*(?=[^<]*(?:<|$))/).map(entry => {
187+
const match = entry.trim().match(/^(.+?)\s*<([^>]+)>$/);
188+
if (match) {
189+
const name = match[1].trim();
190+
const contact = match[2].trim();
191+
let contactType, contactUrl;
192+
if (contact.includes('@') && !contact.includes('://')) {
193+
contactType = 'email';
194+
contactUrl = `mailto:${contact}`;
195+
} else if (contact.startsWith('http://') || contact.startsWith('https://')) {
196+
contactType = 'url';
197+
contactUrl = contact;
198+
} else {
199+
contactType = 'github';
200+
contactUrl = `https://github.com/${contact}`;
201+
}
202+
return { name, contact, contactType, contactUrl };
203+
} else {
204+
// No contact info, just a name
205+
return { name: entry.trim(), contact: null, contactType: null, contactUrl: null };
206+
}
207+
});
208+
209+
if (authors.length === 0) {
210+
throw new Error("No authors found");
187211
}
188212

189213
const date = new Date(markdown.frontMatter.date).getTime();
@@ -192,7 +216,7 @@ module.exports = {
192216
}
193217

194218
cartData = {
195-
slug, title, author, github, date, readme: readme.contents,
219+
slug, title, authors, date, readme: readme.contents,
196220
};
197221
allCartData.push(cartData);
198222

@@ -218,7 +242,7 @@ module.exports = {
218242
const indexData = allCartData.map(cartData => ({
219243
slug: cartData.slug,
220244
title: cartData.title,
221-
author: cartData.author,
245+
authors: cartData.authors,
222246
}));
223247
const cartsJsonPath = await actions.createData("carts.json", JSON.stringify(indexData));
224248
actions.addRoute({

site/src/components/Carts.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
77
import PlayButton from "./PlayButton";
88

99
export default function Carts ({ carts }) {
10-
const cartButtons = carts.map(cart => (<PlayButton key={cart.slug} { ...cart } />));
10+
const cartButtons = carts.map(cart => (
11+
<PlayButton
12+
key={cart.slug}
13+
slug={cart.slug}
14+
title={cart.title}
15+
author={cart.authors.map(a => a.name).join(', ')}
16+
/>
17+
));
1118
return (
1219
<Layout title="Play">
1320
<main>

site/src/components/PlayButton.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Layout from '@theme/Layout';
44
import Link from '@docusaurus/Link';
55
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
66

7-
export default function PlayButton ({ slug, title, author, github, colWidth }) {
7+
export default function PlayButton ({ slug, title, author, colWidth }) {
88
return (
99
<div className={`col col--${colWidth || 2} margin-vert--md col-cart`}>
1010
<div className="cart card">

site/src/components/PlayCart.js

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,37 @@ export default function PlayCart ({ cart }) {
6060
</RWebShare>
6161
</span>
6262
</h1>
63-
<div className="avatar">
64-
<a
65-
className="avatar__photo-link avatar__photo avatar__photo--lg"
66-
href={`https://github.com/${cart.github}`} target="_blank"
67-
>
68-
<img src={`https://github.com/${cart.github}.png?size=128`} />
69-
</a>
70-
<div className="avatar__intro">
71-
<div className="avatar__name"><a href={`https://github.com/${cart.github}`} target="_blank">{cart.author}</a></div>
72-
<small className="avatar__subtitle">
73-
{dateString}
74-
</small>
75-
</div>
63+
<div className="avatar-group">
64+
{cart.authors.map((author, index) => (
65+
<div className="avatar" key={index}>
66+
{author.contactType === 'github' ? (
67+
<a
68+
className="avatar__photo-link avatar__photo avatar__photo--lg"
69+
href={author.contactUrl} target="_blank"
70+
>
71+
<img src={`https://github.com/${author.contact}.png?size=128`} />
72+
</a>
73+
) : (
74+
<div className="avatar__photo avatar__photo--lg avatar__photo--placeholder">
75+
{author.name.charAt(0).toUpperCase()}
76+
</div>
77+
)}
78+
<div className="avatar__intro">
79+
<div className="avatar__name">
80+
{author.contactUrl ? (
81+
<a href={author.contactUrl} target="_blank">{author.name}</a>
82+
) : (
83+
author.name
84+
)}
85+
</div>
86+
{index === 0 && (
87+
<small className="avatar__subtitle">
88+
{dateString}
89+
</small>
90+
)}
91+
</div>
92+
</div>
93+
))}
7694
</div>
7795

7896
<div className="margin-top--lg">

site/src/css/custom.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,24 @@ html[data-theme='dark'] .header-github-link:before {
114114
margin-left: 0.5em;
115115
vertical-align: middle;
116116
}
117+
118+
/* Multiple authors support */
119+
.avatar-group {
120+
display: flex;
121+
flex-wrap: wrap;
122+
gap: 1rem;
123+
}
124+
125+
.avatar-group .avatar {
126+
flex: 0 0 auto;
127+
}
128+
129+
.avatar__photo--placeholder {
130+
display: flex;
131+
align-items: center;
132+
justify-content: center;
133+
background: var(--ifm-color-primary);
134+
color: white;
135+
font-weight: bold;
136+
font-size: 1.5rem;
137+
}

site/static/carts/2048.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
2-
author: Peter Hellberg
3-
github: peterhellberg
2+
author: Peter Hellberg <peterhellberg>
43
date: 2021-10-05
54
---
65

site/static/carts/antcopter.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
2-
author: Eduardo Bart
3-
github: edubart
2+
author: Eduardo Bart <edubart>
43
date: 2022-01-23 00:00:44 GMT
54
---
65

site/static/carts/assemblio.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
2-
author: Philipp Lühmann
3-
github: luehmann
2+
author: Philipp Lühmann <luehmann>
43
date: 2022-01-23 00:00:27 GMT
54
---
65

0 commit comments

Comments
 (0)