Skip to content
quarry Artifact [e738fe6f24]
Login

Artifact [e738fe6f24]

Artifact e738fe6f24c9936a00a6b7f8d56394a8f086d7851140e81a561f9dff42ca4e70:


// Package legal serves the notices a public forge owes its readers: the
// third-party licence inventory, and the privacy statement describing
// what this instance actually stores.
package legal

import (
	_ "embed"
	"encoding/json"
	"fmt"
)

//go:embed licenses.json
var inventory []byte

// Quarry is this software's own licence, embedded from the repository
// root so the page cannot disagree with the file that governs.
//
//go:embed LICENSE
var Quarry string

// Notice is one dependency's licence.
type Notice struct {
	Module  string `json:"module"`
	Version string `json:"version"`
	License string `json:"license"`
	Text    string `json:"text"`
}

// Notices returns the embedded inventory. Generated by cmd/licensegen
// and checked for freshness by a test, because a licence page that has
// silently stopped listing a dependency is worse than none: it asserts
// completeness it no longer has.
func Notices() ([]Notice, error) {
	var out []Notice
	if err := json.Unmarshal(inventory, &out); err != nil {
		return nil, fmt.Errorf("legal: inventory: %w", err)
	}
	return out, nil
}

//go:embed plex-OFL.txt
var plexOFL string

// Bundled lists what quarry ships that is not a Go module, and so never
// appears in the generated inventory: today, the IBM Plex fonts every
// page is set in, and the full Sans faces the link-preview cards are
// drawn in (internal/ogcard).
func Bundled() []Notice {
	return []Notice{{
		Module:  "IBM Plex Sans and IBM Plex Mono (fonts, Latin-1 subset)",
		Version: "Sans 1.1.0, Mono 2.5.0",
		License: "OFL-1.1",
		Text:    plexOFL,
	}, {
		Module:  "IBM Plex Sans (fonts, Regular, SemiBold and Bold, for link-preview cards)",
		Version: "3.005",
		License: "OFL-1.1",
		Text:    plexOFL,
	}}
}