apps/easel/app.go 1.1 K raw
1
package main
2
3
import (
4
	"database/sql"
5
	"embed"
6
	"html/template"
7
	"log/slog"
8
	"net/http"
9
	"time"
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
	HTTP            *http.Client
20
	TZ              *time.Location
21
	TZName          string
22
	Classifications []string
23
	ExcludeTerms    []string
24
	BackfillDays    int
25
	MaxDedupRetries int
26
	BaseURL         string
27
}
28
29
type artworkView struct {
30
	Date             string
31
	Title            string
32
	ArtistDisplay    string
33
	DateDisplay      string
34
	MediumDisplay    string
35
	Dimensions       string
36
	PlaceOfOrigin    string
37
	CreditLine       string
38
	Description      string
39
	DescriptionHTML  template.HTML
40
	ShortDescription string
41
	ImageURL         string
42
	SourceURL        string
43
}
44
45
type archiveRow struct {
46
	Date   string
47
	Title  string
48
	Artist string
49
}
50
51
type indexPageData struct {
52
	TodayDate string
53
	Artwork   *artworkView
54
}
55
56
type dayPageData struct {
57
	Date    string
58
	Artwork artworkView
59
}
60
61
type archivePageData struct {
62
	Archive []archiveRow
63
}
64
65
type errorPageData struct {
66
	Title   string
67
	Message string
68
}