Documentation
¶
Overview ¶
Package sponsors owns the M4 "sponsors" plugin. The plugin is gated by the `read:user` AND `read:org` OAuth scopes; the MVP wires the scope-gate path and returns an empty (but non-Skipped) Result when both scopes are present. The full GraphQL fetch lands as a follow-up.
Index ¶
Constants ¶
const Name = "sponsors"
Name is the canonical plugin slug.
Variables ¶
var Plugin plugins.Plugin = &sponsorsPlugin{}
Plugin is the singleton registered with the global plugin registry.
Functions ¶
func Partial ¶
Partial renders the classic SVG fragment for the sponsors plugin matching upstream org_repo/source/templates/classic/partials/sponsors.ejs.
Output structure:
<section data-section="sponsors">
<section>
<h2 class="field"><svg heart/>${title}</h2>
[for each section in sections — skip "list" when "goal" also present]
[section === "goal" || "list"]:
<div class="fill-width">
<section class="sponsors goal">
[if section === "goal" && goal exists]:
<div class="markdown">${goal.description}</div>
<svg class="bar"><mask>...<rect fill="#ec6cb9"/></svg>
<div class="goal-text">
<span>${count.active.total} sponsor(s) are funding ${user}'s work</span>
[if section === "goal" && goal]:
<span>${goal.title}</span>
</div>
[if section === "list" || sections.includes("list")]:
<div class="row"><img class="avatar" ...></div>
[if past && count.past.total]:
<div class="past-text">${count.past.total} sponsor(s) helped ${user} in the past</div>
<div class="row"><img class="avatar past" ...></div>
</section>
</div>
[section === "about"]:
<div class="row fill-width">
<section class="sponsors"><div class="markdown">${about}</div></section>
</div>
</section>
</section>
Settings: mjun0812 uses plugin_sponsors_sections: goal, about, list + plugin_sponsors_past: yes.
Types ¶
type Count ¶ added in v1.1.0
type Count struct {
Active CountBucket `json:"active"`
Past CountBucket `json:"past"`
}
Count carries active + past sponsor totals.
type CountBucket ¶ added in v1.1.0
type CountBucket struct {
Total int `json:"total"`
}
CountBucket is one bucket in the Count breakdown.
type Goal ¶ added in v1.1.0
type Goal struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
// Progress is the percent (0-100) of the funding goal currently met.
Progress int `json:"progress,omitempty"`
}
Goal mirrors `plugins.sponsors.goal` — funding-goal progress bar shown when the user configures a goal on their GitHub Sponsors profile.
type Result ¶
type Result struct {
Skipped bool `json:"skipped,omitempty"`
SkippedReason string `json:"-"`
Mode string `json:"mode,omitempty"`
Sections []string `json:"sections"`
Sponsors []Sponsor `json:"sponsors"`
Past []Sponsor `json:"past,omitempty"`
// 011 v2 additions for upstream parity (Principle II additive).
// Title is rendered in the section header (`<h2>`); defaults to
// the user's login when empty.
Title string `json:"title,omitempty"`
// User is the login the partial uses in "${user} is being funded by..."
// strings; sourced from PluginContext.Data.User.Login.
User string `json:"user,omitempty"`
// Goal mirrors `plugins.sponsors.goal` when the user has a
// sponsorship goal set on their profile. Empty Goal => no goal
// progress bar rendered.
Goal *Goal `json:"goal,omitempty"`
// About is the markdown blurb shown in the `about` sub-section.
About string `json:"about,omitempty"`
// PastIncluded toggles the past-sponsors block (mjun0812 sets
// `plugin_sponsors_past: yes`).
PastIncluded bool `json:"pastIncluded,omitempty"`
// Size is the per-sponsor avatar width/height in px (upstream
// default 64).
Size int `json:"size,omitempty"`
// Count carries active + past totals (upstream uses these in the
// "N sponsors are funding..." line).
Count Count `json:"count,omitempty"`
}
Result is the JSON payload published under data.Plugins["sponsors"].
type Sponsor ¶
type Sponsor struct {
Login string `json:"login"`
Tier string `json:"tier"`
Since time.Time `json:"since"`
Avatar string `json:"avatar,omitempty"`
// Type is "user" or "organization". The organization variant gets
// a different CSS class on the avatar (rounded square vs circle).
Type string `json:"type,omitempty"`
}
Sponsor mirrors one entry from the upstream sponsor list. The Avatar + Type fields land in v2 for the avatar grid render.