Documentation
¶
Overview ¶
Package printable is the printable deliverable: a planner, tracker, game or puzzle pack written as one HTML template of fixed-size pages, rendered for every paper size and variant the concept names, checked page by page, and printed to PDFs a buyer prints at home or imports into a note app.
Index ¶
- Constants
- Variables
- func Distribution(r Report, p Printed, day string) (map[string][]byte, []string, []diagnostic.Diagnostic)
- func DownloadPage(r Report, files []deliver.File) []byte
- func Facts(r Report) []string
- func FileNote(r Report, e Edition) string
- func Present(p project.Project) bool
- func Rules() []diagnostic.RuleInfo
- func SizeNames() string
- type Axis
- type Bingo
- type BingoCard
- type Calendar
- type Config
- type Day
- type Edition
- type Image
- type ImagePlan
- type Maze
- type Month
- type Page
- type Part
- type Placement
- type Plan
- type Printed
- type Rendered
- type Report
- type Shot
- type Size
- type Sudoku
- type Summary
- type View
- type Week
- type Weekday
- type WordSearch
Constants ¶
const ( ImageWidth = 1500 ImageHeight = 1125 ImageScale = 2 // PageScale is the density page rasters are rendered at for the images. PageScale = 2 )
Listing images are 3000×2250 pixels (4:3), drawn at 1500×1125 CSS pixels and twice the density. The product sits in the central 900 CSS pixels, so Etsy's square and portrait thumbnail crops keep it whole.
const ( Dir = "deliverables/printable" ConceptFile = Dir + "/concept.md" TemplateName = "printable.html.tmpl" TemplateFile = Dir + "/" + TemplateName StyleName = "printable.css" ListingFile = Dir + "/listing.md" DataDir = "data" )
The fixed layout under deliverables/printable.
const ( RuleConfig = "printable.config" RuleConcept = "printable.concept" RulePages = "printable.pages" RuleBuild = "printable.build" RuleLayout = "printable.layout" RuleDelivery = "printable.delivery" RuleListing = "printable.listing" RuleChannels = "printable.channels" )
Rule IDs.
const EtsyImages = deliver.EtsyImages
EtsyImages is how many listing images Etsy takes.
const Safe = 6.35
Safe is the margin printers may cut or skip, in millimetres: nothing that matters may reach into it.
Variables ¶
var ContentColumns = []string{"Part", "Pages", "Job"}
ContentColumns are the columns of the Contents table.
var Roles = []string{"cover", "guide", "contents", "puzzle", "key", "cut", "certificate", "extra"}
Roles a page can carry in data-role.
var Sections = []concept.SectionSpec{ {Name: "Buyer"}, {Name: "Promise"}, {Name: "Contents"}, {Name: "Editions"}, {Name: "Look"}, {Name: "Changelog", Optional: true}, }
Sections of the printable concept, in order.
var Sizes = map[string]Size{ "letter": {Key: "letter", Label: "US Letter", Width: 215.9, Height: 279.4}, "a4": {Key: "a4", Label: "A4", Width: 210, Height: 297}, "a5": {Key: "a5", Label: "A5", Width: 148, Height: 210}, "half-letter": {Key: "half-letter", Label: "Half Letter", Width: 139.7, Height: 215.9}, "tablet": {Key: "tablet", Label: "Tablet 3:4", Width: 157.5, Height: 210, Digital: true}, }
Sizes are the page sizes lfm renders. tablet is 3:4, the shape of every e-ink tablet and the 13-inch iPad.
Functions ¶
func Distribution ¶
func Distribution(r Report, p Printed, day string) (map[string][]byte, []string, []diagnostic.Diagnostic)
Distribution assembles the shop packages: every PDF and listing image once, a ZIP per paper size only when Etsy's five files would not hold the PDFs, a guide per shop in stores/, and a README.
func DownloadPage ¶
DownloadPage renders the unlisted page buyers land on after paying: one file per edition, or a note while the files wait for their first print.
func Facts ¶
Facts are the product's numbers, taken from the build so the listing never promises more pages, sizes or links than the files hold.
func Rules ¶
func Rules() []diagnostic.RuleInfo
Rules describes every printable rule for the catalog.
Types ¶
type Bingo ¶
type Bingo struct {
Cards []BingoCard
Calls []string // every item, for the caller's list
// FirstWin is the median number of calls until the first card completes a
// line when all cards play, from simulated games.
FirstWin int
}
Bingo is a set of bingo cards with what the host needs to know.
type Calendar ¶
type Calendar struct {
Start time.Weekday // the first day of every week row
Weekdays []Weekday // the week's day names from Start
Months []Month
Weeks []Week // every week touching the range, in order
Days []Day // every day of the range
}
Calendar is a run of months for planner pages, computed rather than typed: month lengths, leap years, weekdays and ISO week numbers come from the standard library. Every month, week and day has an ID to link to.
type Config ¶
type Config struct {
Path string
Offer string
Language string
Shop string // the seller's name on the cover and in the licence
Version string // printed in the guide, e.g. 2027.1
Sell string // page (default), shops or bundle
}
Config is deliverables.printable in lfm.json.
type Day ¶
type Day struct {
ID string // d2027-01-05
Date time.Time
Day int
Month int
Year int
Weekday Weekday
Week string // the ID of its week
InRange bool
}
Day is one date. InRange is false for days a month grid shows from the neighbouring months.
type Edition ¶
type Edition struct {
Key string // a4-color-monday
Label string // A4 · color · monday
Size Size
Options map[string]string // axis name, lowercased -> value
}
Edition is one rendering of the product: a size and one value per axis.
type Maze ¶
type Maze struct {
Width, Height int
Right, Bottom [][]bool
Path [][2]int // the solution from the top-left to the bottom-right cell
}
Maze is a perfect maze: every cell reachable by exactly one path. Walls are kept per cell: right and bottom.
type Month ¶
type Month struct {
ID string // m2027-01
Year, Num int
Name, Short string
Rows []Week // the grid: weeks from the one holding the 1st to the one holding the last day
Days []Day
}
Month is one month with its calendar grid.
type Page ¶
type Page struct {
N int
Part string
Role string
IDs []string
Links []string // internal targets, without "#"
External []string
Images []string // as written in src
}
Page is one rendered page as the checks see it.
type Placement ¶
type Placement struct {
Word string
Row, Col int
DRow, DCol int
Cells [][2]int
ReadsBackwards bool
}
Placement is where a word lies: its first letter and direction.
type Plan ¶
type Plan struct {
Name string
Buyer string
Promise string
Parts []Part
Sizes []string // paper size keys, in order
Axes []Axis // variant axes beside the size, such as Ink: color, ink-saver
Body string // font stacks and accent of the Look
Headings string
Accent string
Lines map[string]int // section name -> line, for findings
}
Plan is the parsed concept.
type Printed ¶
type Printed struct {
PDFs map[string][]byte // edition key -> PDF
Images []Image
Pending bool // some prints wait for the next release
}
Printed is what the release printed for the printable: a PDF per edition and the listing images, in their order.
type Rendered ¶
type Rendered struct {
Edition Edition
Doc []byte
Pages []Page
Links int // internal links, the hyperlink count buyers are told
Stray int // elements outside a page section
}
Rendered is one edition rendered to its print document.
type Report ¶
type Report struct {
Config Config
Plan Plan
Summary Summary
Diagnostics []diagnostic.Diagnostic
Editions []Rendered
Assets map[string][]byte // flat name -> bytes, for printing
Listing deliver.ShopListing
Buildable bool // every edition rendered without errors
}
Report is the checked printable.
func Check ¶
func Check(p project.Project, cfg Config, configured bool, offers map[string]*deliver.Price, site string) Report
Check reads deliverables/printable. configured tells whether lfm.json has deliverables.printable; site is the page URL the download path hangs off; offers are the page's offers by key.
func (Report) Images ¶
Images plans the listing images in the order stores show them: the cover alone, everything included, each part, the sizes.
func (Report) Shots ¶
Shots lists the pages the listing images show: the cover, then the first and second page of every part.
func (Report) SizeCovers ¶
SizeCovers returns the first edition of every paper size, whose cover the sizes image shows as cover-<size>.png.
type Shot ¶
type Shot struct {
Page int // 1-based
Name string // the asset name the image documents use, page-3.png
}
Shot asks for one page raster of the first edition.
type Size ¶
type Size struct {
Key, Label string
Width, Height float64
Digital bool // for note apps on tablets and e-ink, not for paper
}
Size is a page size in millimetres.
type Summary ¶
type Summary struct {
Name string `json:"name,omitempty"`
Concept bool `json:"concept"`
Template bool `json:"template"`
Editions []string `json:"editions,omitempty"`
Pages int `json:"pages"` // per edition, as the first one renders
Links int `json:"links"`
Cut int `json:"cut"` // pages to cut out (data-role="cut")
URL string `json:"url,omitempty"`
Files []string `json:"files,omitempty"`
Pending bool `json:"pending"` // the PDFs print with --release
Listing bool `json:"listing"`
Channels []string `json:"channels,omitempty"`
Images int `json:"images"` // listing images rendered
Layout string `json:"layout,omitempty"`
Sell string `json:"sell"` // page, shops or bundle
}
Summary is what the report and --json show about the printable.
type View ¶
type View struct {
Edition Edition
Name string
Promise string
Parts []Part
Language string
Shop string
Version string
Data map[string]any // data/<name>.json as .Data.<name>
}
View is what printable.html.tmpl sees for one edition.
type Week ¶
type Week struct {
ID string // w2027-05: ISO year and week of the week's Thursday
Number int // ISO week number (KW)
Year int // ISO year
Days []Day
}
Week is seven days from the calendar's start day.
type Weekday ¶
type Weekday struct{ Name, Short string }
Weekday is a day name in the calendar's language.
type WordSearch ¶
type WordSearch struct {
Grid [][]string
Words []string // as listed for the solver, in the order given
Found []Placement
}
WordSearch is a letter grid hiding every word exactly once.
func NewWordSearch ¶
func NewWordSearch(words []string, size int, difficulty, language string, seed int) (WordSearch, error)
NewWordSearch hides words in a size×size grid. Letters are uppercased and, for German, umlauts and ß spelled out as puzzle books do; the filler draws from the language's letters and never spells a listed word a second time.
func (WordSearch) Hit ¶
func (ws WordSearch) Hit(row, col int) bool
Hit reports whether the cell at row and col belongs to a hidden word, for drawing the answer key: {{if $ws.Hit $r $c}}.