Documentation
¶
Overview ¶
Package repositories owns the M4 "repositories" plugin. It filters, sorts, and presents the user's repository list — the data the base plugin's paging loop already produced into pc.Data.Computed.RepositoryList.
MVP scope (Phase 3 US1):
- Featured: filter by `_forks` / `_skipped` and sort by `_order` (stars / forks / watchers).
- Random: deterministic Fisher-Yates over Featured when `_random=true` (seed via `_random_seed`).
- Starred (012): fetched from `/users/<login>/starred` when `_starred=true`. Falls back to the Featured-copy placeholder when REST is unavailable (test paths / no token).
Inputs accepted for upstream-compat but NOT yet wired in this MVP:
- `plugin_repositories_affiliations`: parsed but ignored. Base surfaces OWNER repositories regardless. Future US2 work will route this through a dedicated GraphQL query.
- `plugin_repositories_pinned`: when set, the corresponding Result section is populated by reusing Featured as a placeholder. The dedicated `user.pinnedItems` GraphQL fragment lands in the 013 PR.
Index ¶
Constants ¶
const Name = "repositories"
Name is the canonical plugin slug.
Variables ¶
var Plugin plugins.Plugin = &repositoriesPlugin{}
Plugin is the singleton registered with the global plugin registry.
Functions ¶
func Partial ¶
Partial renders the classic SVG fragment for the repositories plugin. Mirrors upstream org_repo/source/templates/classic/partials/repositories.ejs.
Output structure:
<section data-section="repositories">
<h2 class="field"><svg/>Featured repositories</h2>
<div class="row"><section class="largeable-flex-wrap">
[for each repo]:
<div class="row fill-width largeable-width-half">
<section class="repository">
<div class="field"><svg repo|fork/><div class="name">
<span>${nameWithOwner}</span>
[if createdAt]: <span>created ${created}</span>
</div></div>
[if description]: <div class="field description">${description}</div>
<div class="field infos">
[if language]: <div class="language"><svg dot/>${name}</div>
[if license]: <div><svg law/>${license}</div>
<div><svg star/>${stars}</div>
<div><svg fork/>${forks}</div>
<div><svg issue/>${issues}</div>
<div><svg pr/>${pullRequests}</div>
</div>
</section>
</div>
</section></div>
</section>
#466: the per-card "created <date>" label plus the license / issue / pull-request counters mirror upstream repositories.ejs. The license label follows upstream `f.license` (nickname → spdxId → name) via plugins.RepositoryLicense.Label. REST-sourced starred repos leave CreatedAt / License zero, so those fragments are simply skipped.
Types ¶
type Result ¶
type Result struct {
Skipped bool `json:"skipped,omitempty"`
SkippedReason string `json:"-"`
Featured []plugins.Repository `json:"featured"`
Pinned []plugins.Repository `json:"pinned,omitempty"`
Starred []plugins.Repository `json:"starred,omitempty"`
Random []plugins.Repository `json:"random,omitempty"`
}
Result is the JSON payload published under data.Plugins["repositories"].