Documentation
¶
Overview ¶
Package mapgen aggregates submitted result files into the data of the public map and writes the static site (no server, no external resources).
Index ¶
- Constants
- Variables
- func Build(cat *catalog.Catalog, opt Options) (*Data, []Problem, error)
- func CheckFile(root, path string) (*submit.Submission, error)
- func FromIssue(body []byte, resultsDir string) (string, error)
- func I18nFrom(keys map[string]map[string]string) map[string]map[string]string
- func Load(root string) ([]Entry, []Problem, error)
- type CategoryInfo
- type Cell
- type Data
- type Day
- type Entry
- type Event
- type Options
- type Problem
- type RegionInfo
- type Row
- type TargetInfo
Constants ¶
const TimelineDays = 120
TimelineDays bounds the timeline length.
Variables ¶
var ErrNoJSON = errors.New("no JSON submission found in the issue body")
ErrNoJSON is returned when an issue body contains no submission.
Functions ¶
func CheckFile ¶
func CheckFile(root, path string) (*submit.Submission, error)
CheckFile validates a submission file and its location (<root>/AS<asn>/<date>-<hex6>.json, matching the content).
func FromIssue ¶
FromIssue extracts, validates and stores a submission pasted into an issue. It returns the written path relative to resultsDir's parent.
Types ¶
type CategoryInfo ¶
CategoryInfo names a category.
type Cell ¶
type Cell struct {
Status model.Status `json:"s"`
Kind model.Kind `json:"k"`
Conf model.Confidence `json:"c,omitempty"`
Date string `json:"d"`
N int `json:"n"`
}
Cell is the latest state of one target on one network.
type Data ¶
type Data struct {
Generated string `json:"generated"`
Updated string `json:"updated,omitempty"`
Sample bool `json:"sample,omitempty"`
Submissions int `json:"submissions"`
Categories []CategoryInfo `json:"categories"`
Targets []TargetInfo `json:"targets"`
Rows []Row `json:"rows"`
Regions []RegionInfo `json:"regions"`
Cells map[string]map[string]Cell `json:"cells"`
Timeline map[string][]Day `json:"timeline"`
Events map[string][]Event `json:"events"`
I18n map[string]map[string]string `json:"i18n"`
Repo string `json:"repo"`
}
Data is the JSON consumed by the map front-end.
type Entry ¶
type Entry struct {
Path string
Sub submit.Submission
}
Entry is one valid submission together with its repository path.
type Event ¶
type Event struct {
Date string `json:"d"`
Row string `json:"row"`
From model.Status `json:"from"`
To model.Status `json:"to"`
Kind model.Kind `json:"k"`
}
Event is a status change of a target on a network.
type Options ¶
type Options struct {
Results string // directory with submissions
Out string // output directory
Assets string // optional directory with social-preview.png
Sample bool // add clearly-labelled sample data (never for deployment)
Now time.Time
}
Options configure a site build.
type Problem ¶
Problem describes a rejected file.
func ValidatePaths ¶
ValidatePaths checks specific files (e.g. those changed in a pull request).
type RegionInfo ¶
RegionInfo names a region.
type Row ¶
type Row struct {
Key string `json:"key"`
ASN int `json:"asn"`
ISP string `json:"isp"`
Region string `json:"region,omitempty"`
Conn string `json:"conn"`
Reports int `json:"reports"`
Last string `json:"last"`
}
Row is one network (ASN × region × connection type).
type TargetInfo ¶
type TargetInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Category string `json:"category"`
}
TargetInfo names a target.