Phase 0 of the reader redesign: - Panels no longer render under the top/bottom bars: sidebars get measured insets (same resize/safe-area mechanism as the viewport); panel max-height now derives from the bounded sidebar instead of a 100vh guess; right-side border targets the actual sidebar. - Bookmarks work end-to-end for the first time: REST CRUD under /api/media-items/:id/bookmarks (create/delete route through AnnotationService for dedup/LWW/tombstones), fix UpdateMediaBookmark referencing nonexistent updated_at column, frontend posts to the real API with per-format position (CFI vs page), live list with jump + delete instead of SSR-only snapshot. - Fix chapter matching in progress saves: boundaries were compared by a nonexistent tocItem property, so chapter was never persisted. - Remove dead UI: Navigator panel stub, empty dictionary popup shell, unwired Chrome Behavior select; purge 160 stale build artifacts. - Reader chrome now follows the user's app theme instead of hardcoded theme-tokyo-night.
72 lines
3.5 KiB
Go
72 lines
3.5 KiB
Go
package router
|
|
|
|
import (
|
|
"bookhoard/internal/handlers"
|
|
)
|
|
|
|
func registerMediaRoutes(cfg *Config) {
|
|
e := cfg.Echo
|
|
|
|
// JWT middleware for protected routes
|
|
jwtMiddleware := createJWTMiddleware(cfg)
|
|
protected := e.Group("/api", jwtMiddleware)
|
|
admin := protected.Group("", handlers.AdminMiddleware)
|
|
|
|
// Media item routes (all authenticated users)
|
|
protected.GET("/media-items", cfg.MediaHandler.ListMediaItems)
|
|
protected.GET("/media-items/:id", cfg.MediaHandler.GetMediaItem)
|
|
|
|
// Media rating routes (all authenticated users)
|
|
protected.POST("/media-items/:id/rating", cfg.MediaHandler.CreateMediaRating)
|
|
protected.GET("/media-items/:id/rating", cfg.MediaHandler.GetMediaRating)
|
|
protected.PUT("/media-items/:id/rating", cfg.MediaHandler.UpdateMediaRating)
|
|
protected.DELETE("/media-items/:id/rating", cfg.MediaHandler.DeleteMediaRating)
|
|
|
|
// Progress routes (all authenticated users)
|
|
protected.GET("/media-items/:id/progress", cfg.MediaHandler.GetMediaReadingProgress)
|
|
protected.PUT("/media-items/:id/progress", cfg.MediaHandler.UpdateMediaReadingProgress)
|
|
protected.DELETE("/media-items/:id/progress", cfg.MediaHandler.DeleteMediaReadingProgress)
|
|
|
|
// Notes routes (all authenticated users)
|
|
protected.GET("/media-items/:id/notes", cfg.MediaHandler.GetMediaNotes)
|
|
protected.POST("/media-items/:id/notes", cfg.MediaHandler.CreateMediaNote)
|
|
protected.GET("/media-items/:id/notes/:noteId", cfg.MediaHandler.GetMediaNote)
|
|
protected.PUT("/media-items/:id/notes/:noteId", cfg.MediaHandler.UpdateMediaNote)
|
|
protected.DELETE("/media-items/:id/notes/:noteId", cfg.MediaHandler.DeleteMediaNote)
|
|
|
|
// Highlights routes (all authenticated users)
|
|
protected.GET("/media-items/:id/highlights", cfg.MediaHandler.GetMediaHighlights)
|
|
protected.POST("/media-items/:id/highlights", cfg.MediaHandler.CreateMediaHighlight)
|
|
protected.GET("/media-items/:id/highlights/:highlightId", cfg.MediaHandler.GetMediaHighlight)
|
|
protected.PUT("/media-items/:id/highlights/:highlightId", cfg.MediaHandler.UpdateMediaHighlight)
|
|
protected.DELETE("/media-items/:id/highlights/:highlightId", cfg.MediaHandler.DeleteMediaHighlight)
|
|
|
|
// Bookmark routes (all authenticated users)
|
|
protected.GET("/media-items/:id/bookmarks", cfg.MediaHandler.GetMediaBookmarks)
|
|
protected.POST("/media-items/:id/bookmarks", cfg.MediaHandler.CreateMediaBookmark)
|
|
protected.PUT("/media-items/:id/bookmarks/:bookmarkId", cfg.MediaHandler.UpdateMediaBookmark)
|
|
protected.DELETE("/media-items/:id/bookmarks/:bookmarkId", cfg.MediaHandler.DeleteMediaBookmark)
|
|
|
|
// Admin-only media routes
|
|
admin.POST("/media-items", cfg.MediaHandler.CreateMediaItem)
|
|
admin.PUT("/media-items/:id", cfg.MediaHandler.UpdateMediaItem)
|
|
admin.DELETE("/media-items/:id", cfg.MediaHandler.DeleteMediaItem)
|
|
|
|
// Shelf management (protected)
|
|
protected.POST("/devices/:id/shelves", cfg.MediaHandler.AddToShelf)
|
|
protected.GET("/devices/:id/shelves", cfg.MediaHandler.GetShelf)
|
|
protected.DELETE("/devices/:id/shelves", cfg.MediaHandler.RemoveFromShelf)
|
|
protected.DELETE("/devices/:id/shelves/clear", cfg.MediaHandler.ClearShelf)
|
|
|
|
// Bulk media operations (protected)
|
|
mediaItems := protected.Group("/media-items")
|
|
mediaItems.POST("/bulk-delete", cfg.MediaHandler.HandleBulkDelete)
|
|
mediaItems.POST("/bulk-update", cfg.MediaHandler.HandleBulkUpdate)
|
|
|
|
// File serving - authenticated (registered on Echo to avoid /api prefix)
|
|
// Create a group with JWT middleware for routes outside /api
|
|
authenticated := e.Group("", createJWTMiddleware(cfg))
|
|
// Note: Must be registered LAST as it's a wildcard route
|
|
authenticated.GET("/uploads/library-:id/*", cfg.MediaHandler.ServeFile)
|
|
}
|