recipe

package
v0.0.0-...-6d1ceae Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SearchTypeInclude = "include"
	SearchTypeExclude = "exclude"
)
View Source
const (
	NutritionPrecisionExact        = "exact"
	NutritionPrecisionApprox       = "approx"
	NutritionPrecisionProfessional = "professional" // calculated by a professional
	NutritionPrecisionAuto         = "auto"         // calculated by the system

	LangEn = "en"
	LangRu = "ru"
)
View Source
const (
	TagSeparator = ":"
)

Variables

This section is empty.

Functions

func GetTagGroups

func GetTagGroups(tags []*Tag) []string

func Schema

func Schema() *jsonschema.Schema

func SeedToYAML

func SeedToYAML(path string) error

SeedToYAML saves each seed recipe to a file (using Recipe.Slug as file name)

func Slugify

func Slugify(name string) string

Types

type Equipment

type Equipment struct {
	ID   uuid.UUID `json:"-" yaml:"-"`
	Name string    `json:"name"`
	Slug string    `json:"-" yaml:"-"`
}

func EquipmentFromJSONString

func EquipmentFromJSONString(data string) []*Equipment

func (*Equipment) Slugify

func (e *Equipment) Slugify()

type Filter

type Filter struct {
	NameContains  string
	Locale        string
	Equipment     []string
	EquipmentNot  []string
	Tag           []string
	TagNot        []string
	Ingredient    []string
	IngredientNot []string
	Limit         int
	Offset        int
	NewFirst      bool

	WithEdges bool
}

func (Filter) Clear

func (f Filter) Clear() Filter

func (Filter) HasEquipmentRules

func (f Filter) HasEquipmentRules() bool

func (Filter) HasIngredientRules

func (f Filter) HasIngredientRules() bool

func (Filter) HasTagRules

func (f Filter) HasTagRules() bool

func (Filter) IsEmpty

func (f Filter) IsEmpty() bool

func (Filter) WithAddEquipment

func (f Filter) WithAddEquipment(equipment string, searchType string) Filter

func (Filter) WithAddIngredient

func (f Filter) WithAddIngredient(ingredient string, searchType string) Filter

func (Filter) WithAddTag

func (f Filter) WithAddTag(tag string, searchType string) Filter

func (Filter) WithName

func (f Filter) WithName(name string) Filter

func (Filter) WithNewFirst

func (f Filter) WithNewFirst(b bool) Filter

func (Filter) WithRemoveEquipment

func (f Filter) WithRemoveEquipment(equipment string, searchType string) Filter

func (Filter) WithRemoveIngredient

func (f Filter) WithRemoveIngredient(ingredient string, searchType string) Filter

func (Filter) WithRemoveTag

func (f Filter) WithRemoveTag(tag string, searchType string) Filter

type Idea

type Idea struct {
	ID   uuid.UUID `json:"-" yaml:"-"`
	Text string    `json:"text"`
}

func IdeasFromJSONString

func IdeasFromJSONString(data string) []*Idea

type Ingredient

type Ingredient struct {
	ID       uuid.UUID `json:"-" yaml:"-"`
	Product  *Product  `json:"product"`
	Quantity string    `json:"quantity"`
	Unit     string    `json:"unit"`
	Optional bool      `json:"optional,omitempty" yaml:",omitempty"`
}

func IngredientsFromJSONString

func IngredientsFromJSONString(data string) []*Ingredient

func (*Ingredient) Slugify

func (i *Ingredient) Slugify()

type Instruction

type Instruction struct {
	ID   uuid.UUID `json:"-" yaml:"-"`
	Text string    `json:"text"`
}

func InstructionsFromJSONString

func InstructionsFromJSONString(data string) []Instruction

type Nutrition

type Nutrition struct {
	Calories  int      `json:"calories"`
	Fat       int      `json:"fat"`
	Carbs     int      `json:"carbs"`
	Protein   int      `json:"protein"`
	Precision string   `json:"precision"`
	Benefits  []string `json:"benefits"`
}

func NutritionFromJSONString

func NutritionFromJSONString(data string) *Nutrition

func (*Nutrition) IsEmpty

func (n *Nutrition) IsEmpty() bool

func (*Nutrition) JSONString

func (n *Nutrition) JSONString() string

type Product

type Product struct {
	ID   uuid.UUID `json:"-" yaml:"-"`
	Name string    `json:"name"`
	Slug string    `json:"-" yaml:"-"`
}

type Recipe

type Recipe struct {
	ID               uuid.UUID         `json:"-" yaml:"-"`
	Slug             string            `json:"-" yaml:"-"`
	Name             string            `json:"name"`
	Description      string            `json:"description"` // Short description for catalog
	Text             string            `json:"text"`        // Long description for recipe page
	Tags             []*Tag            `json:"tags"`
	Ingredients      []*Ingredient     `json:"ingredients"`
	Equipment        []*Equipment      `json:"equipment"`
	Instructions     []Instruction     `json:"instructions"` // Steps to prepare the recipe
	Ideas            []*Idea           `json:"ideas"`        // Ideas for variations
	Time             time.Duration     `json:"time"`
	Servings         int               `json:"servings"`
	Nutrition        *Nutrition        `json:"nutrition"`
	Meta             map[string]string `json:"meta"`
	Lang             string            `json:"lang"`
	Rating           float32           `json:"rating"`
	Sources          []*Source         `json:"sources"`
	ModerationStatus string            `json:"moderation_status" yaml:"-"`
	Published        bool              `json:"published"`
}

func LoadFromYAML

func LoadFromYAML(path string) ([]*Recipe, error)

func LoadRecipeFromString

func LoadRecipeFromString(data string) (*Recipe, error)

func PumpkinBuns

func PumpkinBuns() *Recipe

func PumpkinSoup

func PumpkinSoup() *Recipe

func SeedData

func SeedData() []*Recipe

func (*Recipe) EquipmentJSONString

func (r *Recipe) EquipmentJSONString() string

func (*Recipe) IdeasJSONString

func (r *Recipe) IdeasJSONString() string

func (*Recipe) IngredientsJSONString

func (r *Recipe) IngredientsJSONString() string

func (*Recipe) InstructionsJSONString

func (r *Recipe) InstructionsJSONString() string

func (*Recipe) JSONString

func (r *Recipe) JSONString() string
func (r *Recipe) Link(baseURL string) string

func (*Recipe) MetaJSONString

func (r *Recipe) MetaJSONString() string

func (*Recipe) PostProcess

func (r *Recipe) PostProcess()

func (*Recipe) ShareText

func (r *Recipe) ShareText() string

func (*Recipe) SourcesJSONString

func (r *Recipe) SourcesJSONString() string

func (*Recipe) TagsJSONString

func (r *Recipe) TagsJSONString() string

type Source

type Source struct {
	ID          uuid.UUID `json:"-" yaml:"-"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	URL         string    `json:"url"`
}

func SourcesFromJSONString

func SourcesFromJSONString(data string) []*Source

type Tag

type Tag struct {
	ID    uuid.UUID `json:"-" yaml:"-"`
	Name  string    `json:"name"`
	Group string    `json:"group"`
	Slug  string    `json:"-" yaml:"-"`
}

func FilterTagsByGroup

func FilterTagsByGroup(tags []*Tag, group string) []*Tag

func TagFromTitle

func TagFromTitle(tag string) *Tag

func TagsFromJSONString

func TagsFromJSONString(data string) []*Tag

func (*Tag) Slugify

func (t *Tag) Slugify()

func (*Tag) Title

func (t *Tag) Title() string

Jump to

Keyboard shortcuts

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