Skip to content
Open
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
37 changes: 37 additions & 0 deletions .github/workflows/sync-projects.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Sync projects

on:
schedule:
- cron: '23 5 * * *'
workflow_dispatch:

permissions:
contents: write
pull-requests: write

concurrency:
group: sync-projects

jobs:
sync:
if: github.ref_name == github.event.repository.default_branch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Sync public repositories
env:
GH_TOKEN: ${{ github.token }}
run: python3 scripts/sync-projects.py

- name: Open or update project index pull request
uses: peter-evans/create-pull-request@3ffccacd46053766916f087ce41d627c0b8cf2d1 # v8.1.3
with:
branch: automation/sync-projects
delete-branch: true
add-paths: src/content/projects/
title: 'projects: sync public repositories'
commit-message: 'projects: sync public repositories'
body: Refresh the software index from the Manic Systems GitHub repository API.
93 changes: 93 additions & 0 deletions scripts/sync-projects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import json
import os
import re
import tomllib
from itertools import count
from pathlib import Path
from urllib.request import Request, urlopen

PROJECTS = Path(__file__).resolve().parents[1] / "src/content/projects"
API = "https://api.github.com/orgs/manic-systems/repos"
INFRASTRUCTURE = {"web", "workflows"}


def fetch_repositories():
headers = {
"Accept": "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
}
if token := os.environ.get("GH_TOKEN"):
headers["Authorization"] = f"Bearer {token}"

for number in count(1):
url = f"{API}?type=public&per_page=100&page={number}"
with urlopen(Request(url, headers=headers), timeout=30) as response:
page = json.load(response)
has_next = 'rel="next"' in response.headers.get("Link", "")
if not isinstance(page, list) or (not page and has_next):
raise ValueError(f"Unexpected GitHub repositories response on page {number}")
yield from page
if not has_next:
return


def project_entries(repositories, existing):
entries = {}
for repository in repositories:
name = repository["name"]
if (
repository["private"]
or repository["fork"]
or repository["disabled"]
or name.startswith(".")
or name in INFRASTRUCTURE
):
continue
if not re.fullmatch(r"[A-Za-z0-9_.-]+", name) or name in entries:
raise ValueError(f"Invalid or duplicate repository name: {name!r}")

# These fields are curated in the checked-in entries, not by GitHub.
previous = existing.get(name, {})
entry = {"area": previous.get("area", "other")}
if description := (repository["description"] or "").strip():
entry["description"] = description
for field in ("order", "note"):
if field in previous:
entry[field] = previous[field]
if repository["archived"]:
entry["archived"] = True
entries[name] = entry

if not entries:
raise ValueError("No public projects returned; refusing to clear the index")
return entries


def toml_value(value):
if isinstance(value, str):
return json.dumps(value, ensure_ascii=False).replace("\x7f", r"\u007f")
return json.dumps(value)


def sync_projects(directory, repositories):
previous = {
path.stem: path.read_text(encoding="utf-8") for path in directory.glob("*.toml")
}
existing = {name: tomllib.loads(text) for name, text in previous.items()}
entries = project_entries(repositories, existing)

directory.mkdir(parents=True, exist_ok=True)
for name, fields in sorted(entries.items()):
text = "".join(f"{key} = {toml_value(value)}\n" for key, value in fields.items())
if text != previous.get(name):
(directory / f"{name}.toml").write_text(text, encoding="utf-8")
for name in previous:
if name not in entries:
(directory / f"{name}.toml").unlink()

return len(entries)


if __name__ == "__main__":
project_count = sync_projects(PROJECTS, fetch_repositories())
print(f"Synced {project_count} public projects from GitHub.")
12 changes: 1 addition & 11 deletions src/components/Footer.astro
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
---
import Icon from './Icon.astro';
import People from './People.astro';
import { github, matrix } from '../data/site';
import { github, matrix } from '@/data/site';
const year = new Date().getUTCFullYear();
---

<div class="mobile-people">
<p class="rail-label">
<Icon name="people" /> People
</p>
<People mobile />
</div>
<footer class="bottom">
<nav class="quick-links" aria-label="Quick links">
<a href={github}>GitHub ↗</a>
Expand All @@ -29,11 +21,9 @@ const year = new Date().getUTCFullYear();
.go-up { justify-self: end; white-space: nowrap; }
.bottom a { display: inline-flex; align-items: center; min-height: 36px; }
.bottom a:hover { text-decoration: underline; text-underline-offset: 5px; }
.mobile-people { display: none; }
@media (max-width: 780px) {
.bottom { grid-template-columns: minmax(0, 1fr) auto; gap: 12px 20px; }
.copyright { grid-column: 1 / -1; grid-row: 2; }
.go-up { grid-column: 2; grid-row: 1; }
.mobile-people { display: block; margin-block-end: 24px; padding-block-start: 24px; border-block-start: 1px solid var(--line); font-size: 0.8125rem; }
}
</style>
2 changes: 2 additions & 0 deletions src/components/Icon.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ const paths = {
systems: 'M7 7h10v10H7ZM10 10h4v4h-4ZM9 3v4M15 3v4M9 17v4M15 17v4M3 9h4M3 15h4M17 9h4M17 15h4',
shell: 'M4 4h16v16H4ZM8 9l3 3-3 3M13 15h3',
libraries: 'm12 3 9 5-9 5-9-5 9-5ZM3 12l9 5 9-5M3 16l9 5 9-5',
other: 'M5 12h.01M12 12h.01M19 12h.01',
menu: 'M4 7h16M4 12h16M4 17h16',
link: 'M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.7 1.7m2.2 5.8a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.7-1.7',
sponsor: '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.78L12 21.23l8.84-8.84a5.5 5.5 0 0 0 0-7.78Z',
};
interface Props {
Expand Down
6 changes: 3 additions & 3 deletions src/components/Masthead.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import { bitmapSeed } from "../data/site";
import { DOT_SIZE, LETTERING, TITLE } from "../lib/masthead/lettering";
import { bitmapSeed } from "@/data/site";
import { DOT_SIZE, LETTERING, TITLE } from "@/lib/masthead/lettering";

const dotInset = (1 - DOT_SIZE) / 2;

Expand Down Expand Up @@ -134,7 +134,7 @@ const cells = Array.from({ length: 48 }, (_, i) => {
</style>

<script>
import { Masthead } from "../lib/masthead/masthead";
import { Masthead } from "@/lib/masthead/masthead";

function initialize() {
const root = document.querySelector<HTMLElement>(".masthead");
Expand Down
7 changes: 3 additions & 4 deletions src/components/OrganizationSidebar.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
import Icon from './Icon.astro';
import People from './People.astro';
import type { ProjectGroup } from '../data/projects';
import Icon from '@/components/Icon.astro';
import type { ProjectGroup } from '@/data/projects';

interface Props {
groups: ProjectGroup[];
Expand Down Expand Up @@ -29,7 +28,7 @@ const { groups } = Astro.props;
</a>
))}
</nav>
<People />
<slot />
</aside>

<style>
Expand Down
35 changes: 21 additions & 14 deletions src/components/People.astro
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
---
import Icon from './Icon.astro';
import { people } from '../data/site';
import type { CollectionEntry } from 'astro:content';
import Icon from '@/components/Icon.astro';

interface Props {
members: readonly CollectionEntry<'users'>[];
mobile?: boolean;
}
const { mobile = false } = Astro.props;
const { members, mobile = false } = Astro.props;
---

<div class:list={['people', { mobile }]}>
{!mobile && (
<p class="rail-label">
<Icon name="people" /> People
</p>
)}
{people.map((person) => (
<a href={`https://github.com/${person}`}>
{person} <span aria-hidden="true">↗</span>
</a>
))}
<p class="rail-label"><Icon name="people" /> People</p>
<div class="member-links">
{members.map(({ id, data }) => (
<a href={`/members/${id}`}>
{data.github} <span aria-hidden="true">→</span>
</a>
))}
</div>
</div>

<style>
.people a { display: block; width: fit-content; max-width: 100%; overflow-wrap: anywhere; min-height: 36px; padding-block: 8px; }
.people a:hover { text-decoration: underline; text-underline-offset: 5px; }
.mobile { display: none; }
@media (max-width: 780px) {
.people { display: none; }
.people.mobile { display: flex; flex-wrap: wrap; gap: 4px 24px; }
.mobile {
display: block;
margin-block-end: 24px;
padding-block-start: 24px;
border-block-start: 1px solid var(--line);
font-size: 0.8125rem;
}
.member-links { display: flex; flex-wrap: wrap; gap: 4px 24px; }
}
</style>
7 changes: 4 additions & 3 deletions src/components/ProjectIndex.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import type { ProjectGroup } from '../data/projects';
import { github } from '../data/site';
import type { ProjectGroup } from '@/data/projects';
import { github } from '@/data/site';

interface Props {
groups: ProjectGroup[];
Expand All @@ -26,8 +26,9 @@ const total = groups.reduce((sum, group) => sum + group.projects.length, 0);
<span class="project-name">{id}</span>
<span class="project-arrow" aria-hidden="true">↗</span>
</div>
<p class="project-desc">{data.description}</p>
{data.description && <p class="project-desc">{data.description}</p>}
{data.note && <p class="project-note">[{data.note}]</p>}
{data.archived && <p class="project-note">[Archived]</p>}
</a>
</li>
))}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Topbar.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import Icon from './Icon.astro';
import { github, matrix } from '../data/site';
import Icon from '@/components/Icon.astro';
import { github, matrix } from '@/data/site';
---

<header class="topbar">
Expand Down
32 changes: 22 additions & 10 deletions src/content.config.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
import { defineCollection } from 'astro:content';
import { file } from 'astro/loaders';
import { glob } from 'astro/loaders';
import { z } from 'astro/zod';
import { projectAreas } from './data/projects';

// Descriptions summarize public READMEs; IDs are the exact GitHub repository names.
// Explicit order preserves the curated index independently of loader iteration order.
// Maintain entries in src/content/projects.json; add areas in src/data/projects.ts.
// Notes are optional, and navigation counts and the total derive from the collection.
const projects = defineCollection({
loader: file('src/content/projects.json'),
loader: glob({
pattern: '*.toml',
base: './src/content/projects',
generateId: ({ entry }) => entry.slice(0, -'.toml'.length),
}),
schema: z.object({
id: z.string().min(1),
area: z.enum(projectAreas.map((area) => area.id)),
description: z.string().min(1),
order: z.number().int().positive(),
description: z.string().min(1).optional(),
order: z.number().int().positive().optional(),
note: z.string().min(1).optional(),
archived: z.boolean().optional(),
}),
});

const publicUrl = z.url({ protocol: /^https?$/ });
const users = defineCollection({
loader: glob({ pattern: '*.md', base: './src/content/users' }),
schema: z.object({
github: z.string().regex(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/),
order: z.number().int().positive(),
name: z.string().min(1).optional(),
links: z.array(z.object({ label: z.string().min(1), url: publicUrl })).default([]),
sponsorship: publicUrl.optional(),
}),
});

export const collections = { projects };
export const collections = { projects, users };
Loading