sponsorships

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sponsorships owns the M4 "sponsorships" plugin. It returns the sponsorships the viewer is paying for. In M4 the plugin is scaffolded; the underlying `viewer.sponsorshipsAsSponsor` GraphQL call lands as a follow-up once the schema covers it. The MVP wires the type surface so downstream consumers see the slot.

Index

Constants

View Source
const Name = "sponsorships"

Name is the canonical plugin slug.

Variables

View Source
var Plugin plugins.Plugin = &sponsorshipsPlugin{}

Plugin is the singleton registered with the global plugin registry.

Functions

func Partial

Partial renders the classic SVG fragment for the sponsorships plugin. Mirrors upstream org_repo/source/templates/classic/partials/sponsorships.ejs: it iterates the configured sections (default "amount, sponsorships") and renders each branch. Unlike the prior implementation it never short-circuits on an empty list — the "amount" section ("$0.00 to open source software") and the "0 users" goal text render even at zero sponsorships, matching the upstream reference card (#449).

Output structure:

<section data-section="sponsorships">
  <h2 class="field"><svg heart/>Sponsorships</h2>
  [amount]:
  <div class="row fill-width">
    <section class="sponsorships sponsors goal">
      <img src="<heart>" alt="" />
      <div><span class="bold">${user}</span> has given a total of
           <span class="bold">$X.XX</span> to open source software
           [since <span class="bold">${date}</span>].</div>
    </section>
  </div>
  [sponsorships]:
  <div class="row fill-width">
    <section class="sponsors goal">
      <div class="goal-text"><span>${user} helped funding the work of N users and organizations.</span></div>
      <div class="row"><img class="avatar ..." .../>...</div>
    </section>
  </div>
</section>

Types

type Result

type Result struct {
	Skipped       bool        `json:"skipped,omitempty"`
	SkippedReason string      `json:"-"`
	Active        []Sponsored `json:"active"`
	Past          []Sponsored `json:"past,omitempty"`
	// Sections honors plugin_sponsorships_sections (default
	// "amount, sponsorships") and drives which partial branches render.
	Sections []string `json:"sections"`
	// Amount is the total spend in US dollars (cents / 100) the viewer
	// has sponsored. Renders in the "amount" section; zero is valid and
	// still renders as "$0.00".
	Amount float64 `json:"amount"`
	// Image is the URL of the heart image shown in the "amount" section.
	// The render pipeline inlines it as a base64 data URI.
	Image string `json:"image,omitempty"`
	// Started is the date of the viewer's first sponsorship, shown as
	// "since <date>" in the amount line. Nil when there are none.
	Started *time.Time `json:"started,omitempty"`
}

Result is the JSON payload published under data.Plugins["sponsorships"].

func (*Result) IsSkipped

func (r *Result) IsSkipped() bool

IsSkipped lets the classic dispatcher detect the skipped path.

type Sponsored struct {
	Login  string     `json:"login"`
	Tier   string     `json:"tier"`
	Since  time.Time  `json:"since"`
	Until  *time.Time `json:"until,omitempty"`
	Avatar string     `json:"avatar,omitempty"`
	Type   string     `json:"type,omitempty"`
}

Sponsored carries one entry from the upstream sponsorships list.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL