issue-credit / page.template.html
davanstrien's picture
davanstrien HF Staff
Agent prompt: start private, ask before making public
6e63205 verified
Raw History Blame Contribute Delete
44.7 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Issues That Became PRs</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Mona+Sans:wght@400..800&display=swap">
<style>
/* Layout: a familiar code-host profile page. Header band, repo tabs, filter bar,
a year calendar, an outcome bar, then a contributor card grid. Click a card for a profile. */
:root {
--bg: #ffffff;
--bg-subtle: #f6f8fa;
--bg-hover: #eff2f5;
--fg: #1f2328;
--fg-muted: #59636e;
--border: #d1d9e0;
--border-strong: #818b98;
--accent: #0969da;
--tab-underline: #fd8c73;
--counter-bg: #e6eaef;
--open: #1a7f37;
--converted: #8250df;
--self: #0969da;
--nolink: #8c959f;
--skip: #d1d9e0;
--cal0: #eff2f5;
--cal1: #aceebb;
--cal2: #4ac26b;
--cal3: #2da44e;
--cal4: #116329;
--cal-stroke: rgba(31, 35, 40, 0.05);
--avatar-bg: #f0f0f0;
--tooltip-bg: #25292e;
--tooltip-fg: #ffffff;
--font-display: "Mona Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
--font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
--font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
--bg: #0d1117; --bg-subtle: #151b23; --bg-hover: #1f2630; --fg: #f0f6fc; --fg-muted: #9198a1;
--border: #3d444d; --border-strong: #656c76; --accent: #4493f8; --tab-underline: #f78166;
--counter-bg: #2f3742; --open: #3fb950; --converted: #ab7df8; --self: #4493f8; --nolink: #656c76;
--skip: #3d444d; --cal0: #151b23; --cal1: #033a16; --cal2: #196c2e; --cal3: #2ea043; --cal4: #56d364;
--cal-stroke: rgba(255, 255, 255, 0.05); --avatar-bg: #262c36; --tooltip-bg: #3d444d; --tooltip-fg: #f0f6fc;
color-scheme: dark;
}
}
:root[data-theme="dark"] {
--bg: #0d1117; --bg-subtle: #151b23; --bg-hover: #1f2630; --fg: #f0f6fc; --fg-muted: #9198a1;
--border: #3d444d; --border-strong: #656c76; --accent: #4493f8; --tab-underline: #f78166;
--counter-bg: #2f3742; --open: #3fb950; --converted: #ab7df8; --self: #4493f8; --nolink: #656c76;
--skip: #3d444d; --cal0: #151b23; --cal1: #033a16; --cal2: #196c2e; --cal3: #2ea043; --cal4: #56d364;
--cal-stroke: rgba(255, 255, 255, 0.05); --avatar-bg: #262c36; --tooltip-bg: #3d444d; --tooltip-fg: #f0f6fc;
color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--font-body); }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.wrap {
max-width: 1080px; margin: 0 auto;
padding-left: max(16px, env(safe-area-inset-left, 0px));
padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--fg-muted); }
/* Header band */
.top { background: var(--bg-subtle); border-bottom: 1px solid var(--border); }
.top-inner { display: flex; align-items: center; gap: 10px; padding-block: 14px; flex-wrap: wrap; }
.mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); color: var(--converted); background: var(--bg); }
.brand { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.top-meta { margin-left: auto; color: var(--fg-muted); font-size: 12px; }
/* Primer-like small pieces */
.pill { display: inline-block; border: 1px solid var(--border); border-radius: 2em; padding: 0 7px; font-size: 12px; font-weight: 500; line-height: 18px; color: var(--fg-muted); white-space: nowrap; }
.counter { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 2em; background: var(--counter-bg); font-size: 12px; font-weight: 600; line-height: 18px; text-align: center; color: var(--fg); font-variant-numeric: tabular-nums; }
.box { border: 1px solid var(--border); border-radius: 6px; }
.icon { flex: none; vertical-align: text-bottom; }
.avatar { border-radius: 50%; box-shadow: 0 0 0 1px var(--border); flex: none; shape-rendering: crispEdges; }
/* Intro */
main { padding-block: 24px 48px; display: grid; gap: 20px; }
.intro h1 { font-family: var(--font-display); font-weight: 600; font-size: 26px; line-height: 1.25; margin: 0 0 6px; text-wrap: balance; }
.intro p { margin: 0; max-width: 68ch; color: var(--fg-muted); font-size: 15px; }
/* Repo tabs */
.unav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; box-shadow: inset 0 -1px 0 var(--border); }
.unav::-webkit-scrollbar { display: none; }
.unav button { appearance: none; background: none; border: 0; font: inherit; color: var(--fg); cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 6px 8px 12px; position: relative; white-space: nowrap; }
.unav button span.lbl { padding: 2px 6px; border-radius: 6px; }
.unav button:hover span.lbl { background: var(--bg-hover); }
.unav button[aria-selected="true"] { font-weight: 600; }
.unav button[aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 2px; border-radius: 6px; background: var(--tab-underline); }
.more-tab { position: relative; display: flex; align-items: center; padding: 6px 8px 12px; }
.more-tab select { appearance: none; font: inherit; color: var(--fg); background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6.5 8 10l3.5-3.5' fill='none' stroke='%23818b98' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 4px center; border: 0; border-radius: 6px; padding: 2px 24px 2px 6px; cursor: pointer; }
.more-tab select:hover { background-color: var(--bg-hover); }
.more-tab[data-active="true"] select { font-weight: 600; }
.more-tab[data-active="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 2px; border-radius: 6px; background: var(--tab-underline); }
.agent-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.prompt { margin: 0; font-family: var(--font-mono); font-size: 12px; line-height: 1.6; color: var(--fg); background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 6px; padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.method code { font-family: var(--font-mono); font-size: 12px; background: var(--counter-bg); color: var(--fg); padding: 1px 5px; border-radius: 6px; }
/* Filter bar */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.seg { display: inline-flex; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 6px; }
.seg button { appearance: none; font: inherit; font-weight: 500; color: var(--fg); background: none; border: 1px solid transparent; border-radius: 6px; margin: -1px; padding: 4px 12px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.seg button[aria-pressed="true"] { background: var(--bg); border-color: var(--border-strong); }
.find { flex: 1 1 200px; min-width: 0; display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; background: var(--bg); color: var(--fg-muted); }
.find:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
.find input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; color: var(--fg); padding: 5px 0; outline: none; }
.sort { appearance: none; font: inherit; font-weight: 500; color: var(--fg); background: var(--bg-subtle) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6.5 8 10l3.5-3.5' fill='none' stroke='%23818b98' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 8px center; border: 1px solid var(--border); border-radius: 6px; padding: 5px 30px 5px 12px; cursor: pointer; }
/* Calendar */
.cal-box { padding: 16px; display: grid; gap: 10px; }
.cal-box h2, .grid-head h2 { font-family: var(--font-display); font-size: 16px; font-weight: 500; margin: 0; }
.cal-split { color: var(--fg-muted); font-size: 12px; }
.cal-scroll { overflow-x: auto; }
.cal text { fill: var(--fg-muted); font-size: 9px; font-family: var(--font-body); }
.cal rect { stroke: var(--cal-stroke); stroke-width: 1; }
.cal .c0 { fill: var(--cal0); } .cal .c1 { fill: var(--cal1); } .cal .c2 { fill: var(--cal2); }
.cal .c3 { fill: var(--cal3); } .cal .c4 { fill: var(--cal4); }
.cal-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--fg-muted); font-size: 12px; }
.legend { display: inline-flex; align-items: center; gap: 3px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; box-shadow: inset 0 0 0 1px var(--cal-stroke); }
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--tooltip-bg); color: var(--tooltip-fg); font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, calc(-100% - 8px)); }
/* Outcome bar, styled like a languages bar */
.mix { padding: 16px; display: grid; gap: 12px; }
.bar { display: flex; height: 8px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--bg); }
.bar span { display: block; min-width: 2px; }
.mix-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 12px; }
.mix-list li { display: inline-flex; align-items: center; gap: 6px; }
.mix-list b { font-weight: 600; }
/* Contributor grid, styled like a contributors page */
.grid-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.card { display: grid; gap: 10px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 6px; color: var(--fg); background: var(--bg); min-width: 0; }
.card:hover { background: var(--bg-subtle); text-decoration: none; border-color: var(--border-strong); }
.card-head { display: flex; gap: 10px; align-items: center; min-width: 0; }
.who { min-width: 0; flex: 1; }
.who-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.login { font-weight: 600; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repos { color: var(--fg-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank { color: var(--fg-muted); font-size: 12px; font-weight: 500; align-self: flex-start; }
.stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--fg-muted); }
.stats span { display: inline-flex; align-items: center; gap: 4px; }
.stats b { color: var(--fg); font-weight: 600; }
.strip { width: 100%; height: 10px; display: block; }
.strip .c0 { fill: var(--cal0); } .strip .c1 { fill: var(--cal1); } .strip .c2 { fill: var(--cal2); }
.strip .c3 { fill: var(--cal3); } .strip .c4 { fill: var(--cal4); }
.share { font-size: 12px; color: var(--fg-muted); }
.more { justify-self: center; appearance: none; font: inherit; font-weight: 500; color: var(--accent); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 5px 16px; cursor: pointer; }
.more:hover { background: var(--bg-subtle); }
.empty { padding: 32px 16px; text-align: center; color: var(--fg-muted); }
/* Method notes */
.method { padding: 16px; font-size: 13px; color: var(--fg-muted); display: grid; gap: 8px; }
.method h2 { font-family: var(--font-display); font-size: 14px; font-weight: 600; color: var(--fg); margin: 0; }
.method ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; max-width: 90ch; }
/* Profile dialog */
dialog { width: min(820px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--fg); overflow: auto; }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dlg { display: grid; gap: 18px; padding: 20px; }
.dlg-head { display: flex; gap: 14px; align-items: center; }
.dlg-head h2 { font-family: var(--font-display); font-size: 22px; font-weight: 600; margin: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; overflow-wrap: anywhere; }
.dlg-head p { margin: 2px 0 0; color: var(--fg-muted); }
.close { margin-left: auto; align-self: flex-start; appearance: none; border: 0; background: none; color: var(--fg-muted); cursor: pointer; padding: 6px; border-radius: 6px; display: grid; place-items: center; }
.close:hover { background: var(--bg-hover); color: var(--fg); }
.picked { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 12px; color: var(--fg-muted); }
.picked span { display: inline-flex; align-items: center; gap: 5px; color: var(--fg); }
.list-head { background: var(--bg-subtle); border-bottom: 1px solid var(--border); padding: 10px 16px; border-radius: 6px 6px 0 0; font-weight: 600; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.issues { list-style: none; margin: 0; padding: 0; }
.issues li { display: flex; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--border); align-items: flex-start; }
.issues li:first-child { border-top: 0; }
.issues .icon { margin-top: 3px; }
.issue-main { min-width: 0; flex: 1; }
.issue-title { font-weight: 600; color: var(--fg); overflow-wrap: anywhere; }
.issue-title:hover { color: var(--accent); }
.issue-meta { font-size: 12px; color: var(--fg-muted); display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: center; margin-top: 2px; }
.issue-meta a { color: var(--fg-muted); }
.issue-meta a:hover { color: var(--accent); }
.issue-meta .fixer { display: inline-flex; gap: 4px; align-items: center; color: var(--fg); }
.o-converted { color: var(--converted); } .o-self { color: var(--self); } .o-nolink { color: var(--nolink); }
.o-skip { color: var(--nolink); } .o-open { color: var(--open); }
@media (max-width: 560px) {
.intro h1 { font-size: 22px; }
.top-meta { margin-left: 0; width: 100%; }
.seg { width: 100%; }
.seg button { flex: 1; justify-content: center; padding: 4px 6px; }
.dlg { padding: 16px; }
.dlg-head .avatar { width: 48px; height: 48px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
</style>
</head>
<body>
<header class="top">
<div class="wrap top-inner">
<span class="mark" aria-hidden="true">
<svg class="icon" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="4.5" cy="3.5" r="1.75"/><circle cx="4.5" cy="12.5" r="1.75"/><circle cx="11.5" cy="8.5" r="1.75"/><path d="M4.5 5.25v5.5M4.5 5.25C4.5 8 7 8.5 9.75 8.5"/></svg>
</span>
<span class="brand">Issue credit</span>
<span class="pill">Demo</span>
<span class="top-meta" id="topMeta"></span>
</div>
</header>
<main class="wrap">
<section class="intro">
<h1>Who writes issues good enough to become PRs?</h1>
<p>Many repos now ask for an issue before a PR, and maintainers often write the fix themselves. A merged-PR count misses the person who wrote the issue. This page counts issues that were closed by a merged PR written by someone else.</p>
</section>
<nav class="unav" id="repoTabs" role="tablist" aria-label="Repository"></nav>
<div class="toolbar">
<div class="seg" id="whoSeg" role="group" aria-label="Issue authors">
<button type="button" id="who-community" data-who="community" aria-pressed="true">Community <span class="counter"></span></button>
<button type="button" id="who-team" data-who="team" aria-pressed="false"><span class="team-label">Team</span> <span class="counter"></span></button>
<button type="button" id="who-everyone" data-who="everyone" aria-pressed="false">Everyone <span class="counter"></span></button>
</div>
<label class="find">
<svg class="icon" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"><circle cx="7" cy="7" r="4.75"/><path d="m10.5 10.5 3.5 3.5"/></svg>
<input type="search" id="find" placeholder="Find a user…" autocomplete="off" aria-label="Find a user">
</label>
<select class="sort" id="sort" aria-label="Sort contributors">
<option value="conv">Sort: Most issues → PRs</option>
<option value="share">Sort: Highest share (3+ closed)</option>
<option value="opened">Sort: Most issues opened</option>
</select>
</div>
<section class="box cal-box" aria-labelledby="calTitle">
<h2 id="calTitle"></h2>
<div class="cal-split" id="calSplit"></div>
<div class="cal-scroll" id="calScroll"></div>
<div class="cal-foot">
<span>Each square is a day. Counted on the day the issue closed.</span>
<span class="legend">Less <i style="background:var(--cal0)"></i><i style="background:var(--cal1)"></i><i style="background:var(--cal2)"></i><i style="background:var(--cal3)"></i><i style="background:var(--cal4)"></i> More</span>
</div>
</section>
<section class="box mix" aria-label="How issues ended">
<div class="bar" id="mixBar"></div>
<ul class="mix-list" id="mixList"></ul>
</section>
<section style="display:grid;gap:12px">
<div class="grid-head">
<h2>Contributors</h2>
<span class="muted" id="gridCount"></span>
</div>
<ol class="grid" id="grid"></ol>
<button type="button" class="more" id="more">Show more</button>
</section>
<section class="box method">
<h2>How this is counted</h2>
<ul>
<li><b>Became a PR</b>: the issue was closed by a merged PR, or a commit, whose author is not the issue author. The link comes from GitHub's own record of what closed the issue, or from a merged PR that says "Fixes #N".</li>
<li><b class="team-label">Team</b>: GitHub marks the person as a Member, Owner or Collaborator on one of these repos. Everyone else is community.</li>
<li>Issues closed with no linked PR are not counted, even when a PR did fix them. This undercounts maintainers who fix things without writing "Fixes #N".</li>
<li>Issues opened by bot accounts are removed. Fixes written by bots or agents still count for the issue author.</li>
<li id="dataNote"></li>
<li id="makeOwn"></li>
</ul>
</section>
<section class="box method" id="agentBox" aria-labelledby="agentTitle">
<div class="agent-head">
<h2 id="agentTitle">Set up your own with a coding agent</h2>
<button type="button" class="more" id="copyPrompt">Copy prompt</button>
</div>
<pre class="prompt" id="agentPrompt"></pre>
</section>
</main>
<dialog id="profile" aria-labelledby="pName"><div class="dlg" id="profileBody"></div></dialog>
<div class="tip" id="tip" hidden></div>
<script>
const DATA = /*__DATA__*/null;
/* ---------- constants ---------- */
const OUTCOMES = [
{ key: "converted", cls: "o-converted", color: "var(--converted)", label: "Became someone else's PR" },
{ key: "self", cls: "o-self", color: "var(--self)", label: "Fixed in the author's own PR" },
{ key: "nolink", cls: "o-nolink", color: "var(--nolink)", label: "Closed, no linked PR" },
{ key: "skip", cls: "o-skip", color: "var(--skip)", label: "Closed as not planned" },
{ key: "open", cls: "o-open", color: "var(--open)", label: "Open" },
];
const CONVERTED = 0, SELF = 1, NOLINK = 2, SKIP = 3, OPEN = 4;
const PAGE_SIZE = 24;
const DAY_MS = 86400000;
const ICONS = {
converted: '<path d="M4.5 5.25v5.5M4.5 5.25C4.5 8 7 8.5 9.75 8.5"/><circle cx="4.5" cy="3.5" r="1.75"/><circle cx="4.5" cy="12.5" r="1.75"/><circle cx="11.5" cy="8.5" r="1.75"/>',
self: '<path d="M4.5 5.25v5.5M11.5 10.75V6A2.5 2.5 0 0 0 9 3.5H7.25M8.75 2 7.25 3.5 8.75 5"/><circle cx="4.5" cy="3.5" r="1.75"/><circle cx="4.5" cy="12.5" r="1.75"/><circle cx="11.5" cy="12.5" r="1.75"/>',
nolink: '<circle cx="8" cy="8" r="6.25"/><path d="m5.5 8.25 1.75 1.75 3.25-3.5"/>',
skip: '<circle cx="8" cy="8" r="6.25"/><path d="M4.25 11.75 11.75 4.25"/>',
open: '<circle cx="8" cy="8" r="6.25"/><circle cx="8" cy="8" r="1.25" fill="currentColor"/>',
close: '<path d="M4 4l8 8M12 4l-8 8"/>',
};
function icon(name, cls = "") {
return `<svg class="icon ${cls}" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${ICONS[name]}</svg>`;
}
function escapeHtml(text) {
return String(text).replace(/[&<>"']/g, (ch) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[ch]));
}
function plural(n, word, many) {
return `${n.toLocaleString("en-GB")} ${n === 1 ? word : (many || word + "s")}`;
}
/* ---------- identicon avatars (5x5 mirrored grid) ---------- */
function hash32(text, seed) {
let h = (0x811c9dc5 ^ seed) >>> 0;
for (let i = 0; i < text.length; i++) {
h ^= text.charCodeAt(i);
h = Math.imul(h, 0x01000193);
}
return h >>> 0;
}
function avatar(login, size) {
const cells = hash32(login, 17);
const tint = hash32(login, 991);
const hue = tint % 360;
const sat = 45 + ((tint >>> 9) % 20);
const light = 50 + ((tint >>> 17) % 12);
let path = "";
let bit = 0;
for (let x = 0; x < 3; x++) {
for (let y = 0; y < 5; y++) {
if ((cells >>> bit) & 1) {
path += `M${x + 0.5} ${y + 0.5}h1v1h-1z`;
if (x < 2) path += `M${4 - x + 0.5} ${y + 0.5}h1v1h-1z`;
}
bit++;
}
}
return `<svg class="avatar" width="${size}" height="${size}" viewBox="0 0 6 6" aria-hidden="true"><rect width="6" height="6" fill="var(--avatar-bg)"/><path d="${path}" fill="hsl(${hue} ${sat}% ${light}%)"/></svg>`;
}
/* ---------- data ---------- */
const REPOS = DATA.repos;
const TEAM = DATA.team;
const ISSUES = DATA.issues.map((r) => ({
repo: r[0], number: r[1], title: r[2], author: r[3], outcome: r[4],
fixer: r[5], ref: r[6], fixerKind: r[7], created: r[8], closed: r[9],
}));
const GENERATED_MS = Date.parse(DATA.generated + "T00:00:00Z");
const SINCE_MS = Date.parse(DATA.since + "T00:00:00Z");
const CAL_START_MS = SINCE_MS - new Date(SINCE_MS).getUTCDay() * DAY_MS;
const CAL_DAYS = Math.round((GENERATED_MS - CAL_START_MS) / DAY_MS) + 1;
const CAL_WEEKS = Math.ceil(CAL_DAYS / 7);
function dayIndex(isoDate) {
return Math.round((Date.parse(isoDate + "T00:00:00Z") - CAL_START_MS) / DAY_MS);
}
for (const issue of ISSUES) {
issue.closedDay = issue.closed ? dayIndex(issue.closed) : -1;
}
const SINGLE_OWNER = new Set(REPOS.map((r) => r.split("/")[0])).size === 1;
function repoShort(index) { return SINGLE_OWNER ? REPOS[index].split("/")[1] : REPOS[index]; }
function isTeam(login) { return Object.prototype.hasOwnProperty.call(TEAM, login); }
function formatDate(isoDate) {
return new Date(isoDate + "T00:00:00Z").toLocaleDateString("en-GB", { day: "numeric", month: "short", year: "numeric", timeZone: "UTC" });
}
function monthYear(isoDate) {
return new Date(isoDate + "T00:00:00Z").toLocaleDateString("en-GB", { month: "short", year: "numeric", timeZone: "UTC" });
}
function issueUrl(issue) { return `https://github.com/${REPOS[issue.repo]}/issues/${issue.number}`; }
function fixUrl(issue) {
if (issue.ref.startsWith("#")) return `https://github.com/${REPOS[issue.repo]}/pull/${issue.ref.slice(1)}`;
return `https://github.com/${REPOS[issue.repo]}/commit/${issue.ref}`;
}
/* ---------- state ---------- */
const state = { repo: -1, who: "community", query: "", sort: "conv", shown: PAGE_SIZE };
function matchesWho(login, who) {
if (who === "everyone") return true;
return (who === "team") === isTeam(login);
}
function inRepo(issue, repo) { return repo < 0 || issue.repo === repo; }
function scopedIssues() {
return ISSUES.filter((i) => inRepo(i, state.repo) && matchesWho(i.author, state.who));
}
function countConverted(repo, who) {
let n = 0;
for (const i of ISSUES) if (i.outcome === CONVERTED && inRepo(i, repo) && matchesWho(i.author, who)) n++;
return n;
}
function buildPeople(issues) {
const people = new Map();
for (const issue of issues) {
let person = people.get(issue.author);
if (!person) {
person = { login: issue.author, counts: [0, 0, 0, 0, 0], opened: 0, repos: new Set(), weeks: new Array(CAL_WEEKS).fill(0) };
people.set(issue.author, person);
}
person.counts[issue.outcome]++;
person.opened++;
person.repos.add(repoShort(issue.repo));
if (issue.outcome === CONVERTED && issue.closedDay >= 0) person.weeks[Math.floor(issue.closedDay / 7)]++;
}
for (const person of people.values()) {
person.closed = person.opened - person.counts[OPEN];
person.share = person.closed ? person.counts[CONVERTED] / person.closed : 0;
}
return [...people.values()];
}
function rankPeople(people) {
let pool = people.filter((p) => p.counts[CONVERTED] > 0);
if (state.sort === "share") pool = pool.filter((p) => p.closed >= 3);
const byConverted = (a, b) => b.counts[CONVERTED] - a.counts[CONVERTED] || b.share - a.share || a.login.localeCompare(b.login);
const sorters = {
conv: byConverted,
share: (a, b) => b.share - a.share || byConverted(a, b),
opened: (a, b) => b.opened - a.opened || byConverted(a, b),
};
pool.sort(sorters[state.sort]);
pool.forEach((p, index) => { p.rank = index + 1; });
return pool;
}
/* ---------- rendering: tabs and filters ---------- */
const TAB_LIMIT = 5;
let repoOrderCache = null;
/* Repos ordered by how many issues became PRs, across all authors. Stable across filters. */
function repoOrder() {
if (!repoOrderCache) {
const totals = REPOS.map((_, index) => countConverted(index, "everyone"));
repoOrderCache = REPOS.map((_, index) => index).sort((a, b) => totals[b] - totals[a]);
}
return repoOrderCache;
}
function renderTabs() {
const order = repoOrder();
const tabRepos = order.length > TAB_LIMIT + 1 ? order.slice(0, TAB_LIMIT) : order;
const moreRepos = order.slice(tabRepos.length);
const tabs = [-1, ...tabRepos].map((index) => `
<button type="button" role="tab" id="tab-${index}" data-repo="${index}" aria-selected="${index === state.repo}">
<span class="lbl">${escapeHtml(index < 0 ? "All repositories" : repoShort(index))}</span><span class="counter">${countConverted(index, state.who).toLocaleString("en-GB")}</span>
</button>`).join("");
let more = "";
if (moreRepos.length) {
const active = moreRepos.includes(state.repo);
const options = moreRepos.map((index) =>
`<option value="${index}"${index === state.repo ? " selected" : ""}>${escapeHtml(repoShort(index))} (${countConverted(index, state.who).toLocaleString("en-GB")})</option>`).join("");
more = `<span class="more-tab" data-active="${active}"><select id="moreRepos" aria-label="More repositories"><option value="">${plural(moreRepos.length, "more repo")}</option>${options}</select></span>`;
}
document.getElementById("repoTabs").innerHTML = tabs + more;
}
function renderSegments() {
for (const button of document.querySelectorAll("#whoSeg button")) {
button.setAttribute("aria-pressed", String(button.dataset.who === state.who));
button.querySelector(".counter").textContent = countConverted(state.repo, button.dataset.who).toLocaleString("en-GB");
}
}
/* ---------- rendering: calendar ---------- */
function level(count, max) {
if (!count) return 0;
return Math.min(4, Math.ceil(4 * Math.sqrt(count / Math.max(max, 4))));
}
function calendarSvg(dayCounts, ariaLabel) {
const cell = CAL_WEEKS > 60 ? 9 : 10, step = cell + 3, left = 30, top = 18;
const width = left + CAL_WEEKS * step + 16;
const height = top + 7 * step;
const max = Math.max(0, ...dayCounts);
let rects = "";
for (let day = 0; day < CAL_DAYS; day++) {
const col = Math.floor(day / 7), row = day % 7;
rects += `<rect x="${left + col * step}" y="${top + row * step}" width="${cell}" height="${cell}" rx="2" class="c${level(dayCounts[day], max)}" data-day="${day}" data-n="${dayCounts[day]}"/>`;
}
const months = [];
for (let col = 0; col < CAL_WEEKS; col++) {
const month = new Date(CAL_START_MS + col * 7 * DAY_MS).getUTCMonth();
const prev = col ? new Date(CAL_START_MS + (col - 1) * 7 * DAY_MS).getUTCMonth() : -1;
if (month !== prev) months.push({ col, month, year: new Date(CAL_START_MS + col * 7 * DAY_MS).getUTCFullYear() });
}
if (months.length > 1 && months[1].col - months[0].col < 3) months.shift();
const monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
const monthText = months.map((m, index) => `<text x="${left + m.col * step}" y="11">${monthNames[m.month]}${m.month === 0 || index === 0 ? " " + m.year : ""}</text>`).join("");
const dayText = [[1, "Mon"], [3, "Wed"], [5, "Fri"]].map(([row, name]) => `<text x="0" y="${top + row * step + 9}">${name}</text>`).join("");
return `<svg class="cal" viewBox="0 0 ${width} ${height}" width="${width}" height="${height}" role="img" aria-label="${escapeHtml(ariaLabel)}">${monthText}${dayText}${rects}</svg>`;
}
function dayCountsFor(issues) {
const counts = new Array(CAL_DAYS).fill(0);
for (const issue of issues) {
if (issue.outcome === CONVERTED && issue.closedDay >= 0 && issue.closedDay < CAL_DAYS) counts[issue.closedDay]++;
}
return counts;
}
function renderCalendar(issues) {
const counts = dayCountsFor(issues);
const total = counts.reduce((a, b) => a + b, 0);
const where = state.repo < 0 ? "" : ` in ${repoShort(state.repo)}`;
const title = `${plural(total, "issue")} became someone else's PR${where} since ${monthYear(DATA.since)}`;
document.getElementById("calTitle").textContent = title;
const community = countConverted(state.repo, "community");
const team = countConverted(state.repo, "team");
const split = document.getElementById("calSplit");
split.hidden = state.who !== "everyone";
split.textContent = `Written by community authors: ${community.toLocaleString("en-GB")} · by ${DATA.team_label} authors: ${team.toLocaleString("en-GB")}`;
const scroller = document.getElementById("calScroll");
scroller.innerHTML = calendarSvg(counts, title);
scroller.scrollLeft = scroller.scrollWidth;
}
/* ---------- rendering: outcome bar ---------- */
function renderMix(issues) {
const counts = [0, 0, 0, 0, 0];
for (const issue of issues) counts[issue.outcome]++;
const total = issues.length || 1;
document.getElementById("mixBar").innerHTML = OUTCOMES.map((o, i) =>
counts[i] ? `<span style="flex:${counts[i]};background:${o.color}" title="${o.label}: ${counts[i]}"></span>` : "").join("");
document.getElementById("mixList").innerHTML = OUTCOMES.map((o, i) => `
<li>${icon(o.key, o.cls)}<b>${o.label}</b><span class="num">${counts[i].toLocaleString("en-GB")}</span><span class="muted num">${(100 * counts[i] / total).toFixed(1)}%</span></li>`).join("");
}
/* ---------- rendering: contributor grid ---------- */
function stripSvg(weeks) {
const max = Math.max(3, ...weeks);
const rects = weeks.map((n, i) => `<rect x="${i * 5}" width="4" height="10" rx="1" class="c${level(n, max)}"/>`).join("");
return `<svg class="strip" viewBox="0 0 ${CAL_WEEKS * 5 - 1} 10" preserveAspectRatio="none" aria-hidden="true">${rects}</svg>`;
}
function outcomeBar(counts) {
return `<div class="bar" aria-hidden="true">${OUTCOMES.map((o, i) =>
counts[i] ? `<span style="flex:${counts[i]};background:${o.color}"></span>` : "").join("")}</div>`;
}
function roleLabel(login) {
return isTeam(login) ? `<span class="pill" title="GitHub marks this person as ${TEAM[login]} on a Hugging Face repo">${TEAM[login]}</span>` : "";
}
function cardHtml(person) {
const c = person.counts;
const shareText = person.closed
? `${Math.round(100 * person.share)}% of ${plural(person.closed, "closed issue")} became someone else's PR`
: "No closed issues yet";
return `<li><a class="card" href="#u-${encodeURIComponent(person.login)}" aria-label="Open profile for ${escapeHtml(person.login)}">
<div class="card-head">
${avatar(person.login, 40)}
<div class="who">
<div class="who-line"><span class="login">${escapeHtml(person.login)}</span>${roleLabel(person.login)}</div>
<div class="repos">${[...person.repos].sort().join(" · ")}</div>
</div>
<span class="rank num">${person.rank ? "#" + person.rank : "–"}</span>
</div>
<div class="stats">
<span>${icon("converted", "o-converted")}<b class="num">${c[CONVERTED]}</b> became PRs</span>
<span>${icon("self", "o-self")}<b class="num">${c[SELF]}</b> own PR${c[SELF] === 1 ? "" : "s"}</span>
<span>${icon("open", "o-open")}<b class="num">${person.opened}</b> issue${person.opened === 1 ? "" : "s"} opened</span>
</div>
${outcomeBar(c)}
<div class="share">${shareText}</div>
${stripSvg(person.weeks)}
</a></li>`;
}
function renderGrid(issues) {
const people = buildPeople(issues);
const ranked = rankPeople(people);
const query = state.query.trim().toLowerCase();
let list = ranked;
if (query) {
const rankedLogins = new Set(ranked.map((p) => p.login));
const extras = people.filter((p) => !rankedLogins.has(p.login)).map((p) => Object.assign(p, { rank: 0 }));
list = ranked.concat(extras).filter((p) => p.login.toLowerCase().includes(query));
}
const shown = list.slice(0, state.shown);
const grid = document.getElementById("grid");
grid.innerHTML = shown.length
? shown.map(cardHtml).join("")
: `<li class="box empty" style="grid-column:1/-1">No one matches “${escapeHtml(state.query)}” in this view.</li>`;
const rule = state.sort === "share" ? "with an issue that became a PR and 3+ closed issues" : "with at least one issue that became a PR";
document.getElementById("gridCount").textContent = query
? `${plural(list.length, "match", "matches")} for “${state.query}”`
: `Showing ${Math.min(state.shown, list.length)} of ${plural(list.length, "person", "people")} ${rule}`;
document.getElementById("more").hidden = list.length <= state.shown;
}
/* ---------- top-level render ---------- */
function render() {
const issues = scopedIssues();
renderTabs();
renderSegments();
renderCalendar(issues);
renderMix(issues);
renderGrid(issues);
}
/* ---------- profile dialog ---------- */
const OUTCOME_ORDER = [CONVERTED, SELF, OPEN, NOLINK, SKIP];
function issueMeta(issue) {
const parts = [`<a href="${issueUrl(issue)}" target="_blank" rel="noopener">${repoShort(issue.repo)}#${issue.number}</a>`, `opened ${formatDate(issue.created)}`];
if (issue.outcome === CONVERTED) {
const who = issue.fixer
? `<span class="fixer">${avatar(issue.fixer, 16)}${escapeHtml(issue.fixer)}${issue.fixerKind === 2 ? ' <span class="pill">bot</span>' : roleLabel(issue.fixer)}</span>`
: "an unknown author";
parts.push(`closed by <a href="${fixUrl(issue)}" target="_blank" rel="noopener">${escapeHtml(issue.ref)}</a> from ${who}`);
} else if (issue.outcome === SELF) {
parts.push(`fixed in their own PR <a href="${fixUrl(issue)}" target="_blank" rel="noopener">${escapeHtml(issue.ref)}</a>`);
} else if (issue.outcome === NOLINK) {
parts.push(`closed ${formatDate(issue.closed)}, no linked PR`);
} else if (issue.outcome === SKIP) {
parts.push(`closed as not planned`);
}
return parts.join(" · ");
}
function openProfile(login) {
const mine = ISSUES.filter((i) => i.author === login);
if (!mine.length) return false;
mine.sort((a, b) => OUTCOME_ORDER.indexOf(a.outcome) - OUTCOME_ORDER.indexOf(b.outcome) || b.created.localeCompare(a.created));
const counts = [0, 0, 0, 0, 0];
for (const i of mine) counts[i.outcome]++;
const repos = [...new Set(mine.map((i) => repoShort(i.repo)))].sort();
const fixers = new Map();
for (const i of mine) if (i.outcome === CONVERTED && i.fixer) fixers.set(i.fixer, (fixers.get(i.fixer) || 0) + 1);
const fixerList = [...fixers.entries()].sort((a, b) => b[1] - a[1]);
const calTitle = `${plural(counts[CONVERTED], "issue")} became someone else's PR since ${monthYear(DATA.since)}`;
const repoQualifiers = [...new Set(mine.map((i) => "repo:" + REPOS[i.repo]))].join(" ");
const searchUrl = "https://github.com/search?type=issues&q=" + encodeURIComponent(`is:issue author:${login} ${repoQualifiers} linked:pr`);
document.getElementById("profileBody").innerHTML = `
<div class="dlg-head">
${avatar(login, 64)}
<div style="min-width:0">
<h2 id="pName">${escapeHtml(login)} ${roleLabel(login)}</h2>
<p>${plural(mine.length, "issue")} opened across ${repos.join(", ")} · <a href="https://github.com/${encodeURIComponent(login)}" target="_blank" rel="noopener">GitHub profile</a></p>
</div>
<button type="button" class="close" id="closeProfile" aria-label="Close" autofocus>${icon("close")}</button>
</div>
<div class="box cal-box">
<h2>${calTitle}</h2>
<div class="cal-scroll" id="profileCal">${calendarSvg(dayCountsFor(mine), calTitle)}</div>
${outcomeBar(counts)}
</div>
${fixerList.length ? `<div class="picked">Picked up by ${fixerList.map(([f, n]) => `<span>${avatar(f, 20)}${escapeHtml(f)} ${roleLabel(f)} <span class="muted num">×${n}</span></span>`).join("")}</div>` : ""}
<div class="box">
<div class="list-head">
<span>${icon("converted", "o-converted")} ${counts[CONVERTED]} became PRs &nbsp; ${icon("open", "o-open")} ${counts[OPEN]} open &nbsp; ${icon("nolink", "o-nolink")} ${counts[NOLINK] + counts[SKIP] + counts[SELF]} other</span>
<a href="${searchUrl}" target="_blank" rel="noopener" style="font-weight:400">Search on GitHub ↗</a>
</div>
<ul class="issues">
${mine.map((i) => `<li>${icon(OUTCOMES[i.outcome].key, OUTCOMES[i.outcome].cls)}<div class="issue-main"><a class="issue-title" href="${issueUrl(i)}" target="_blank" rel="noopener">${escapeHtml(i.title)}</a><div class="issue-meta">${issueMeta(i)}</div></div></li>`).join("")}
</ul>
</div>`;
const dialog = document.getElementById("profile");
if (!dialog.open) dialog.showModal();
dialog.scrollTop = 0;
const cal = document.getElementById("profileCal");
cal.scrollLeft = cal.scrollWidth;
document.getElementById("closeProfile").addEventListener("click", () => dialog.close());
return true;
}
function loginFromHash() {
const hash = decodeURIComponent(location.hash.slice(1));
return hash.startsWith("u-") ? hash.slice(2) : "";
}
function syncHash() {
const login = loginFromHash();
const dialog = document.getElementById("profile");
if (login && openProfile(login)) return;
if (dialog.open) dialog.close();
}
/* ---------- agent prompt ---------- */
function agentPrompt(space) {
return `Set up my own copy of the Issue Credit Space (${space}) for these GitHub repos: <owner/repo, owner/repo>.
<me> is my Hugging Face username (hf auth whoami).
1. Duplicate it: hf repos duplicate ${space} --type space --private
2. Download my copy: hf download <me>/issue-credit --repo-type space --local-dir issue-credit
3. Edit issue-credit/config.toml (repos, title, team_label, since), then upload it:
hf upload <me>/issue-credit issue-credit/config.toml config.toml --repo-type space
4. Test without uploading: GITHUB_TOKEN=$(gh auth token) uv run issue-credit/refresh.py --space <me>/issue-credit --out ./preview
5. Ask me to save a read-only GitHub token as GITHUB_TOKEN=... in ~/.config/issue-credit/secrets.env.
Never read, print or upload that file.
6. Run it once as a Job, check the Space updated, then schedule it weekly:
hf jobs uv run --secrets HF_TOKEN --secrets-file ~/.config/issue-credit/secrets.env issue-credit/refresh.py --space <me>/issue-credit
hf jobs scheduled uv run --secrets HF_TOKEN --secrets-file ~/.config/issue-credit/secrets.env @weekly issue-credit/refresh.py --space <me>/issue-credit
7. My copy starts private. When the page looks right, ask me before making it public:
hf repos settings <me>/issue-credit --type space --public`;
}
/* ---------- tooltip for calendar squares ---------- */
const tip = document.getElementById("tip");
document.addEventListener("mouseover", (event) => {
const rect = event.target.closest && event.target.closest("rect[data-day]");
if (!rect) { tip.hidden = true; return; }
const n = Number(rect.dataset.n);
const date = new Date(CAL_START_MS + Number(rect.dataset.day) * DAY_MS).toLocaleDateString("en-GB", { weekday: "short", day: "numeric", month: "short", year: "numeric", timeZone: "UTC" });
tip.textContent = n ? `${plural(n, "issue")} became a PR on ${date}` : `No issues became PRs on ${date}`;
const box = rect.getBoundingClientRect();
tip.style.left = `${box.left + box.width / 2}px`;
tip.style.top = `${box.top}px`;
tip.hidden = false;
});
document.addEventListener("scroll", () => { tip.hidden = true; }, true);
/* ---------- events ---------- */
document.getElementById("repoTabs").addEventListener("click", (event) => {
const button = event.target.closest("button[data-repo]");
if (!button) return;
state.repo = Number(button.dataset.repo);
state.shown = PAGE_SIZE;
render();
});
document.getElementById("repoTabs").addEventListener("change", (event) => {
if (event.target.id !== "moreRepos") return;
state.repo = event.target.value === "" ? -1 : Number(event.target.value);
state.shown = PAGE_SIZE;
render();
});
document.getElementById("whoSeg").addEventListener("click", (event) => {
const button = event.target.closest("button[data-who]");
if (!button) return;
state.who = button.dataset.who;
state.shown = PAGE_SIZE;
render();
});
document.getElementById("find").addEventListener("input", (event) => {
state.query = event.target.value;
state.shown = PAGE_SIZE;
renderGrid(scopedIssues());
});
document.getElementById("sort").addEventListener("change", (event) => {
state.sort = event.target.value;
state.shown = PAGE_SIZE;
renderGrid(scopedIssues());
});
document.getElementById("more").addEventListener("click", () => {
state.shown += PAGE_SIZE;
renderGrid(scopedIssues());
});
const profileDialog = document.getElementById("profile");
profileDialog.addEventListener("click", (event) => { if (event.target === profileDialog) profileDialog.close(); });
profileDialog.addEventListener("close", () => { if (loginFromHash()) location.hash = ""; });
window.addEventListener("hashchange", syncHash);
document.getElementById("topMeta").textContent = `${DATA.title} · ${plural(REPOS.length, "repo")} · ${plural(ISSUES.length, "issue")} since ${formatDate(DATA.since)} · updated ${formatDate(DATA.generated)}`;
for (const el of document.querySelectorAll(".team-label")) el.textContent = DATA.team_label;
document.getElementById("dataNote").textContent = `Data: GitHub GraphQL API, issues opened since ${formatDate(DATA.since)} in ${plural(REPOS.length, "repo")}, refreshed ${formatDate(DATA.generated)}. Avatars are generated patterns, not real profile pictures.`;
if (DATA.space) {
const spaceUrl = `https://huggingface.co/spaces/${DATA.space}`;
document.getElementById("makeOwn").innerHTML = `Track your own repos: <a href="${spaceUrl}?duplicate=true" target="_blank" rel="noopener">duplicate this Space</a>, edit <code>config.toml</code>, and run <code>refresh.py</code> as a scheduled Job. The <a href="${spaceUrl}/blob/main/README.md" target="_blank" rel="noopener">README</a> has the steps.`;
document.getElementById("agentPrompt").textContent = agentPrompt(DATA.space);
} else {
document.getElementById("makeOwn").hidden = true;
document.getElementById("agentBox").hidden = true;
}
document.getElementById("copyPrompt").addEventListener("click", async (event) => {
const button = event.currentTarget;
const prompt = document.getElementById("agentPrompt");
try {
await navigator.clipboard.writeText(prompt.textContent);
button.textContent = "Copied";
} catch {
const range = document.createRange();
range.selectNodeContents(prompt);
getSelection().removeAllRanges();
getSelection().addRange(range);
button.textContent = "Selected, press Ctrl/Cmd+C";
}
setTimeout(() => { button.textContent = "Copy prompt"; }, 2500);
});
render();
syncHash();
</script>
</body>
</html>