| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "database/sql" |
| 5 | "embed" |
| 6 | "html/template" |
| 7 | "log/slog" |
| 8 | |
| 9 | "github.com/stevedylandev/andromeda/apps/jotts/internal/store" |
| 10 | "github.com/stevedylandev/andromeda/pkg/auth" |
| 11 | ) |
| 12 | |
| 13 | //go:embed templates/*.html static/* |
| 14 | var appFS embed.FS |
| 15 | |
| 16 | type App struct { |
| 17 | DB *sql.DB |
| 18 | Log *slog.Logger |
| 19 | Templates *template.Template |
| 20 | Sessions *auth.Store |
| 21 | Password string |
| 22 | APIKey string |
| 23 | CookieSecure bool |
| 24 | } |
| 25 | |
| 26 | type Note = store.Note |
| 27 | type NoteInput = store.NoteInput |
| 28 | |
| 29 | type indexPageData struct { |
| 30 | Notes []Note |
| 31 | } |
| 32 | |
| 33 | type loginPageData struct { |
| 34 | Error string |
| 35 | } |
| 36 | |
| 37 | type newPageData struct { |
| 38 | Error string |
| 39 | } |
| 40 | |
| 41 | type editPageData struct { |
| 42 | Note Note |
| 43 | Error string |
| 44 | } |
| 45 | |
| 46 | type viewPageData struct { |
| 47 | Note Note |
| 48 | Rendered template.HTML |
| 49 | } |