apps/cellar/app.go 2.1 K raw
1
package main
2
3
import (
4
	"database/sql"
5
	"embed"
6
	"html/template"
7
	"log/slog"
8
9
	"github.com/stevedylandev/andromeda/pkg/auth"
10
)
11
12
//go:embed templates/*.html static/*
13
var appFS embed.FS
14
15
type App struct {
16
	DB              *sql.DB
17
	Log             *slog.Logger
18
	Templates       map[string]*template.Template
19
	Sessions        *auth.Store
20
	AppPassword     string
21
	CookieSecure    bool
22
	AnthropicAPIKey string
23
	SiteURL         string
24
	SiteTitle       string
25
	SiteDescription string
26
}
27
28
type Wine struct {
29
	ID             int64  `json:"id"`
30
	ShortID        string `json:"short_id"`
31
	Name           string `json:"name"`
32
	Origin         string `json:"origin"`
33
	Grape          string `json:"grape"`
34
	Notes          string `json:"notes"`
35
	HasImage       bool   `json:"has_image"`
36
	ImageMime      string `json:"image_mime,omitempty"`
37
	Sweetness      int    `json:"sweetness"`
38
	Acidity        int    `json:"acidity"`
39
	Tannin         int    `json:"tannin"`
40
	Alcohol        int    `json:"alcohol"`
41
	Body           int    `json:"body"`
42
	Clarity        int    `json:"clarity"`
43
	ColorIntensity int    `json:"color_intensity"`
44
	AromaIntensity int    `json:"aroma_intensity"`
45
	NoseComplexity int    `json:"nose_complexity"`
46
	Background     string `json:"background"`
47
	CreatedAt      string `json:"created_at"`
48
	Wishlist       bool   `json:"wishlist"`
49
}
50
51
type WineInput struct {
52
	Name           string
53
	Origin         string
54
	Grape          string
55
	Notes          string
56
	Background     string
57
	Sweetness      int
58
	Acidity        int
59
	Tannin         int
60
	Alcohol        int
61
	Body           int
62
	Clarity        int
63
	ColorIntensity int
64
	AromaIntensity int
65
	NoseComplexity int
66
}
67
68
type wineWithSVG struct {
69
	Wine        Wine
70
	PentagonSVG template.HTML
71
}
72
73
type indexPageData struct {
74
	Wines []wineWithSVG
75
}
76
77
type loginPageData struct {
78
	Error string
79
	Next  string
80
}
81
82
type wineDetailPageData struct {
83
	Wine        Wine
84
	PentagonSVG template.HTML
85
	BarsSVG     template.HTML
86
}
87
88
type adminPageData struct {
89
	Wines []Wine
90
}
91
92
type wineFormPageData struct {
93
	Wine            *Wine
94
	Error           string
95
	HasAnthropicKey bool
96
}
97
98
type wishlistPageData struct {
99
	Wines   []Wine
100
	IsAdmin bool
101
}