Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesPull RequestsActionsSecurityInsightsSettings
✨ AI
More
Blame · Line-by-line history

components.tsx

Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.

components.tsxBlame484 lines · 1 contributor
fc1817aClaude1import type { FC } from "hono/jsx";
06d5ffeClaude2import { html } from "hono/html";
fc1817aClaude3import type { GitCommit, GitTreeEntry, GitDiffFile } from "../git/repository";
06d5ffeClaude4import type { Repository } from "../db/schema";
fc1817aClaude5
06d5ffeClaude6export const RepoHeader: FC<{
7 owner: string;
8 repo: string;
9 starCount?: number;
10 starred?: boolean;
c81ab7aClaude11 forkCount?: number;
06d5ffeClaude12 currentUser?: string | null;
c81ab7aClaude13 forkedFrom?: string | null;
71cd5ecClaude14 archived?: boolean;
15 isTemplate?: boolean;
16}> = ({
17 owner,
18 repo,
19 starCount,
20 starred,
21 forkCount,
22 currentUser,
23 forkedFrom,
24 archived,
25 isTemplate,
26}) => (
fc1817aClaude27 <div class="repo-header">
c81ab7aClaude28 <div>
29 <div style="display: flex; align-items: center; gap: 8px; font-size: 20px">
30 <a href={`/${owner}`} class="owner">
31 {owner}
32 </a>
33 <span class="separator">/</span>
34 <a href={`/${owner}/${repo}`} class="name">
35 {repo}
36 </a>
71cd5ecClaude37 {archived && (
38 <span
39 class="badge"
40 style="background:var(--bg-secondary);color:var(--text-muted);font-size:11px;padding:2px 8px;border-radius:10px;text-transform:uppercase;letter-spacing:0.5px"
41 title="Read-only: pushes and new issues/PRs disabled"
42 >
43 Archived
44 </span>
45 )}
46 {isTemplate && (
47 <span
48 class="badge"
49 style="background:var(--bg-secondary);color:var(--accent);font-size:11px;padding:2px 8px;border-radius:10px;text-transform:uppercase;letter-spacing:0.5px"
50 title="This repository can be used as a template"
51 >
52 Template
53 </span>
54 )}
c81ab7aClaude55 </div>
56 {forkedFrom && (
57 <div style="font-size: 12px; color: var(--text-muted); margin-top: 2px">
58 forked from <a href={`/${forkedFrom}`}>{forkedFrom}</a>
59 </div>
60 )}
61 </div>
06d5ffeClaude62 <div class="repo-header-actions">
c81ab7aClaude63 {currentUser && currentUser !== owner && (
45e31d0Claude64 <form method="post" action={`/${owner}/${repo}/fork`} style="display:inline">
c81ab7aClaude65 <button type="submit" class="star-btn">
66 {"\u2442"} Fork {forkCount !== undefined && forkCount > 0 ? forkCount : ""}
67 </button>
68 </form>
69 )}
06d5ffeClaude70 {starCount !== undefined && (
71 currentUser ? (
45e31d0Claude72 <form method="post" action={`/${owner}/${repo}/star`} style="display:inline">
06d5ffeClaude73 <button
74 type="submit"
75 class={`star-btn${starred ? " starred" : ""}`}
76 >
77 {starred ? "\u2605" : "\u2606"} {starCount}
78 </button>
79 </form>
80 ) : (
81 <span class="star-btn">
82 {"\u2606"} {starCount}
83 </span>
84 )
85 )}
86 </div>
fc1817aClaude87 </div>
88);
89
90export const RepoNav: FC<{
91 owner: string;
92 repo: string;
3ef4c9dClaude93 active:
94 | "code"
95 | "commits"
96 | "issues"
97 | "pulls"
98 | "releases"
eafe8c6Claude99 | "actions"
3ef4c9dClaude100 | "gates"
3cbe3d6Claude101 | "insights"
102 | "explain"
103 | "changelog"
1e162a8Claude104 | "semantic"
105 | "wiki"
106 | "projects";
fc1817aClaude107}> = ({ owner, repo, active }) => (
108 <div class="repo-nav">
06d5ffeClaude109 <a href={`/${owner}/${repo}`} class={active === "code" ? "active" : ""}>
fc1817aClaude110 Code
111 </a>
79136bbClaude112 <a
113 href={`/${owner}/${repo}/issues`}
114 class={active === "issues" ? "active" : ""}
115 >
116 Issues
117 </a>
1e162a8Claude118 <a
119 href={`/${owner}/${repo}/wiki`}
120 class={active === "wiki" ? "active" : ""}
121 >
122 Wiki
123 </a>
0074234Claude124 <a
125 href={`/${owner}/${repo}/pulls`}
126 class={active === "pulls" ? "active" : ""}
127 >
128 Pull Requests
129 </a>
1e162a8Claude130 <a
131 href={`/${owner}/${repo}/projects`}
132 class={active === "projects" ? "active" : ""}
133 >
134 Projects
135 </a>
fc1817aClaude136 <a
137 href={`/${owner}/${repo}/commits`}
138 class={active === "commits" ? "active" : ""}
139 >
140 Commits
141 </a>
eafe8c6Claude142 <a
143 href={`/${owner}/${repo}/actions`}
144 class={active === "actions" ? "active" : ""}
145 >
146 Actions
147 </a>
3ef4c9dClaude148 <a
149 href={`/${owner}/${repo}/releases`}
150 class={active === "releases" ? "active" : ""}
151 >
152 Releases
153 </a>
154 <a
155 href={`/${owner}/${repo}/gates`}
156 class={active === "gates" ? "active" : ""}
157 >
158 {"\u25CF"} Gates
159 </a>
160 <a
161 href={`/${owner}/${repo}/insights`}
162 class={active === "insights" ? "active" : ""}
163 >
164 Insights
165 </a>
3cbe3d6Claude166 <a
167 href={`/${owner}/${repo}/explain`}
168 class={active === "explain" ? "active" : ""}
169 style="margin-left: auto; color: #bc8cff"
170 >
171 {"\u2728"} Explain
172 </a>
173 <a href={`/${owner}/${repo}/ask`} style="color: #bc8cff">
3ef4c9dClaude174 {"\u2728"} Ask AI
175 </a>
fc1817aClaude176 </div>
177);
178
06d5ffeClaude179export const BranchSwitcher: FC<{
180 owner: string;
181 repo: string;
182 currentRef: string;
183 branches: string[];
184 pathType: "tree" | "blob" | "commits";
185 subPath?: string;
186}> = ({ owner, repo, currentRef, branches, pathType, subPath }) => {
187 if (branches.length <= 1) {
188 return <div class="branch-selector">{currentRef}</div>;
189 }
190
191 return (
192 <div class="branch-dropdown">
193 <button class="branch-selector" type="button">
194 {currentRef} &#9662;
195 </button>
196 <div class="branch-dropdown-content">
197 {branches.map((branch) => {
198 let href: string;
199 if (pathType === "commits") {
200 href = `/${owner}/${repo}/commits/${branch}`;
201 } else if (subPath) {
202 href = `/${owner}/${repo}/${pathType}/${branch}/${subPath}`;
203 } else {
204 href = `/${owner}/${repo}/tree/${branch}`;
205 }
206 return (
207 <a
208 href={href}
209 class={branch === currentRef ? "active-branch" : ""}
210 >
211 {branch}
212 </a>
213 );
214 })}
215 </div>
216 </div>
217 );
218};
219
fc1817aClaude220export const Breadcrumb: FC<{
221 owner: string;
222 repo: string;
223 ref: string;
224 path: string;
225}> = ({ owner, repo, ref, path }) => {
226 const parts = path.split("/").filter(Boolean);
227 const crumbs: { name: string; href: string }[] = [
228 { name: repo, href: `/${owner}/${repo}/tree/${ref}` },
229 ];
230 let accumulated = "";
231 for (const part of parts) {
232 accumulated += (accumulated ? "/" : "") + part;
233 crumbs.push({
234 name: part,
235 href: `/${owner}/${repo}/tree/${ref}/${accumulated}`,
236 });
237 }
238 return (
239 <div class="breadcrumb">
240 {crumbs.map((crumb, i) => (
241 <>
242 {i > 0 && <span>/</span>}
243 {i === crumbs.length - 1 ? (
244 <strong>{crumb.name}</strong>
245 ) : (
246 <a href={crumb.href}>{crumb.name}</a>
247 )}
248 </>
249 ))}
250 </div>
251 );
252};
253
254export const FileTable: FC<{
255 entries: GitTreeEntry[];
256 owner: string;
257 repo: string;
258 ref: string;
259 path: string;
260}> = ({ entries, owner, repo, ref, path }) => (
261 <table class="file-table">
262 <tbody>
263 {entries.map((entry) => {
264 const fullPath = path ? `${path}/${entry.name}` : entry.name;
265 const href =
266 entry.type === "tree"
267 ? `/${owner}/${repo}/tree/${ref}/${fullPath}`
268 : `/${owner}/${repo}/blob/${ref}/${fullPath}`;
269 return (
270 <tr>
271 <td class="file-icon">
272 {entry.type === "tree" ? "\u{1F4C1}" : "\u{1F4C4}"}
273 </td>
274 <td class="file-name">
275 <a href={href}>{entry.name}</a>
276 </td>
277 <td style="text-align: right; color: var(--text-muted); font-size: 13px;">
278 {entry.size !== undefined ? formatSize(entry.size) : ""}
279 </td>
280 </tr>
281 );
282 })}
283 </tbody>
284 </table>
285);
286
06d5ffeClaude287export const HighlightedCode: FC<{
288 highlightedHtml: string;
289 lineCount: number;
290}> = ({ highlightedHtml, lineCount }) => {
291 const lineNums = Array.from({ length: lineCount }, (_, i) => i + 1);
292 return (
293 <div class="blob-code">
294 <table>
295 <tbody>
296 <tr>
297 <td class="line-num" style="vertical-align: top; padding-top: 0; padding-bottom: 0">
298 <pre style="margin: 0; line-height: 1.6; font-size: 13px">
299 {lineNums.map((n) => (
300 <>
301 <span>{n}</span>
302 {"\n"}
303 </>
304 ))}
305 </pre>
306 </td>
307 <td class="line-content" style="vertical-align: top; padding-top: 0; padding-bottom: 0">
308 <pre style="margin: 0; line-height: 1.6; font-size: 13px">{html([highlightedHtml] as unknown as TemplateStringsArray)}</pre>
309 </td>
310 </tr>
311 </tbody>
312 </table>
313 </div>
314 );
315};
316
317export const PlainCode: FC<{ lines: string[] }> = ({ lines }) => (
318 <div class="blob-code">
319 <table>
320 <tbody>
321 {lines.map((line, i) => (
322 <tr>
323 <td class="line-num">{i + 1}</td>
324 <td class="line-content">{line}</td>
325 </tr>
326 ))}
327 </tbody>
328 </table>
329 </div>
330);
331
fc1817aClaude332export const CommitList: FC<{
333 commits: GitCommit[];
334 owner: string;
335 repo: string;
3951454Claude336 verifications?: Record<string, { verified: boolean; reason: string }>;
337}> = ({ commits, owner, repo, verifications }) => (
fc1817aClaude338 <div class="commit-list">
3951454Claude339 {commits.map((commit) => {
340 const v = verifications?.[commit.sha];
341 return (
342 <div class="commit-item">
343 <div>
344 <div class="commit-message">
345 <a href={`/${owner}/${repo}/commit/${commit.sha}`}>
346 {commit.message}
347 </a>
348 {v?.verified && (
349 <span
350 title="Signed with a registered key"
351 style="margin-left:8px;font-size:10px;padding:1px 6px;border-radius:3px;background:var(--green,#2ea043);color:#fff;text-transform:uppercase;letter-spacing:.4px"
352 >
353 Verified
354 </span>
355 )}
356 </div>
357 <div class="commit-meta">
358 {commit.author} committed {formatRelativeDate(commit.date)}
359 </div>
fc1817aClaude360 </div>
3951454Claude361 <a
362 href={`/${owner}/${repo}/commit/${commit.sha}`}
363 class="commit-sha"
364 >
365 {commit.sha.slice(0, 7)}
366 </a>
fc1817aClaude367 </div>
3951454Claude368 );
369 })}
fc1817aClaude370 </div>
371);
372
373export const DiffView: FC<{ raw: string; files: GitDiffFile[] }> = ({
374 raw,
375 files,
376}) => {
377 const sections = parseDiff(raw);
378
379 return (
380 <div class="diff-view">
381 <div style="margin-bottom: 16px; font-size: 14px; color: var(--text-muted);">
382 Showing{" "}
383 <strong style="color: var(--text)">{files.length}</strong> changed
384 file{files.length !== 1 ? "s" : ""} with{" "}
385 <span class="stat-add">
386 +{files.reduce((s, f) => s + f.additions, 0)}
387 </span>{" "}
388 and{" "}
389 <span class="stat-del">
390 -{files.reduce((s, f) => s + f.deletions, 0)}
391 </span>
392 </div>
393 {sections.map((section) => (
394 <div class="diff-file">
395 <div class="diff-file-header">{section.path}</div>
396 <div class="diff-content">
397 {section.lines.map((line) => {
398 let cls = "line";
399 if (line.startsWith("+")) cls += " line-add";
400 else if (line.startsWith("-")) cls += " line-del";
401 else if (line.startsWith("@@")) cls += " line-hunk";
402 return <span class={cls}>{line + "\n"}</span>;
403 })}
404 </div>
405 </div>
406 ))}
407 </div>
408 );
409};
410
06d5ffeClaude411export const RepoCard: FC<{ repo: Repository; ownerName: string }> = ({
412 repo,
413 ownerName,
414}) => (
415 <div class="card">
416 <h3>
417 <a href={`/${ownerName}/${repo.name}`}>{repo.name}</a>
418 </h3>
419 {repo.description && <p>{repo.description}</p>}
420 <div class="card-meta">
421 {repo.isPrivate && <span class="badge">Private</span>}
422 <span>{"\u2606"} {repo.starCount}</span>
423 {repo.pushedAt && (
424 <span>Updated {formatRelativeDate(repo.pushedAt.toString())}</span>
425 )}
426 </div>
427 </div>
428);
429
fc1817aClaude430function parseDiff(raw: string): Array<{ path: string; lines: string[] }> {
431 const sections: Array<{ path: string; lines: string[] }> = [];
432 const diffRegex = /^diff --git a\/(.+?) b\/.+$/;
433 let current: { path: string; lines: string[] } | null = null;
434
435 for (const line of raw.split("\n")) {
436 const match = line.match(diffRegex);
437 if (match) {
438 if (current) sections.push(current);
439 current = { path: match[1], lines: [] };
440 continue;
441 }
442 if (current && !line.startsWith("diff --git")) {
443 if (
444 line.startsWith("index ") ||
445 line.startsWith("--- ") ||
446 line.startsWith("+++ ") ||
447 line.startsWith("new file") ||
448 line.startsWith("deleted file") ||
449 line.startsWith("old mode") ||
450 line.startsWith("new mode")
451 ) {
452 continue;
453 }
454 current.lines.push(line);
455 }
456 }
457 if (current) sections.push(current);
458 return sections;
459}
460
461function formatSize(bytes: number): string {
462 if (bytes < 1024) return `${bytes} B`;
463 if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
464 return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
465}
466
467function formatRelativeDate(dateStr: string): string {
468 const date = new Date(dateStr);
469 const now = new Date();
470 const diffMs = now.getTime() - date.getTime();
471 const diffMins = Math.floor(diffMs / 60000);
472 if (diffMins < 1) return "just now";
473 if (diffMins < 60) return `${diffMins} minute${diffMins > 1 ? "s" : ""} ago`;
474 const diffHours = Math.floor(diffMins / 60);
475 if (diffHours < 24)
476 return `${diffHours} hour${diffHours > 1 ? "s" : ""} ago`;
477 const diffDays = Math.floor(diffHours / 24);
478 if (diffDays < 30) return `${diffDays} day${diffDays > 1 ? "s" : ""} ago`;
479 return date.toLocaleDateString("en-US", {
480 month: "short",
481 day: "numeric",
482 year: "numeric",
483 });
484}