Support GitHub repos in the issues/PRs panel drawer (#46) #47

Merged
pedromcaraujo merged 1 commit from github-panel-drawer into main 2026-09-20 12:00:06 +01:00

Teaches the per-channel panel drawer to speak GitHub as a second provider, so a channel can point at a GitHub repo and get the same Issues/PRs tabs and # palette that Forgejo channels have. Closes #46.

What changed

  • web/panel.py — the substantive work. Refactored the hardcoded-Forgejo sidecar into a Provider base class with ForgejoProvider/GitHubProvider subclasses, isolating the four real divergences the issue identified:
    • Auth: token <t> vs Bearer <t> (+ X-GitHub-Api-Version).
    • API host: Forgejo serves API+web from one host; GitHub splits api.github.com from github.com (or /api/v3 for Enterprise), derived from the web base.
    • Markdown: Forgejo's capitalised {Text,Mode,Context} vs GitHub's lowercase {text,mode,context}.
    • Attachments: Forgejo proxies auth-gated images; GitHub user-content is public, so the rewrite/proxy is a passthrough.
    • Endpoints stay provider-agnostic and reuse the existing JSON thinning. GitHub's /issues returns PRs too, so they're filtered out to match the issues-only tab.
  • modules/forge.nixgithub added to the type enum; generalised option docs; a build-time assertion that a panel carries repo/tokenFile (and baseUrl for Forgejo).
  • modules/launcher.nixpanelUrl accepts github and defaults its web base to github.com.
  • web/index.htmlisRepoPanel()/forgeLabel() helpers replace the three per-type checks and make user-visible strings ("Open in GitHub ↗", palette tooltip) provider-aware. Renderer and palette are otherwise unchanged.
  • flake.nix — the eval check now configures both a Forgejo and a GitHub panel, so both providers' config paths are exercised in CI.

Design note

The two-host question resolves without a new config field: baseUrl stays the web host (what the drawer links to), and each provider derives its own API host. For public GitHub, baseUrl is optional and defaults to https://github.com.

Verification

  • nix flake check passes; the built channels.json shows a GitHub panel resolving to url: https://github.com/<owner>/<repo> with repo/tokenFile kept server-side.
  • python3 -m py_compile web/panel.py clean; nixpkgs-fmt clean.

Not covered

  • Untested against a live GitHub repo — the eval is static. The markdown passthrough for relative image paths (rare in issue bodies) is the one spot worth eyeballing on a real repo.
Teaches the per-channel panel drawer to speak GitHub as a second provider, so a channel can point at a GitHub repo and get the same Issues/PRs tabs and `#` palette that Forgejo channels have. Closes #46. ## What changed - **`web/panel.py`** — the substantive work. Refactored the hardcoded-Forgejo sidecar into a `Provider` base class with `ForgejoProvider`/`GitHubProvider` subclasses, isolating the four real divergences the issue identified: - **Auth**: `token <t>` vs `Bearer <t>` (+ `X-GitHub-Api-Version`). - **API host**: Forgejo serves API+web from one host; GitHub splits `api.github.com` from `github.com` (or `/api/v3` for Enterprise), derived from the web base. - **Markdown**: Forgejo's capitalised `{Text,Mode,Context}` vs GitHub's lowercase `{text,mode,context}`. - **Attachments**: Forgejo proxies auth-gated images; GitHub user-content is public, so the rewrite/proxy is a passthrough. - Endpoints stay provider-agnostic and reuse the existing JSON thinning. GitHub's `/issues` returns PRs too, so they're filtered out to match the issues-only tab. - **`modules/forge.nix`** — `github` added to the `type` enum; generalised option docs; a build-time assertion that a panel carries `repo`/`tokenFile` (and `baseUrl` for Forgejo). - **`modules/launcher.nix`** — `panelUrl` accepts `github` and defaults its web base to `github.com`. - **`web/index.html`** — `isRepoPanel()`/`forgeLabel()` helpers replace the three per-type checks and make user-visible strings ("Open in GitHub ↗", palette tooltip) provider-aware. Renderer and palette are otherwise unchanged. - **`flake.nix`** — the `eval` check now configures both a Forgejo and a GitHub panel, so both providers' config paths are exercised in CI. ## Design note The two-host question resolves without a new config field: `baseUrl` stays the **web** host (what the drawer links to), and each provider derives its own API host. For public GitHub, `baseUrl` is optional and defaults to `https://github.com`. ## Verification - `nix flake check` passes; the built `channels.json` shows a GitHub panel resolving to `url: https://github.com/<owner>/<repo>` with `repo`/`tokenFile` kept server-side. - `python3 -m py_compile web/panel.py` clean; `nixpkgs-fmt` clean. ## Not covered - Untested against a live GitHub repo — the eval is static. The markdown passthrough for relative image paths (rare in issue bodies) is the one spot worth eyeballing on a real repo.
Support GitHub repos in the issues/PRs panel drawer (#46)
All checks were successful
CI / check (pull_request) Successful in 28s
113bbebcb0
The panel-drawer sidecar spoke only Forgejo. Factor a Provider
abstraction so a channel can point at a GitHub repo and get the same
Issues/PRs tabs and Alt+K `#` palette.

web/panel.py: replace the hardcoded Forgejo calls with a Provider base
class and ForgejoProvider/GitHubProvider subclasses that isolate the
four real divergences — auth scheme (token vs Bearer), API host (Forgejo
serves one host; GitHub splits api.github.com from github.com, or
/api/v3 for Enterprise), markdown field casing, and attachments (GitHub
user-content is public, so the proxy is a passthrough). The endpoints
stay provider-agnostic and reuse the existing thinning, since both
forges' JSON already lines up. GitHub's /issues endpoint returns PRs
too, so they're filtered out to match the issues-only tab.

Keep baseUrl as the web host and derive the API host per provider, so
GitHub needs no extra config field; baseUrl defaults to github.com.

modules/forge.nix: add `github` to the type enum, generalise the docs,
and assert a panel carries repo/tokenFile (and baseUrl for Forgejo).
modules/launcher.nix: panelUrl accepts github and defaults its web base.
web/index.html: isRepoPanel()/forgeLabel() helpers replace the three
per-type checks and make the user-visible strings provider-aware.
flake.nix: the eval check now configures both a Forgejo and a GitHub
panel so both providers' config paths are exercised.
pedromcaraujo deleted branch github-panel-drawer 2026-09-20 12:00:07 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pedromcaraujo/forge!47
No description provided.