From a51578cbf1c9989fe50de9de2b935e4ed4b7a41f Mon Sep 17 00:00:00 2001 From: arnef Date: Sat, 15 Aug 2026 11:50:27 +0200 Subject: [PATCH] Drop PDF support, EPUB only - internal/library: ListBooks only scans .epub files, dropping the pdf-specific metadata branch (epub metadata reading is now unconditional) - internal/web: uploadSubmit rejects non-.epub uploads with updated error message - views: upload form/file input and empty-library hint now reference only EPUB; templ regenerated - README/copilot-instructions updated to reflect EPUB-only scope Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/copilot-instructions.md | 2 +- README.md | 7 ++----- internal/library/library.go | 20 +++++++++----------- internal/web/handlers.go | 4 ++-- views/pages.templ | 6 +++--- views/pages_templ.go | 4 ++-- 6 files changed, 19 insertions(+), 24 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 28436ce..603f53c 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -1,6 +1,6 @@ # eBook Library (Go + templ) -Minimalistic, no-JS eBook library web app for reading files (EPUB/PDF) on a +Minimalistic, no-JS eBook library web app for reading EPUB files on a Tolino e-reader browser. UI text/comments are in German. ## Build & run diff --git a/README.md b/README.md index 039fcb2..ab13444 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Minimalistische eBook-Bibliothek für den Tolino-Webbrowser. ## Features (MVP) -- Listet EPUB/PDF-Dateien aus `books/` +- Listet EPUB-Dateien aus `books/` - Detailseite pro Buch - Download-Link pro Buch (für Tolino) - Schlichtes, kontrastreiches UI ohne JavaScript-Abhängigkeit @@ -56,10 +56,7 @@ go run ./cmd/server ## Bücher hinzufügen -Lege deine Dateien in den Ordner `books/`: - -- `.epub` (bevorzugt) -- `.pdf` (optional) +Lege deine EPUB-Dateien in den Ordner `books/`. Alternativ können Benutzer mit Upload-Recht Bücher direkt im Browser hochladen. diff --git a/internal/library/library.go b/internal/library/library.go index 454a570..b4956dc 100644 --- a/internal/library/library.go +++ b/internal/library/library.go @@ -44,7 +44,7 @@ func (s *Service) ListBooks() ([]Book, error) { } ext := strings.ToLower(filepath.Ext(e.Name())) - if ext != ".epub" && ext != ".pdf" { + if ext != ".epub" { continue } @@ -55,17 +55,15 @@ func (s *Service) ListBooks() ([]Book, error) { hasCover := false title := fallbackTitle - if ext == ".epub" { - meta, err := readEPUBMetadata(fullPath) - if err == nil { - if strings.TrimSpace(meta.Title) != "" { - title = strings.TrimSpace(meta.Title) - } - if strings.TrimSpace(meta.Author) != "" { - author = strings.TrimSpace(meta.Author) - } - hasCover = meta.HasCover + meta, err := readEPUBMetadata(fullPath) + if err == nil { + if strings.TrimSpace(meta.Title) != "" { + title = strings.TrimSpace(meta.Title) } + if strings.TrimSpace(meta.Author) != "" { + author = strings.TrimSpace(meta.Author) + } + hasCover = meta.HasCover } books = append(books, Book{ diff --git a/internal/web/handlers.go b/internal/web/handlers.go index c3659ce..1baf223 100644 --- a/internal/web/handlers.go +++ b/internal/web/handlers.go @@ -210,8 +210,8 @@ func (h *Handler) uploadSubmit(w http.ResponseWriter, r *http.Request) { defer file.Close() ext := strings.ToLower(filepath.Ext(header.Filename)) - if ext != ".epub" && ext != ".pdf" { - render(w, r.Context(), views.UploadPage("Nur EPUB- und PDF-Dateien erlaubt.")) + if ext != ".epub" { + render(w, r.Context(), views.UploadPage("Nur EPUB-Dateien erlaubt.")) return } diff --git a/views/pages.templ b/views/pages.templ index 0314c24..d358e50 100644 --- a/views/pages.templ +++ b/views/pages.templ @@ -77,8 +77,8 @@ templ UploadPage(errMsg string) {

{ errMsg }

}
- - + +
} @@ -104,7 +104,7 @@ templ IndexPage(books []library.Book, canUpload bool) { } if len(books) == 0 { -

Keine eBooks gefunden. Lege EPUB- oder PDF-Dateien im Ordner books/ ab.

+

Keine eBooks gefunden. Lege EPUB-Dateien im Ordner books/ ab.

} else {