cmo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package cmo is the library behind the cmo command line. It scrapes the Canadian Mathematical Society's CMO/CJMO archive page, extracts all PDF links, and returns typed Edition records.

Index

Constants

View Source
const BaseURL = "https://" + Host

BaseURL is the root every request is built from.

View Source
const DefaultUserAgent = "Mozilla/5.0 (compatible; cmo-cli/dev; +https://github.com/tamnd/cmo-cli)"

DefaultUserAgent identifies the client to the CMS server.

View Source
const Host = "cms.math.ca"

Host is the CMS website this client reads.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	HTTP      *http.Client
	UserAgent string
	// Rate is the minimum gap between requests. Zero means no pacing.
	Rate    time.Duration
	Retries int
	// contains filtered or unexported fields
}

Client talks to the CMS website over HTTP.

func NewClient

func NewClient() *Client

NewClient returns a Client with sensible defaults.

func (*Client) Editions

func (c *Client) Editions(ctx context.Context, limit int) ([]Edition, error)

Editions fetches the CMO/CJMO archive page and returns all editions sorted newest-first. If limit > 0 the returned slice is capped at limit.

func (*Client) Get

func (c *Client) Get(ctx context.Context, url string) ([]byte, error)

Get fetches url and returns the response body. It paces and retries according to the client's settings.

type Domain

type Domain struct{}

Domain is the cmo driver for the any-cli/kit framework.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify turns a URL or bare path into (type, id). For cmo we have a single resource type: "edition" identified by "YEAR:COMPETITION".

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate is the inverse of Classify: the https URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type Edition

type Edition struct {
	Rank         int    `json:"rank"          csv:"rank"          tsv:"rank"`
	Year         int    `json:"year"          csv:"year"          tsv:"year"`
	Competition  string `json:"competition"   csv:"competition"   tsv:"competition"`
	ProblemsURL  string `json:"problems_url"  csv:"problems_url"  tsv:"problems_url"`
	SolutionsURL string `json:"solutions_url" csv:"solutions_url" tsv:"solutions_url"`
}

Edition is one year/competition entry in the CMO or CJMO archive.

Jump to

Keyboard shortcuts

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