78 lines
2.2 KiB
Go
78 lines
2.2 KiB
Go
// Package seeddata holds the development fixture. It is a JSON file rather
|
|
// than Go literals so the shape stays diffable and a designer can edit copy
|
|
// without touching code.
|
|
//
|
|
// Backer email addresses deliberately end in .invalid: no real person's data
|
|
// should ever end up here.
|
|
package seeddata
|
|
|
|
import (
|
|
_ "embed"
|
|
"encoding/json"
|
|
)
|
|
|
|
//go:embed seed.json
|
|
var raw []byte
|
|
|
|
type Owner struct {
|
|
Slug string `json:"slug"`
|
|
Name string `json:"name"`
|
|
Initials string `json:"initials"`
|
|
Location string `json:"location"`
|
|
Blurb string `json:"blurb"`
|
|
// Optional. Left out of the fixture because there is nowhere to host the
|
|
// files yet; an organisation without one shows its initials.
|
|
AvatarURL string `json:"avatarUrl,omitempty"`
|
|
}
|
|
|
|
type Story struct {
|
|
Heading string `json:"heading"`
|
|
Body []string `json:"body"`
|
|
}
|
|
|
|
type Tier struct {
|
|
Type string `json:"type"`
|
|
Price int `json:"price"`
|
|
ListPrice *int `json:"listPrice"`
|
|
Title string `json:"title"`
|
|
Includes []string `json:"includes"`
|
|
InventoryLimit *int `json:"inventoryLimit"`
|
|
EstimatedDelivery string `json:"estimatedDelivery"`
|
|
Featured bool `json:"featured"`
|
|
// Backers is how many pledges the seed creates at this tier's price. The
|
|
// raised amount is never written anywhere — it falls out of those rows.
|
|
Backers int `json:"backers"`
|
|
}
|
|
|
|
type Update struct {
|
|
Title string `json:"title"`
|
|
Body string `json:"body"`
|
|
}
|
|
|
|
type Comment struct {
|
|
AuthorName string `json:"authorName"`
|
|
Body string `json:"body"`
|
|
}
|
|
|
|
type Campaign struct {
|
|
Slug string `json:"slug"`
|
|
Title string `json:"title"`
|
|
Category string `json:"category"`
|
|
Summary string `json:"summary"`
|
|
Art string `json:"art"`
|
|
GoalAmount int `json:"goalAmount"`
|
|
EndsAt string `json:"endsAt"`
|
|
Status string `json:"status"`
|
|
Owner Owner `json:"owner"`
|
|
Story []Story `json:"story"`
|
|
Tiers []Tier `json:"tiers"`
|
|
Updates []Update `json:"updates"`
|
|
Comments []Comment `json:"comments"`
|
|
}
|
|
|
|
func Load() ([]Campaign, error) {
|
|
var out []Campaign
|
|
err := json.Unmarshal(raw, &out)
|
|
return out, err
|
|
}
|