Documentation
¶
Overview ¶
Package topics owns the M4 "topics" plugin. It fetches the user's starred-topics page via plain HTTPS + goquery — the GitHub API does not expose the dataset, but `https://github.com/stars/{user}/topics` is fully server-rendered HTML (no React hydration, no include-fragment), so a single GET is enough. No headless browser required.
The Navigator interface is preserved as a test seam: production code uses httpNavigator; non-network tests substitute a fake. The upstream chromedp-backed implementation is gone.
Index ¶
Constants ¶
const Name = "topics"
Name is the canonical plugin slug.
NavigatorKey is the inputs map slot tests use to inject a fake Navigator. Production code never sets this — the plugin falls back to pc.Render.
Variables ¶
var Plugin plugins.Plugin = &topicsPlugin{}
Plugin is the singleton registered with the global plugin registry.
Functions ¶
func Partial ¶
Partial renders the classic SVG fragment for the topics plugin. Returns "" when the result is missing or skipped.
Output structure (mirrors upstream org_repo/source/templates/classic/partials/topics.ejs):
<section data-section="topics">
<section>
<h2 class="field"><svg pin/>Starred topics</h2>
<div class="row">
<section>
<div class="topics fill-width">
[labels mode]: <div class="label" title="desc">name</div>...
[icons mode]: <img src="icon" width="24" height="24" alt="name" title="name"/>...
</div>
</section>
</div>
</section>
</section>
Settings: mjun0812 uses plugin_topics: yes, plugin_topics_limit: 15, plugin_topics_mode: starred (default) and a variant with mode: icons.
Types ¶
type Navigator ¶
type Navigator interface {
}
Navigator abstracts the HTTP fetch + HTML parse so non-network tests can inject a fake. Production code uses httpNavigator from http_navigator.go.
func NewHTTPNavigator ¶ added in v1.1.0
NewHTTPNavigator returns the production Navigator. When client is nil, http.DefaultClient is used. userAgent is sent on every request — GitHub serves a degraded HTML page to requests with an empty UA, so we always send a real-looking one.
type Result ¶
type Result struct {
Skipped bool `json:"skipped,omitempty"`
SkippedReason string `json:"-"`
List []Topic `json:"list"`
Mode string `json:"mode"`
Limit int `json:"limit"`
Sort string `json:"sort"`
}
Result is the JSON payload published under data.Plugins["topics"]. Field set mirrors data-model E-023.
type Topic ¶
type Topic struct {
Name string `json:"name"`
Description string `json:"description"`
Icon string `json:"icon"`
URL string `json:"url"`
// StarredAt is opaque metadata used only for sorting when the user
// requested sort="starred-at". Not part of the public JSON shape;
// upstream does not expose it.
StarredAt string `json:"-"`
}
Topic mirrors one entry in the starred-topics list.