feat(reader): Add panel detection support for manga and comics
- Add shouldEnablePanelDetection to determine when to enable panel detection - Enable for manga/comics libraries with fixed_layout or comic_archive formats - Fetch library type info using GetLibraryWithType query - Pass panel detection config to reader initialization - Include format_group, manga_type, and reading_direction in reader response
This commit is contained in:
+40
-11
@@ -93,6 +93,15 @@ func (h *ReaderHandler) ShowReader(c *echo.Context) error {
|
||||
return c.JSON(http.StatusForbidden, map[string]string{"error": "Access denied to this library"})
|
||||
}
|
||||
|
||||
// Get library with type information for panel detection decision
|
||||
libraryWithType, err := h.db.GetLibraryWithType(c.Request().Context(), mediaItem.LibraryID)
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusInternalServerError, map[string]string{"error": "Failed to get library info"})
|
||||
}
|
||||
|
||||
// Determine if panel detection should be enabled
|
||||
enablePanelDetection := shouldEnablePanelDetection(libraryWithType.TypeName, mediaItem.FormatGroup)
|
||||
|
||||
// Get reading progress
|
||||
var progress database.ReadingProgress
|
||||
progress, err = h.db.GetReadingProgress(c.Request().Context(), database.GetReadingProgressParams{
|
||||
@@ -111,17 +120,21 @@ func (h *ReaderHandler) ShowReader(c *echo.Context) error {
|
||||
|
||||
// Return JSON response instead of rendering template
|
||||
return c.JSON(http.StatusOK, map[string]interface{}{
|
||||
"media_item_id": mediaItemID,
|
||||
"title": mediaItem.Title,
|
||||
"author": textToString(mediaItem.Author),
|
||||
"cover_image_path": textToString(mediaItem.CoverImagePath),
|
||||
"library_type": mediaItem.FormatGroup,
|
||||
"mime_type": textToString(mediaItem.MimeType),
|
||||
"file_path": mediaItem.FilePath,
|
||||
"total_pages": mediaItem.PageCount,
|
||||
"chapter_count": mediaItem.ChapterCount,
|
||||
"progress": progress,
|
||||
"bookmarks": bookmarks,
|
||||
"media_item_id": mediaItemID,
|
||||
"title": mediaItem.Title,
|
||||
"author": textToString(mediaItem.Author),
|
||||
"cover_image_path": textToString(mediaItem.CoverImagePath),
|
||||
"library_type": mediaItem.FormatGroup,
|
||||
"mime_type": textToString(mediaItem.MimeType),
|
||||
"file_path": mediaItem.FilePath,
|
||||
"total_pages": mediaItem.PageCount,
|
||||
"chapter_count": mediaItem.ChapterCount,
|
||||
"progress": progress,
|
||||
"bookmarks": bookmarks,
|
||||
"enable_panel_detection": enablePanelDetection,
|
||||
"format_group": mediaItem.FormatGroup,
|
||||
"manga_type": mediaItem.MangaType,
|
||||
"reading_direction": mediaItem.ReadingDirection,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -620,3 +633,19 @@ func (h *ReaderHandler) ParseEbook(c *echo.Context) error {
|
||||
"error": "This format should be parsed client-side, not on the server",
|
||||
})
|
||||
}
|
||||
|
||||
// shouldEnablePanelDetection determines if panel detection should be enabled
|
||||
// based on library type and format group
|
||||
func shouldEnablePanelDetection(libraryType string, formatGroup string) bool {
|
||||
panelLibraries := map[string]bool{
|
||||
"manga": true,
|
||||
"comics": true,
|
||||
}
|
||||
|
||||
panelFormats := map[string]bool{
|
||||
"fixed_layout": true,
|
||||
"comic_archive": true,
|
||||
}
|
||||
|
||||
return panelLibraries[libraryType] && panelFormats[formatGroup]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user