commit da9ad43ec7dad3ad4efeed2361068ae491831977
parent 79567f55c1a190f7e4697ed32c5f3ef15f11e8fa
Author: breadcat <breadcat@users.noreply.github.com>
Date: Tue, 30 Jun 2026 14:53:03 +0100
Move all types into respective files
There are a few overlaps but they're mostly correct
Diffstat:
12 files changed, 142 insertions(+), 144 deletions(-)
diff --git a/include-admin-orphans.go b/include-admin-orphans.go
@@ -6,6 +6,11 @@ import (
"os"
)
+type OrphanData struct {
+ Orphans []string // on disk, not in DB
+ ReverseOrphans []string // in DB, not on disk
+}
+
func getOrphanedFiles(uploadDir string) (OrphanData, error) {
diskFiles, err := getFilesOnDisk(uploadDir)
if err != nil {
diff --git a/include-admin-thumbnails.go b/include-admin-thumbnails.go
@@ -12,6 +12,15 @@ import (
"strings"
)
+type VideoFile struct {
+ ID int
+ Filename string
+ Path string
+ HasThumbnail bool
+ ThumbnailPath string
+ EscapedFilename string
+}
+
func generateThumbnailAtTime(videoPath, uploadDir, filename, timestamp string) error {
thumbDir := filepath.Join(uploadDir, "thumbnails")
if err := os.MkdirAll(thumbDir, 0755); err != nil {
diff --git a/include-admin.go b/include-admin.go
@@ -12,6 +12,22 @@ import (
"time"
)
+type AdminPageData struct {
+ Config Config
+ Error string
+ Success string
+ OrphanData OrphanData
+ ActiveTab string
+ MissingThumbnails []VideoFile
+ RecentFiles []File
+}
+
+type SedRule struct {
+ Name string `json:"name"`
+ Description string `json:"description"`
+ Command string `json:"command"`
+}
+
func renderAdminPage(w http.ResponseWriter, r *http.Request, data AdminPageData) {
if data.ActiveTab == "" {
data.ActiveTab = r.FormValue("active_tab")
diff --git a/include-bulk.go b/include-bulk.go
@@ -9,6 +9,26 @@ import (
"strings"
)
+type TagPair struct {
+ Category string
+ Value string
+}
+
+type BulkTagFormData struct {
+ Categories []string
+ RecentFiles []File
+ Error string
+ Success string
+ FormData struct {
+ FileRange string
+ Category string
+ Value string
+ Operation string
+ TagQuery string
+ SelectionMode string
+ }
+}
+
func applyBulkTagOperations(fileIDs []int, category, value, operation string) error {
category = strings.TrimSpace(category)
value = strings.TrimSpace(value)
diff --git a/include-cbz.go b/include-cbz.go
@@ -14,6 +14,11 @@ import (
"strings"
)
+type CBZImage struct {
+ Filename string
+ Index int
+}
+
// generateCBZThumbnail creates a 2x2 collage thumbnail from a CBZ file
func generateCBZThumbnail(cbzPath, uploadDir, filename string) error {
diff --git a/include-db.go b/include-db.go
@@ -7,6 +7,23 @@ import (
_ "github.com/mattn/go-sqlite3"
)
+type Config struct {
+ // Values from CLI arguments
+ DatabasePath string
+ UploadDir string
+ ServerPort string
+ // Values from database
+ GallerySize string
+ ItemsPerPage string
+ TagAliases []TagAliasGroup
+ SedRules []SedRule
+}
+
+type TagAliasGroup struct {
+ Category string `json:"category"`
+ Aliases []string `json:"aliases"`
+}
+
// InitDatabase opens the database connection and creates tables if needed
func InitDatabase(dbPath string) (*sql.DB, error) {
db, err := sql.Open("sqlite3", dbPath+"?_busy_timeout=5000")
diff --git a/include-filters.go b/include-filters.go
@@ -14,6 +14,14 @@ type Breadcrumb struct {
Count int // 0 = not shown
}
+type filter struct {
+ Category string
+ Value string
+ Values []string // Expanded values including aliases
+ IsPreviews bool // New field to indicate preview mode
+ IsProperty bool
+}
+
func untaggedFilesHandler(w http.ResponseWriter, r *http.Request) {
page := pageFromRequest(r)
perPage := perPageFromConfig(50)
diff --git a/include-general.go b/include-general.go
@@ -7,6 +7,40 @@ import (
"strings"
)
+type TagDisplay struct {
+ Value string
+ Count int
+}
+
+type ListData struct {
+ Tagged []File
+ Untagged []File
+ Breadcrumbs []Breadcrumb
+}
+
+type PageData struct {
+ Title string
+ Data interface{}
+ Query string
+ IP string
+ Port string
+ Files []File
+ Tags map[string][]TagDisplay
+ Properties map[string][]PropertyDisplay
+ Breadcrumbs []Breadcrumb
+ Pagination *Pagination
+ GallerySize string
+}
+
+type File struct {
+ ID int
+ Filename string
+ EscapedFilename string
+ Path string
+ Description string
+ Tags map[string][]string
+}
+
func sanitizeFilename(filename string) string {
if filename == "" {
return "file"
diff --git a/include-notes.go b/include-notes.go
@@ -14,6 +14,18 @@ import (
"strings"
)
+type notesAnalysis struct {
+ Stats map[string]int
+ Categories []string
+ LineCount int
+}
+
+type Note struct {
+ Category string
+ Value string
+ Original string // The full line as stored
+}
+
// GetNotes retrieves the notes content from database
func GetNotes(db *sql.DB) (string, error) {
var content string
diff --git a/include-pagination.go b/include-pagination.go
@@ -8,6 +8,17 @@ import (
"strings"
)
+type Pagination struct {
+ CurrentPage int
+ TotalPages int
+ HasPrev bool
+ HasNext bool
+ PrevPage int
+ NextPage int
+ PerPage int
+ PageBaseURL string
+}
+
func pageFromRequest(r *http.Request) int {
if p, err := strconv.Atoi(r.URL.Query().Get("page")); err == nil && p > 0 {
return p
diff --git a/include-properties.go b/include-properties.go
@@ -15,6 +15,11 @@ import (
"strings"
)
+type PropertyDisplay struct {
+ Value string
+ Count int
+}
+
func computeProperties(fileID int64, filePath string) {
ext := strings.ToLower(filepath.Ext(filePath))
diff --git a/include-types.go b/include-types.go
@@ -1,143 +0,0 @@
-package main
-
-type File struct {
- ID int
- Filename string
- EscapedFilename string
- Path string
- Description string
- Tags map[string][]string
-}
-
-type Config struct {
- // Values from CLI arguments
- DatabasePath string
- UploadDir string
- ServerPort string
- // Values from database
- GallerySize string
- ItemsPerPage string
- TagAliases []TagAliasGroup
- SedRules []SedRule
-}
-
-type TagAliasGroup struct {
- Category string `json:"category"`
- Aliases []string `json:"aliases"`
-}
-
-type TagDisplay struct {
- Value string
- Count int
-}
-
-type PropertyDisplay struct {
- Value string
- Count int
-}
-
-type ListData struct {
- Tagged []File
- Untagged []File
- Breadcrumbs []Breadcrumb
-}
-
-type PageData struct {
- Title string
- Data interface{}
- Query string
- IP string
- Port string
- Files []File
- Tags map[string][]TagDisplay
- Properties map[string][]PropertyDisplay
- Breadcrumbs []Breadcrumb
- Pagination *Pagination
- GallerySize string
-}
-
-type Pagination struct {
- CurrentPage int
- TotalPages int
- HasPrev bool
- HasNext bool
- PrevPage int
- NextPage int
- PerPage int
- PageBaseURL string
-}
-
-type VideoFile struct {
- ID int
- Filename string
- Path string
- HasThumbnail bool
- ThumbnailPath string
- EscapedFilename string
-}
-
-type filter struct {
- Category string
- Value string
- Values []string // Expanded values including aliases
- IsPreviews bool // New field to indicate preview mode
- IsProperty bool
-}
-
-type BulkTagFormData struct {
- Categories []string
- RecentFiles []File
- Error string
- Success string
- FormData struct {
- FileRange string
- Category string
- Value string
- Operation string
- TagQuery string
- SelectionMode string
- }
-}
-
-type TagPair struct {
- Category string
- Value string
-}
-
-type OrphanData struct {
- Orphans []string // on disk, not in DB
- ReverseOrphans []string // in DB, not on disk
-}
-
-type Note struct {
- Category string
- Value string
- Original string // The full line as stored
-}
-
-type SedRule struct {
- Name string `json:"name"`
- Description string `json:"description"`
- Command string `json:"command"`
-}
-
-type CBZImage struct {
- Filename string
- Index int
-}
-
-type AdminPageData struct {
- Config Config
- Error string
- Success string
- OrphanData OrphanData
- ActiveTab string
- MissingThumbnails []VideoFile
- RecentFiles []File
-}
-
-type notesAnalysis struct {
- Stats map[string]int
- Categories []string
- LineCount int
-}
-\ No newline at end of file