showcase

package
v0.19.3 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: BSD-2-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatLanguagesWithPercentages added in v0.4.0

func FormatLanguagesWithPercentages(languages []LanguageStats) string

FormatLanguagesWithPercentages formats languages with their percentages

func GenerateRankHistorySVG added in v0.18.3

func GenerateRankHistorySVG(summaries []ProjectSummary) string

GenerateRankHistorySVG creates an interactive inline SVG that shows a Google-Trends-style rank history graph for all projects.

Layout:

  • Plot area: left = oldest snapshot, right = "now"; rank 1 at top.
  • Legend panel: 3-column grid to the right of the plot; hovering a legend entry highlights the corresponding plot line.
  • The SVG uses width/height="100%" so it fills the browser window.

Types

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator handles showcase generation for repositories. It orchestrates the per-repo pipeline (filter -> summarize -> link -> write) and delegates the actual work to focused collaborators: SummaryCache owns cache/rank- history persistence, ProjectLinker owns outbound URL construction, and aitool.Runner (via resolveSummary) owns AI-tool selection and invocation.

func New

func New(cfg *config.Config, workDir string) *Generator

New creates a new showcase generator

func (*Generator) GenerateShowcase

func (g *Generator) GenerateShowcase(repoFilter []string, forceRegenerate bool) error

GenerateShowcase generates a showcase for repositories If repoFilter is provided, only those repositories are processed If repoFilter is empty/nil, all repositories in work directory are processed

func (*Generator) SetAITool added in v0.8.1

func (g *Generator) SetAITool(tool string)

SetAITool sets the AI tool to use for generating summaries

type LanguageStats added in v0.4.0

type LanguageStats struct {
	Name       string
	Lines      int
	Percentage float64
}

LanguageStats holds statistics for a programming language

type LegacyRepoMetadata added in v0.4.0

type LegacyRepoMetadata struct {
	Languages       []string
	CommitCount     int
	LinesOfCode     int
	FirstCommitDate string
	LastCommitDate  string
	License         string
	AvgCommitAge    float64
}

LegacyRepoMetadata for backwards compatibility with old cache files

type ProjectLinker added in v0.19.3

type ProjectLinker struct {
	// contains filtered or unexported fields
}

ProjectLinker builds the outbound links (Codeberg/GitHub/Forgejo) shown alongside each project in the showcase. It owns all URL construction, including parsing a configured Forgejo API base into a browsable web URL, so Generator itself doesn't need to know anything about org config shape or forge URL conventions.

func NewProjectLinker added in v0.19.3

func NewProjectLinker(cfg *config.Config) *ProjectLinker

NewProjectLinker creates a ProjectLinker for the given config. A nil config is replaced with a zero-value one so callers (and tests) can construct a linker without a fully populated configuration.

func (l *ProjectLinker) BuildLinks(repoName, repoPath string) (codebergURL, githubURL, forgejoURL string)

BuildLinks returns the Codeberg, GitHub, and Forgejo URLs for repoName, whose local working copy lives at repoPath. Any link is left empty when the corresponding organization isn't configured (or, for Codeberg, when the repository isn't actually set up to sync there).

type ProjectSummary

type ProjectSummary struct {
	Name         string
	Summary      string
	CodebergURL  string
	GitHubURL    string
	ForgejoURL   string
	Metadata     *RepoMetadata
	RankHistory  []RepoRankHistory // Latest 5 weekly rank points, newest first
	Images       []string          // Relative paths to images in showcase directory
	CodeSnippet  string            // Code snippet to show when no images
	CodeLanguage string            // Language and file info for the snippet
}

ProjectSummary holds the summary information for a project

type RankHistoryStore added in v0.13.0

type RankHistoryStore struct {
	Version   int            `json:"version"`
	Snapshots []RankSnapshot `json:"snapshots"`
}

RankHistoryStore stores all ranking snapshots used for weekly history.

type RankSnapshot added in v0.13.0

type RankSnapshot struct {
	Date  string         `json:"date"`
	Ranks map[string]int `json:"ranks"`
}

RankSnapshot stores ranking spots for all repositories on one day.

type RepoMetadata

type RepoMetadata struct {
	Languages        []LanguageStats // Programming languages with usage statistics
	Documentation    []LanguageStats // Documentation/text files with usage statistics
	CommitCount      int
	LinesOfCode      int // Lines of code (excluding documentation)
	LinesOfDocs      int // Lines of documentation
	FirstCommitDate  string
	LastCommitDate   string
	LastActivityDate string // Most recent commit on any local branch (--all); used for activity checks
	License          string
	AvgCommitAge     float64 // Average age of last 42 commits in days (HEAD only; used for score)
	TagCount         int     // Total number of git tags in the repository
	Score            float64 // Project score combining recent activity, reduced LOC weight, tag count, and release status
	LatestTag        string  // Latest version tag (empty if no tags)
	LatestTagDate    string  // Date of the latest tag (empty if no tags)
	HasReleases      bool    // Whether the project has any releases/tags
}

RepoMetadata holds metadata about a repository

type RepoRankHistory added in v0.13.0

type RepoRankHistory struct {
	Spot         int    `json:"spot"`
	Anchor       string `json:"anchor"`
	SnapshotDate string `json:"snapshotDate,omitempty"`
	Arrow        string `json:"arrow"`
}

RepoRankHistory represents one history point for a repository.

type SummaryCache added in v0.19.3

type SummaryCache struct {
	// contains filtered or unexported fields
}

SummaryCache owns persistence for showcase generation: reading and writing the per-repo JSON summary cache, and updating/applying the weekly rank- history snapshots (backed by the lower-level store in rank_history.go). Generator delegates all of this here so its own orchestration loop doesn't need to know about cache file layout or the rank-history file format.

func NewSummaryCache added in v0.19.3

func NewSummaryCache(workDir string) *SummaryCache

NewSummaryCache creates a SummaryCache rooted at workDir (the same directory that holds the synced repositories).

func (*SummaryCache) ApplyRankHistory added in v0.19.3

func (c *SummaryCache) ApplyRankHistory(summaries []ProjectSummary, anchorDate time.Time) error

ApplyRankHistory loads the rank-history store and annotates each summary with its RankHistory field (the last rankHistoryPoints weekly points, relative to anchorDate).

func (*SummaryCache) FilePath added in v0.19.3

func (c *SummaryCache) FilePath(repoName string) string

FilePath returns the cache file path for a given repository. Exposed so callers can include it in log/diagnostic output without needing to know the cache directory layout themselves.

func (*SummaryCache) Load added in v0.19.3

func (c *SummaryCache) Load(repoName string) (*ProjectSummary, error)

Load reads a cached project summary for repoName from disk.

func (*SummaryCache) LoadAll added in v0.19.3

func (c *SummaryCache) LoadAll(repos []string, isExcluded func(string) bool) map[string]ProjectSummary

LoadAll reads cached summaries for every name in repos that isExcluded rejects, keyed by repo name. Repos with no cache entry (or an unreadable one) are silently skipped, matching the historical "best effort" merge behavior used to rebuild the full showcase around a single freshly regenerated project.

func (*SummaryCache) Save added in v0.19.3

func (c *SummaryCache) Save(repoName string, summary *ProjectSummary) error

Save writes summary to the cache, creating the cache directory if needed.

func (*SummaryCache) UpdateRankHistorySnapshot added in v0.19.3

func (c *SummaryCache) UpdateRankHistorySnapshot(anchorDate time.Time, summaries []ProjectSummary) error

UpdateRankHistorySnapshot loads the rank-history store, upserts a snapshot for anchorDate built from summaries' current ordering, and saves the store back to disk. Only full showcase runs should call this: a single-repo update must not perturb the shared weekly ranking snapshot.

Jump to

Keyboard shortcuts

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