Drop PDF support, EPUB only
Docker Image bauen und veröffentlichen / docker (push) Successful in 2m38s
Docker Image bauen und veröffentlichen / docker (push) Successful in 2m38s
- 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>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# eBook Library (Go + templ)
|
# 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.
|
Tolino e-reader browser. UI text/comments are in German.
|
||||||
|
|
||||||
## Build & run
|
## Build & run
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Minimalistische eBook-Bibliothek für den Tolino-Webbrowser.
|
|||||||
|
|
||||||
## Features (MVP)
|
## Features (MVP)
|
||||||
|
|
||||||
- Listet EPUB/PDF-Dateien aus `books/`
|
- Listet EPUB-Dateien aus `books/`
|
||||||
- Detailseite pro Buch
|
- Detailseite pro Buch
|
||||||
- Download-Link pro Buch (für Tolino)
|
- Download-Link pro Buch (für Tolino)
|
||||||
- Schlichtes, kontrastreiches UI ohne JavaScript-Abhängigkeit
|
- Schlichtes, kontrastreiches UI ohne JavaScript-Abhängigkeit
|
||||||
@@ -56,10 +56,7 @@ go run ./cmd/server
|
|||||||
|
|
||||||
## Bücher hinzufügen
|
## Bücher hinzufügen
|
||||||
|
|
||||||
Lege deine Dateien in den Ordner `books/`:
|
Lege deine EPUB-Dateien in den Ordner `books/`.
|
||||||
|
|
||||||
- `.epub` (bevorzugt)
|
|
||||||
- `.pdf` (optional)
|
|
||||||
|
|
||||||
Alternativ können Benutzer mit Upload-Recht Bücher direkt im Browser hochladen.
|
Alternativ können Benutzer mit Upload-Recht Bücher direkt im Browser hochladen.
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func (s *Service) ListBooks() ([]Book, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext := strings.ToLower(filepath.Ext(e.Name()))
|
ext := strings.ToLower(filepath.Ext(e.Name()))
|
||||||
if ext != ".epub" && ext != ".pdf" {
|
if ext != ".epub" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,17 +55,15 @@ func (s *Service) ListBooks() ([]Book, error) {
|
|||||||
hasCover := false
|
hasCover := false
|
||||||
title := fallbackTitle
|
title := fallbackTitle
|
||||||
|
|
||||||
if ext == ".epub" {
|
meta, err := readEPUBMetadata(fullPath)
|
||||||
meta, err := readEPUBMetadata(fullPath)
|
if err == nil {
|
||||||
if err == nil {
|
if strings.TrimSpace(meta.Title) != "" {
|
||||||
if strings.TrimSpace(meta.Title) != "" {
|
title = strings.TrimSpace(meta.Title)
|
||||||
title = strings.TrimSpace(meta.Title)
|
|
||||||
}
|
|
||||||
if strings.TrimSpace(meta.Author) != "" {
|
|
||||||
author = strings.TrimSpace(meta.Author)
|
|
||||||
}
|
|
||||||
hasCover = meta.HasCover
|
|
||||||
}
|
}
|
||||||
|
if strings.TrimSpace(meta.Author) != "" {
|
||||||
|
author = strings.TrimSpace(meta.Author)
|
||||||
|
}
|
||||||
|
hasCover = meta.HasCover
|
||||||
}
|
}
|
||||||
|
|
||||||
books = append(books, Book{
|
books = append(books, Book{
|
||||||
|
|||||||
@@ -210,8 +210,8 @@ func (h *Handler) uploadSubmit(w http.ResponseWriter, r *http.Request) {
|
|||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
ext := strings.ToLower(filepath.Ext(header.Filename))
|
ext := strings.ToLower(filepath.Ext(header.Filename))
|
||||||
if ext != ".epub" && ext != ".pdf" {
|
if ext != ".epub" {
|
||||||
render(w, r.Context(), views.UploadPage("Nur EPUB- und PDF-Dateien erlaubt."))
|
render(w, r.Context(), views.UploadPage("Nur EPUB-Dateien erlaubt."))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -77,8 +77,8 @@ templ UploadPage(errMsg string) {
|
|||||||
<p class="error">{ errMsg }</p>
|
<p class="error">{ errMsg }</p>
|
||||||
}
|
}
|
||||||
<form method="post" action="/upload" enctype="multipart/form-data" class="upload-form">
|
<form method="post" action="/upload" enctype="multipart/form-data" class="upload-form">
|
||||||
<label for="book">EPUB oder PDF auswählen</label>
|
<label for="book">EPUB auswählen</label>
|
||||||
<input id="book" type="file" name="book" accept=".epub,.pdf" required />
|
<input id="book" type="file" name="book" accept=".epub" required />
|
||||||
<button type="submit" class="btn">Hochladen</button>
|
<button type="submit" class="btn">Hochladen</button>
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ templ IndexPage(books []library.Book, canUpload bool) {
|
|||||||
}
|
}
|
||||||
</section>
|
</section>
|
||||||
if len(books) == 0 {
|
if len(books) == 0 {
|
||||||
<p>Keine eBooks gefunden. Lege EPUB- oder PDF-Dateien im Ordner <code>books/</code> ab.</p>
|
<p>Keine eBooks gefunden. Lege EPUB-Dateien im Ordner <code>books/</code> ab.</p>
|
||||||
} else {
|
} else {
|
||||||
<ul class="book-list">
|
<ul class="book-list">
|
||||||
for _, b := range books {
|
for _, b := range books {
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ func UploadPage(errMsg string) templ.Component {
|
|||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, " <form method=\"post\" action=\"/upload\" enctype=\"multipart/form-data\" class=\"upload-form\"><label for=\"book\">EPUB oder PDF auswählen</label> <input id=\"book\" type=\"file\" name=\"book\" accept=\".epub,.pdf\" required> <button type=\"submit\" class=\"btn\">Hochladen</button></form>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, " <form method=\"post\" action=\"/upload\" enctype=\"multipart/form-data\" class=\"upload-form\"><label for=\"book\">EPUB auswählen</label> <input id=\"book\" type=\"file\" name=\"book\" accept=\".epub\" required> <button type=\"submit\" class=\"btn\">Hochladen</button></form>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -435,7 +435,7 @@ func IndexPage(books []library.Book, canUpload bool) templ.Component {
|
|||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
if len(books) == 0 {
|
if len(books) == 0 {
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "<p>Keine eBooks gefunden. Lege EPUB- oder PDF-Dateien im Ordner <code>books/</code> ab.</p>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "<p>Keine eBooks gefunden. Lege EPUB-Dateien im Ordner <code>books/</code> ab.</p>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user