apps/blobs/app.go 1.4 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
	S3             *S3Client
21
	Password       string
22
	CookieSecure   bool
23
	MaxUploadBytes int64
24
}
25
26
type loginPageData struct {
27
	Error string
28
}
29
30
type bucketsPageData struct {
31
	Buckets []BucketInfo
32
	Error   string
33
}
34
35
type crumb struct {
36
	Label string
37
	Href  string
38
}
39
40
type folderItem struct {
41
	Name string
42
	Href string
43
}
44
45
type fileItem struct {
46
	Name         string
47
	Size         int64
48
	SizeHuman    string
49
	LastModified string
50
	DetailHref   string
51
	PreviewSrc   string
52
	IsImage      bool
53
}
54
55
type browsePageData struct {
56
	Bucket   string
57
	Prefix   string
58
	ParentHref string
59
	Crumbs   []crumb
60
	Folders  []folderItem
61
	Files    []fileItem
62
	Error    string
63
	Success  string
64
	MaxUploadMB int64
65
}
66
67
type detailPageData struct {
68
	Bucket       string
69
	Key          string
70
	Name         string
71
	ContentType  string
72
	Size         int64
73
	SizeHuman    string
74
	LastModified string
75
	ETag         string
76
	IsImage      bool
77
	PreviewSrc   string
78
	PresignedURL string
79
	PublicURL    string
80
	HasPublic    bool
81
	ParentHref   string
82
	ParentPrefix string
83
	Crumbs       []crumb
84
	Error        string
85
}