topics

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 15 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 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

View Source
const Name = "topics"

Name is the canonical plugin slug.

View Source
const NavigatorKey = "_test_topics_navigator"

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

View Source
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 interface {
	Fetch(ctx context.Context, url string) ([]Topic, error)
}

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

func NewHTTPNavigator(client httpDoer, userAgent string) Navigator

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.

func (*Result) IsSkipped

func (r *Result) IsSkipped() bool

IsSkipped lets the classic dispatcher detect the skipped path.

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.

Jump to

Keyboard shortcuts

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