Help us shape the future of Go! Take the 2026 Go Developer Survey

deliver

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package deliver holds what every deliverable a page sells shares: the unlisted folder its files are served from, file names, and the download page buyers land on after paying.

Index

Constants

View Source
const (
	// SellPage sells through the page's checkout: after paying, buyers land
	// on an unlisted download page lfm publishes. The default.
	SellPage = "page"
	// SellShops sells through shops that deliver the files themselves; the
	// page's buy buttons link to the shop listings and no download page exists.
	SellShops = "shops"
	// SellBundle sells a deliverable only inside the bundle.
	SellBundle = "bundle"
)

How a deliverable or a bundle is sold, as its "sell" in lfm.json says.

View Source
const (
	MaxTitle       = 140
	MaxTags        = 13
	MaxTag         = 20
	MinDescription = 200
)

Store limits, from the strictest channel (Etsy).

View Source
const (
	EtsyFiles     = 5
	EtsyFileBytes = 20 << 20
	EtsyImages    = 20
)

Shop limits that shape a package.

View Source
const MinPathLength = 16

MinPathLength is the shortest unlisted download folder name: the path is the only lock on the files.

Variables

View Source
var LinkText = regexp.MustCompile(`(?i)\bhttps?://|\bwww\.[a-z0-9-]+\.|[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}`)

LinkText matches a web address or email address in store copy, which stores refuse in descriptions.

View Source
var ShopListingSections = []concept.SectionSpec{
	{Name: "Title"}, {Name: "Description"}, {Name: "Tags"}, {Name: "Price"}, {Name: "AI"},
}

ShopListingSections are the sections of a shop listing.md, in order.

Functions

func CSSValue

func CSSValue(s string) string

CSSValue strips what could end a CSS declaration from a configured value.

func CopyLink(url, kind string) string

CopyLink turns the address of a shared Google Docs, Slides or Sheets master of kind (document, presentation, spreadsheets) into the link that makes the buyer's own copy; "" for any other address.

func JPEGStamp

func JPEGStamp(jpg []byte) string

JPEGStamp returns the key StampJPEG recorded, or "".

func NewPath

func NewPath() string

NewPath returns a fresh random download path.

func Page

func Page(d Download) []byte

Page renders the download page: marked noindex and sending no referrer, so the address does not travel.

func PlainText

func PlainText(md string) string

PlainText turns listing Markdown into the plain text Etsy shows.

func RawSection

func RawSection(text string, d concept.Document, name string) string

RawSection returns the source lines of a section as written, blank lines included, so Markdown paragraphs survive.

func Sell

func Sell(mode string) string

Sell returns the sell mode with its default.

func Shop

func Shop(raw string) string

Shop names the shop a checkout URL belongs to, or "" for any other host, such as a Stripe Payment Link.

func Shops

func Shops() []string

Shops returns the keys of the digital shops lfm prepares guides for.

func Slug

func Slug(title, fallback string) string

Slug is a file name for a title: lowercase ASCII, accents folded and the letters that do not decompose spelled out, so "Größer leben" is groesser-leben. fallback names a title without letters.

func StampJPEG

func StampJPEG(jpg []byte, key string) []byte

StampJPEG records key in a JPEG comment right after the start marker, the way a stamped PDF records its inputs, so a later compile can reuse the image while its inputs are unchanged.

func ValidPath

func ValidPath(p string) bool

ValidPath reports whether p can serve as the unlisted download folder.

Types

type Download

type Download struct {
	Language, Title, Subtitle, Accent string
	Heading                           string // the page title, e.g. "Download: <title>"
	Links                             []Link // shown before the files
	Files                             []File
	Thanks                            string // above the files
	Pending                           string // instead of the files while they are not ready
	Keep                              string // below the files
}

Download is the unlisted page buyers land on after paying.

type File

type File struct {
	Name, Label, Note string
	Size              int
}

File is one download on the page.

type Issue

type Issue struct{ Message, Hint string }

Issue is a reason a shop would refuse what was built.

func Package

func Package(pkg ShopPackage, files map[string][]byte, day string) ([]string, []Issue)

Package writes the shop guides and the README of pkg into files, which already holds the downloads and images/, adding a ZIP per group when Etsy's five files do not hold the downloads. It returns the shops prepared and what a shop would refuse.

type Link struct{ Label, URL, Note string }

Link is an address on the download page, such as a Google Sheets copy link.

type Price

type Price struct {
	Text     string // as written, e.g. "7.99 EUR"
	Amount   *big.Rat
	Currency string
}

Price is one list price, e.g. of an edition or a product.

func ParsePrice

func ParsePrice(s string) (Price, bool)

ParsePrice reads a price written as 7.99 EUR or 7,99 EUR.

type ShopListing

type ShopListing struct {
	Present     bool
	Title       string
	Description string // Markdown
	Tags        []string
	Price       *Price
	AIText      string
	AIImages    string
	AITools     string
	AIStatement string
}

ShopListing is a parsed listing.md of a product sold in digital shops: a printable or a bundle.

func CheckShopListing

func CheckShopListing(text string, offer *Price, add func(line int, message, hint string)) ShopListing

CheckShopListing parses a shop listing.md and reports where a shop would refuse it or where its price differs from the page's offer.

func (ShopListing) AIUsed

func (l ShopListing) AIUsed() bool

AIUsed reports whether the product declares any AI use.

type ShopPackage

type ShopPackage struct {
	Name     string
	Source   string // the folder it is built from, e.g. deliverables/printable
	Listing  ShopListing
	Files    []string            // every download, in order; their bytes are in the files map
	Groups   map[string][]string // when Etsy's five files do not hold Files: ZIP name -> files in it
	Images   []string            // listing images under images/, in order
	Facts    []string            // what the files hold, from the build
	Decide   []string            // the README's decisions for the owner
	Pending  bool                // prints wait for the next release
	External []string            // outside links inside the files
}

ShopPackage is a product sold in digital shops (Etsy, Gumroad, Payhip, Ko-fi): its files, listing images and texts.

type Wording

type Wording struct{ Heading, Thanks, Pending, Keep string }

Wording is what a download page says around its files, per language; English is the fallback.

func Words

func Words(language string) Wording

Words returns the download page wording for a language.

Jump to

Keyboard shortcuts

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