Federated via graft
0

Configure Feed

Select the types of activity you want to include in your feed.

1// Package status tracks the outcome of each repo pair's most recent sync 2// pass, keeps a small dashboard over the activity log, and serves both over 3// HTTP — so an operator can tell the daemon is alive and see what it's 4// actually done without reading logs. 5package status 6 7import ( 8 "encoding/json" 9 "html/template" 10 "net/http" 11 "net/url" 12 "sort" 13 "strings" 14 "sync" 15 "time" 16 17 "graft/internal/state" 18) 19 20// PairResult is the outcome of one repo pair's most recent pass. An empty 21// error string means that scope is either disabled or succeeded. 22type PairResult struct { 23 Name string `json:"name"` 24 Series string `json:"series"` 25 LastRun time.Time `json:"last_run"` 26 GitError string `json:"git_error,omitempty"` 27 IssuesError string `json:"issues_error,omitempty"` 28 PatchError string `json:"patch_error,omitempty"` 29} 30 31func (r PairResult) ok() bool { 32 return r.GitError == "" && r.IssuesError == "" && r.PatchError == "" 33} 34 35// ServerRef is one repo pair's declared mirror target — a specific Forgejo 36// instance or a specific Radicle node — as configured, regardless of 37// whether it has ever actually produced an event yet. 38type ServerRef struct { 39 Label string // host, e.g. "f1.cyberwild.org" 40 URL string // repo root on that host 41} 42 43// Tracker holds the latest result per repo pair, safe for concurrent use, 44// plus a handle on the state store for the activity dashboard. 45type Tracker struct { 46 startedAt time.Time 47 store *state.Store 48 sourceURL string 49 50 mu sync.Mutex 51 pairs map[string]PairResult 52 topology map[string][]ServerRef 53 publicHost string 54} 55 56func NewTracker(store *state.Store, sourceURL string) *Tracker { 57 return &Tracker{startedAt: time.Now(), store: store, sourceURL: sourceURL, pairs: map[string]PairResult{}} 58} 59 60// SetTopology declares every mirror target configured for each series, so 61// the dashboard can show a side that's never produced an event yet (e.g. a 62// Radicle node nothing has been pushed to) instead of only sides the 63// activity log happens to mention. 64func (t *Tracker) SetTopology(topology map[string][]ServerRef) { 65 t.mu.Lock() 66 defer t.mu.Unlock() 67 t.topology = topology 68} 69 70// SetPublicHost declares the host graft is reachable at (e.g. 71// graft.cyberwild.org), enabling the "Social bridges" link and the 72// /social page. Call with "" (the default) to leave ActivityPub disabled. 73func (t *Tracker) SetPublicHost(host string) { 74 t.mu.Lock() 75 defer t.mu.Unlock() 76 t.publicHost = host 77} 78 79// Record stores the outcome of a pass for one pair. Pass nil for a scope 80// that succeeded or wasn't enabled. series is the dashboard row this pair's 81// status badge groups under (see config.RepoPair.Series). 82func (t *Tracker) Record(name, series string, gitErr, issuesErr, patchErr error) { 83 r := PairResult{Name: name, Series: series, LastRun: time.Now()} 84 if gitErr != nil { 85 r.GitError = gitErr.Error() 86 } 87 if issuesErr != nil { 88 r.IssuesError = issuesErr.Error() 89 } 90 if patchErr != nil { 91 r.PatchError = patchErr.Error() 92 } 93 t.mu.Lock() 94 defer t.mu.Unlock() 95 t.pairs[name] = r 96} 97 98func (t *Tracker) snapshot() []PairResult { 99 t.mu.Lock() 100 defer t.mu.Unlock() 101 out := make([]PairResult, 0, len(t.pairs)) 102 for _, r := range t.pairs { 103 out = append(out, r) 104 } 105 sort.Slice(out, func(i, j int) bool { return out[i].Name < out[j].Name }) 106 return out 107} 108 109type statusResponse struct { 110 StartedAt time.Time `json:"started_at"` 111 Pairs []PairResult `json:"pairs"` 112} 113 114// Handler serves: 115// 116// GET /healthz - 200 if every pair's last pass was clean, 503 otherwise 117// GET /api/status - the JSON snapshot Record() has been fed 118// GET / - the activity dashboard (calendar + recent commits) 119func (t *Tracker) Handler() http.Handler { 120 mux := http.NewServeMux() 121 122 mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { 123 for _, p := range t.snapshot() { 124 if !p.ok() { 125 w.WriteHeader(http.StatusServiceUnavailable) 126 return 127 } 128 } 129 w.WriteHeader(http.StatusOK) 130 }) 131 132 mux.HandleFunc("/api/status", func(w http.ResponseWriter, r *http.Request) { 133 resp := statusResponse{StartedAt: t.startedAt, Pairs: t.snapshot()} 134 w.Header().Set("Content-Type", "application/json") 135 json.NewEncoder(w).Encode(resp) 136 }) 137 138 mux.HandleFunc("/", t.serveDashboard) 139 mux.HandleFunc("/social", t.serveSocial) 140 141 return mux 142} 143 144const dashboardDays = 3 145 146func (t *Tracker) serveDashboard(w http.ResponseWriter, r *http.Request) { 147 since := time.Now().UTC().AddDate(0, 0, -(dashboardDays - 1)).Truncate(24 * time.Hour) 148 entries, err := t.store.ActivitySince(since) 149 if err != nil { 150 http.Error(w, "load activity: "+err.Error(), http.StatusInternalServerError) 151 return 152 } 153 154 pairs := groupPairStatus(t.snapshot()) 155 health := make(map[string]bool, len(pairs)) 156 for _, p := range pairs { 157 health[p.Name] = p.OK 158 } 159 160 t.mu.Lock() 161 topology := t.topology 162 publicHost := t.publicHost 163 t.mu.Unlock() 164 165 data := dashboardData{ 166 Series: buildSeriesRows(entries, health, topology), 167 Activity: recentActivity(entries), 168 SourceURL: t.sourceURL, 169 SocialEnabled: publicHost != "", 170 } 171 w.Header().Set("Content-Type", "text/html; charset=utf-8") 172 w.Header().Set("Cache-Control", "no-store") 173 if err := dashboardTmpl.Execute(w, data); err != nil { 174 http.Error(w, err.Error(), http.StatusInternalServerError) 175 } 176} 177 178// socialData is what the /social page renders: one row per series 179// describing its ActivityPub and AT Proto/Bluesky bridges. Built 180// incrementally across the v2 milestones — see the plan for what each 181// stage adds (follower counts, delivery timestamps, bridged-comment 182// counts, Bluesky status). 183type socialData struct { 184 PublicHost string 185 Series []socialRow 186 SourceURL string 187} 188 189type socialRow struct { 190 Name string 191 Handle string // "series@host" 192 WebfingerURL string 193 ActorURL string 194 OutboxURL string 195} 196 197func (t *Tracker) serveSocial(w http.ResponseWriter, r *http.Request) { 198 t.mu.Lock() 199 topology := t.topology 200 publicHost := t.publicHost 201 t.mu.Unlock() 202 203 if publicHost == "" { 204 http.NotFound(w, r) 205 return 206 } 207 208 names := make([]string, 0, len(topology)) 209 for name := range topology { 210 names = append(names, name) 211 } 212 sort.Strings(names) 213 214 rows := make([]socialRow, 0, len(names)) 215 for _, name := range names { 216 actorURL := "https://" + publicHost + "/actors/" + name 217 rows = append(rows, socialRow{ 218 Name: name, 219 Handle: name + "@" + publicHost, 220 WebfingerURL: "https://" + publicHost + "/.well-known/webfinger?resource=acct:" + name + "@" + publicHost, 221 ActorURL: actorURL, 222 OutboxURL: actorURL + "/outbox", 223 }) 224 } 225 226 data := socialData{PublicHost: publicHost, Series: rows, SourceURL: t.sourceURL} 227 w.Header().Set("Content-Type", "text/html; charset=utf-8") 228 w.Header().Set("Cache-Control", "no-store") 229 if err := socialTmpl.Execute(w, data); err != nil { 230 http.Error(w, err.Error(), http.StatusInternalServerError) 231 } 232} 233 234type dashboardData struct { 235 Series []seriesRow 236 Activity []commitLine 237 SourceURL string 238 SocialEnabled bool 239} 240 241// pairStatus is one badge in the dashboard's top status card: one per 242// series (repo), OK only if every pair mirroring that repo's last pass was 243// clean — grouped so a repo with 3 mirrored sides (e.g. two Forgejos plus 244// an external instance) shows one badge, not three. 245type pairStatus struct { 246 Name string 247 OK bool 248} 249 250func groupPairStatus(results []PairResult) []pairStatus { 251 order := []string{} 252 ok := map[string]bool{} 253 for _, r := range results { 254 name := r.Series 255 if name == "" { 256 name = r.Name 257 } 258 if _, seen := ok[name]; !seen { 259 order = append(order, name) 260 ok[name] = true 261 } 262 if !r.ok() { 263 ok[name] = false 264 } 265 } 266 sort.Strings(order) 267 out := make([]pairStatus, 0, len(order)) 268 for _, name := range order { 269 out = append(out, pairStatus{Name: name, OK: ok[name]}) 270 } 271 return out 272} 273 274// seriesRow is one full-width strip of the activity heatmap: everything 275// mirrored for one underlying repository (grouped across its Forgejo and 276// Radicle sides via config.RepoPair.Series), one cell per actual event — 277// not one per day — so nothing is ever aggregated behind a single tooltip. 278type seriesRow struct { 279 Name string 280 OK bool 281 SubRows []subRow 282} 283 284// subRow is one mirrored side of a series — one real repo (a specific 285// Forgejo instance, or a specific Radicle node) — shown once the series is 286// expanded, with only that side's own events and its own link. A series 287// with 3 mirrored sides (two Forgejos plus Radicle) gets 3 sub-rows, never 288// one link picked arbitrarily to represent all of them. 289type subRow struct { 290 Label string 291 URL string 292 Events []event 293} 294 295// event is one activity_log row: one heatmap cell, one tooltip, one link. 296type event struct { 297 Kind string // "git", "issue", "patch" — drives the cell's color 298 Label string // "Commit", "Issue", "Patch" 299 Text string 300 URL string 301 Server string // which mirrored side this happened on, e.g. "f1", "alice" 302 When string // human-readable timestamp, for the tooltip 303} 304 305type commitLine struct { 306 When string 307 Pair string 308 PairURL string 309 Server string 310 Kind string // "Commit", "Issue", "Patch" 311 Message string 312 URL string 313} 314 315// serverLabel names which side of a series a repo_pair belongs to, e.g. 316// "federation-x-f1" under series "federation-x" becomes "f1". Several pairs 317// share one series row/badge, so without this an operator can't tell which 318// mirrored server (f1, f2, an external instance...) a given event actually 319// happened on. Empty if the pair name doesn't start with its series name. 320func serverLabel(repoPair, series string) string { 321 if series == "" { 322 return "" 323 } 324 suffix := strings.TrimPrefix(repoPair, series+"-") 325 if suffix == repoPair { 326 return "" 327 } 328 return suffix 329} 330 331// hostLabel shortens a URL's host to its canonical name for compact 332// display: the TLD is dropped ("f1.cyberwild.org" -> "f1.cyberwild", 333// "artefacts.bimr.net" -> "artefacts.bimr"), so every server — ours or an 334// external instance's — reads the same way, never a per-pair alias. 335func hostLabel(rawURL string) string { 336 u, err := url.Parse(rawURL) 337 if err != nil || u.Host == "" { 338 return "" 339 } 340 host := u.Host 341 // A Radicle Explorer URL's host is always the shared frontend 342 // (e.g. radicle.cyberwild.org) — the actual node lives in the path, 343 // /nodes/<node-host>/<rid>/... — so different Radicle nodes get 344 // distinct labels instead of collapsing into one shared one. 345 if segs := strings.Split(strings.TrimPrefix(u.Path, "/"), "/"); len(segs) >= 2 && segs[0] == "nodes" { 346 host = segs[1] 347 } 348 return host 349} 350 351// buildSeriesRows groups entries by their Series (one row per monitored 352// repo, spanning both its Forgejo and Radicle sides) — Atlassian 353// Statuspage style: one full-width horizontal strip per series. Each entry 354// becomes its own cell, oldest first, so a busy day never hides events 355// behind one shared tooltip. 356func buildSeriesRows(entries []state.ActivityEntry, health map[string]bool, topology map[string][]ServerRef) []seriesRow { 357 type subAcc struct { 358 url string 359 events []state.ActivityEntry 360 } 361 type seriesAcc struct { 362 subOrder []string 363 subs map[string]*subAcc 364 } 365 seriesAccs := map[string]*seriesAcc{} 366 var seriesOrder []string 367 368 ensureSeries := func(name string) *seriesAcc { 369 sa, ok := seriesAccs[name] 370 if !ok { 371 sa = &seriesAcc{subs: map[string]*subAcc{}} 372 seriesAccs[name] = sa 373 seriesOrder = append(seriesOrder, name) 374 } 375 return sa 376 } 377 ensureSub := func(sa *seriesAcc, label string) *subAcc { 378 sub, ok := sa.subs[label] 379 if !ok { 380 sub = &subAcc{} 381 sa.subs[label] = sub 382 sa.subOrder = append(sa.subOrder, label) 383 } 384 return sub 385 } 386 387 // Seed every configured mirror target first, so a side that has never 388 // produced an event (e.g. a Radicle node nothing has been pushed to 389 // yet) still gets its own row instead of being invisible. 390 for name, refs := range topology { 391 sa := ensureSeries(name) 392 for _, ref := range refs { 393 sub := ensureSub(sa, ref.Label) 394 if sub.url == "" { 395 sub.url = ref.URL 396 } 397 } 398 } 399 400 for _, e := range entries { 401 name := e.Series 402 if name == "" { 403 name = e.RepoPair 404 } 405 sa := ensureSeries(name) 406 server := hostLabel(e.URL) 407 if server == "" { 408 server = serverLabel(e.RepoPair, e.Series) 409 } 410 if server == "" { 411 server = e.RepoPair 412 } 413 sub := ensureSub(sa, server) 414 if sub.url == "" { 415 sub.url = repoRootURL(e.URL) 416 } 417 sub.events = append(sub.events, e) 418 } 419 sort.Strings(seriesOrder) 420 421 rows := make([]seriesRow, 0, len(seriesOrder)) 422 for _, name := range seriesOrder { 423 sa := seriesAccs[name] 424 subOrder := append([]string(nil), sa.subOrder...) 425 sort.Strings(subOrder) 426 427 subRows := make([]subRow, 0, len(subOrder)) 428 for _, label := range subOrder { 429 sub := sa.subs[label] 430 // entries arrive newest-first (see ActivitySince); the 431 // heatmap reads left-to-right as oldest-to-newest. 432 es := make([]state.ActivityEntry, len(sub.events)) 433 copy(es, sub.events) 434 sort.Slice(es, func(i, j int) bool { return es[i].OccurredAt.Before(es[j].OccurredAt) }) 435 subRows = append(subRows, subRow{Label: label, URL: sub.url, Events: toEvents(es)}) 436 } 437 438 ok, known := health[name] 439 if !known { 440 ok = true 441 } 442 rows = append(rows, seriesRow{Name: name, OK: ok, SubRows: subRows}) 443 } 444 return rows 445} 446 447func toEvents(es []state.ActivityEntry) []event { 448 out := make([]event, 0, len(es)) 449 for _, e := range es { 450 server := hostLabel(e.URL) 451 if server == "" { 452 server = serverLabel(e.RepoPair, e.Series) 453 } 454 out = append(out, event{ 455 Kind: e.Kind, 456 Label: kindLabel(e.Kind), 457 Text: e.Summary, 458 URL: e.URL, 459 Server: server, 460 When: e.OccurredAt.Format("Mon, Jan 2, 15:04"), 461 }) 462 } 463 return out 464} 465 466func kindLabel(kind string) string { 467 switch kind { 468 case "git": 469 return "Commit" 470 case "issue": 471 return "Issue" 472 case "patch": 473 return "Patch" 474 default: 475 return kind 476 } 477} 478 479// recentActivity lists every mirrored event — commits, issues, and 480// patches/pull requests alike, newest first. graft doesn't mirror stars or 481// other social metadata: its sync scope is git content, issues, and 482// patches/PRs only (see config.SyncScope), so that's what shows up here. 483func recentActivity(entries []state.ActivityEntry) []commitLine { 484 out := make([]commitLine, 0, len(entries)) 485 for _, e := range entries { 486 name := e.Series 487 if name == "" { 488 name = e.RepoPair 489 } 490 server := hostLabel(e.URL) 491 if server == "" { 492 server = serverLabel(e.RepoPair, e.Series) 493 } 494 // The (server) parenthetical should point at that specific 495 // server's own repo, not the series' shared Radicle explorer 496 // link (which is fixed to whichever pair logged first). 497 pairURL := repoRootURL(e.URL) 498 if pairURL == "" { 499 pairURL = e.SeriesURL 500 } 501 out = append(out, commitLine{ 502 When: e.OccurredAt.Format("Jan 2, 15:04"), 503 Pair: name, 504 PairURL: pairURL, 505 Server: server, 506 Kind: kindLabel(e.Kind), 507 Message: e.Summary, 508 URL: e.URL, 509 }) 510 } 511 return out 512} 513 514// repoRootURL trims an event's specific-item URL (a commit, issue, or 515// patch/PR page) back down to its repository root, e.g. 516// ".../owner/repo/commit/<sha>" -> ".../owner/repo". Empty if rawURL is 517// empty or doesn't contain a recognized item path. 518func repoRootURL(rawURL string) string { 519 // Forgejo uses singular "/commit/"; Radicle Explorer uses plural 520 // "/commits/" — both must be recognized, or every Radicle-hosted 521 // commit link falls back to a non-clickable label. 522 for _, marker := range []string{"/commit/", "/commits/", "/issues/", "/pulls/", "/patches/"} { 523 if idx := strings.Index(rawURL, marker); idx >= 0 { 524 return rawURL[:idx] 525 } 526 } 527 return "" 528} 529 530var dashboardTmpl = template.Must(template.New("dashboard").Parse(`<!doctype html> 531<html lang="en"> 532<head> 533<meta charset="utf-8"> 534<meta name="viewport" content="width=device-width, initial-scale=1"> 535<title>graft</title> 536<style> 537 :root { 538 color-scheme: light; 539 --surface: #ffffff; 540 --surface-sunk: #f4f5f7; 541 --text: #172b4d; 542 --text-muted: #6b778c; 543 --border: #dfe1e6; 544 --brand: #0052cc; 545 --brand-dark: #0747a6; 546 --kind-git: #0052cc; 547 --kind-issue: #00875a; 548 --kind-patch: #6554c0; 549 --bad: #de350b; 550 --good: #36b37e; 551 } 552 * { box-sizing: border-box; } 553 body { 554 margin: 0; 555 background: var(--surface-sunk); 556 color: var(--text); 557 font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 558 } 559 main { max-width: 920px; margin: 0 auto; padding: 2.5rem 1.5rem 1rem; } 560 561 .top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1.5rem; } 562 .top > div { display: flex; align-items: baseline; gap: .6rem; } 563 h1 { font-size: 1.25rem; margin: 0; font-weight: 600; } 564 .sub { color: var(--text-muted); font-size: .85rem; } 565 .nav-link { color: var(--brand); font-size: .82rem; text-decoration: none; font-weight: 500; } 566 .nav-link:hover { text-decoration: underline; } 567 568 .card { 569 background: var(--surface); 570 border: 1px solid var(--border); 571 border-radius: 4px; 572 padding: 1.25rem 1.5rem; 573 margin-bottom: 1.25rem; 574 } 575 576 .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); flex: none; display: inline-block; } 577 .dot.bad { background: var(--bad); } 578 579 .heatmap-head { display: flex; align-items: baseline; justify-content: space-between; } 580 .heatmap-head h2 { margin: 0; } 581 .legend { display: flex; gap: .9rem; margin-bottom: .9rem; } 582 .legend span { display: flex; align-items: center; gap: .35rem; font-size: .74rem; color: var(--text-muted); } 583 .legend .sw { width: 8px; height: 8px; border-radius: 2px; display: inline-block; } 584 .legend .sw[data-kind="git"] { background: var(--kind-git); } 585 .legend .sw[data-kind="issue"] { background: var(--kind-issue); } 586 .legend .sw[data-kind="patch"] { background: var(--kind-patch); } 587 .heatmap { display: flex; flex-direction: column; gap: .15rem; } 588 .series-group { border-bottom: 1px solid var(--border); } 589 .series-group:last-child { border-bottom: none; } 590 .series-group[open] { padding-bottom: .5rem; } 591 .series-label { 592 display: flex; align-items: center; gap: .45rem; padding: .55rem 0; 593 cursor: pointer; list-style: none; 594 } 595 .series-label::-webkit-details-marker { display: none; } 596 .series-label::before { 597 content: ""; width: 0; height: 0; flex: none; 598 border-style: solid; border-width: 4px 0 4px 5px; 599 border-color: transparent transparent transparent var(--text-muted); 600 transition: transform .12s ease; 601 } 602 .series-group[open] > .series-label::before { transform: rotate(90deg); } 603 .series-name { font-size: .82rem; font-weight: 600; color: var(--text); } 604 .series-count { font-size: .74rem; color: var(--text-muted); } 605 .subrows { display: flex; flex-direction: column; gap: .5rem; padding-left: 1.3rem; } 606 .subrow { display: flex; align-items: center; gap: .75rem; } 607 .subrow-name { 608 flex: 0 0 11rem; font-size: .78rem; color: var(--text-muted); text-decoration: none; 609 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; 610 } 611 a.subrow-name { color: var(--brand); } 612 a.subrow-name:hover { text-decoration: underline; } 613 .days { display: flex; gap: 3px; flex-wrap: wrap; } 614 .cell { 615 flex: none; width: 10px; height: 22px; border-radius: 3px; 616 background: var(--border); position: relative; cursor: default; 617 } 618 .cell[data-kind="git"] { background: var(--kind-git); } 619 .cell[data-kind="issue"] { background: var(--kind-issue); } 620 .cell[data-kind="patch"] { background: var(--kind-patch); } 621 622 .tip { 623 display: none; position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); 624 background: var(--text); color: #fff; border-radius: 6px; 625 font-size: .78rem; z-index: 20; padding: .5rem 0; 626 box-shadow: 0 4px 12px rgba(9,30,66,.25); 627 width: max-content; max-width: min(320px, 90vw); 628 } 629 .cell:nth-child(-n+2) .tip { left: 0; transform: none; } 630 .cell:nth-last-child(-n+2) .tip { left: auto; right: 0; transform: none; } 631 .cell:hover .tip, .tip:hover { display: block; } 632 .tip .tip-date { padding: 0 .75rem .35rem; font-weight: 600; border-bottom: 1px solid rgba(255,255,255,.15); margin-bottom: .35rem; } 633 .tip a.tip-row { 634 display: flex; gap: .4em; padding: .3rem .75rem; color: #fff; text-decoration: none; 635 white-space: normal; overflow-wrap: anywhere; line-height: 1.35; 636 } 637 .tip a.tip-row:hover { background: rgba(255,255,255,.12); } 638 .tip .tip-kind { color: #b3bac5; flex: none; } 639 .tip .tip-empty { padding: 0 .75rem; color: #b3bac5; } 640 641 h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: 0 0 .9rem; font-weight: 600; } 642 .commits { border-top: 1px solid var(--border); } 643 .commit { 644 display: flex; align-items: center; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--border); 645 font-size: .82rem; 646 } 647 .commit .when { color: var(--text-muted); flex: none; width: 9em; } 648 .commit .kind { color: var(--text-muted); flex: none; width: 4.5em; font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; } 649 .commit .pair { 650 color: var(--text-muted); flex: 0 1 auto; max-width: 22em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; 651 text-decoration: none; 652 } 653 .commit a.pair { color: var(--brand); } 654 .commit a.pair:hover { text-decoration: underline; } 655 .commit .msg { 656 flex: 1 1 auto; min-width: 0; 657 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, monospace; 658 color: inherit; text-decoration: none; 659 } 660 .commit a.msg { color: var(--brand); } 661 .commit a.msg:hover { text-decoration: underline; } 662 .empty { color: var(--text-muted); padding: .5rem 0; } 663 664 footer { 665 max-width: 920px; margin: 0 auto; padding: 1rem 1.5rem 2.5rem; 666 color: var(--text-muted); font-size: .78rem; display: flex; gap: 1rem; 667 } 668 footer a { color: var(--text-muted); } 669</style> 670</head> 671<body> 672<main> 673 <div class="top"> 674 <div> 675 <h1>graft</h1> 676 <span class="sub">Forgejo &lt;-&gt; Radicle sync — last 3 days</span> 677 </div> 678 {{if .SocialEnabled}}<a class="nav-link" href="/social">Social bridges &rarr;</a>{{end}} 679 </div> 680 681 <div class="card"> 682 <div class="heatmap-head"> 683 <h2>Activity by repo</h2> 684 <div class="legend"> 685 <span><i class="sw" data-kind="git"></i>Commit</span> 686 <span><i class="sw" data-kind="issue"></i>Issue</span> 687 <span><i class="sw" data-kind="patch"></i>Patch</span> 688 </div> 689 </div> 690 <div class="heatmap"> 691 {{range .Series}} 692 <details class="series-group"> 693 <summary class="series-label"> 694 <span class="dot{{if not .OK}} bad{{end}}"></span> 695 <span class="series-name">{{.Name}}</span> 696 <span class="series-count">{{len .SubRows}} mirrored side{{if ne (len .SubRows) 1}}s{{end}}</span> 697 </summary> 698 <div class="subrows"> 699 {{range .SubRows}} 700 <div class="subrow"> 701 {{if .URL}} 702 <a class="subrow-name" href="{{.URL}}" target="_blank" rel="noopener">{{.Label}}</a> 703 {{else}} 704 <span class="subrow-name">{{.Label}}</span> 705 {{end}} 706 <div class="days"> 707 {{range .Events}} 708 <div class="cell" data-kind="{{.Kind}}"> 709 <div class="tip"> 710 <div class="tip-date">{{.When}}</div> 711 {{if .URL}} 712 <a class="tip-row" href="{{.URL}}" target="_blank" rel="noopener"><span class="tip-kind">{{.Label}}</span>{{.Text}}</a> 713 {{else}} 714 <span class="tip-row"><span class="tip-kind">{{.Label}}</span>{{.Text}}</span> 715 {{end}} 716 </div> 717 </div> 718 {{else}} 719 <span class="tip-empty">nothing synced</span> 720 {{end}} 721 </div> 722 </div> 723 {{end}} 724 </div> 725 </details> 726 {{else}} 727 <span class="empty">nothing synced yet</span> 728 {{end}} 729 </div> 730 </div> 731 732 <div class="card"> 733 <h2>Recent activity</h2> 734 <div class="commits"> 735 {{range .Activity}} 736 <div class="commit"> 737 <span class="when">{{.When}}</span> 738 <span class="kind">{{.Kind}}</span> 739 {{if .PairURL}} 740 <a class="pair" href="{{.PairURL}}" target="_blank" rel="noopener">{{.Pair}}{{if .Server}} ({{.Server}}){{end}}</a> 741 {{else}} 742 <span class="pair">{{.Pair}}{{if .Server}} ({{.Server}}){{end}}</span> 743 {{end}} 744 {{if .URL}} 745 <a class="msg" href="{{.URL}}" target="_blank" rel="noopener">{{.Message}}</a> 746 {{else}} 747 <span class="msg">{{.Message}}</span> 748 {{end}} 749 </div> 750 {{else}} 751 <p class="empty">nothing mirrored yet</p> 752 {{end}} 753 </div> 754 </div> 755</main> 756<footer> 757 {{if .SourceURL}}<a href="{{.SourceURL}}" target="_blank" rel="noopener">{{.SourceURL}}</a>{{end}} 758 <span>GPLv3</span> 759</footer> 760</body> 761</html> 762`)) 763 764var socialTmpl = template.Must(template.New("social").Parse(`<!doctype html> 765<html lang="en"> 766<head> 767<meta charset="utf-8"> 768<meta name="viewport" content="width=device-width, initial-scale=1"> 769<title>graft — social bridges</title> 770<style> 771 :root { 772 color-scheme: light; 773 --surface: #ffffff; 774 --surface-sunk: #f4f5f7; 775 --text: #172b4d; 776 --text-muted: #6b778c; 777 --border: #dfe1e6; 778 --brand: #0052cc; 779 } 780 * { box-sizing: border-box; } 781 body { 782 margin: 0; background: var(--surface-sunk); color: var(--text); 783 font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 784 } 785 main { max-width: 760px; margin: 0 auto; padding: 2.5rem 1.5rem 1rem; } 786 .top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1.5rem; } 787 .top > div { display: flex; align-items: baseline; gap: .6rem; } 788 h1 { font-size: 1.25rem; margin: 0; font-weight: 600; } 789 .sub { color: var(--text-muted); font-size: .85rem; } 790 .nav-link { color: var(--brand); font-size: .82rem; text-decoration: none; font-weight: 500; } 791 .nav-link:hover { text-decoration: underline; } 792 .card { 793 background: var(--surface); border: 1px solid var(--border); border-radius: 4px; 794 padding: 1.25rem 1.5rem; margin-bottom: 1.25rem; 795 } 796 .series-block { padding: .75rem 0; border-bottom: 1px solid var(--border); } 797 .series-block:last-child { border-bottom: none; } 798 .handle { font-size: .95rem; font-weight: 600; color: var(--text); } 799 h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: .6rem 0 .4rem; font-weight: 600; } 800 .endpoints { display: flex; flex-direction: column; gap: .3rem; } 801 .endpoints a { font-size: .8rem; color: var(--brand); text-decoration: none; font-family: ui-monospace, monospace; } 802 .endpoints a:hover { text-decoration: underline; } 803 .badge { 804 display: inline-block; font-size: .72rem; color: var(--text-muted); background: var(--surface-sunk); 805 border: 1px solid var(--border); border-radius: 3px; padding: .15rem .5rem; margin-top: .4rem; 806 } 807 .empty { color: var(--text-muted); padding: .5rem 0; } 808 footer { 809 max-width: 760px; margin: 0 auto; padding: 1rem 1.5rem 2.5rem; 810 color: var(--text-muted); font-size: .78rem; display: flex; gap: 1rem; 811 } 812 footer a { color: var(--text-muted); } 813</style> 814</head> 815<body> 816<main> 817 <div class="top"> 818 <div> 819 <h1>graft — social bridges</h1> 820 <span class="sub">ActivityPub + AT Proto, per repo</span> 821 </div> 822 <a class="nav-link" href="/">&larr; Dashboard</a> 823 </div> 824 825 <div class="card"> 826 {{range .Series}} 827 <div class="series-block"> 828 <div class="handle">@{{.Handle}}</div> 829 <h2>ActivityPub</h2> 830 <div class="endpoints"> 831 <a href="{{.WebfingerURL}}" target="_blank" rel="noopener">WebFinger</a> 832 <a href="{{.ActorURL}}" target="_blank" rel="noopener">Actor</a> 833 <a href="{{.OutboxURL}}" target="_blank" rel="noopener">Outbox</a> 834 </div> 835 <h2>AT Proto / Bluesky</h2> 836 <span class="badge">not configured</span> 837 </div> 838 {{else}} 839 <span class="empty">no series configured</span> 840 {{end}} 841 </div> 842</main> 843<footer> 844 {{if .SourceURL}}<a href="{{.SourceURL}}" target="_blank" rel="noopener">{{.SourceURL}}</a>{{end}} 845 <span>GPLv3</span> 846</footer> 847</body> 848</html> 849`))