- Extend `BoxFile` with thumbnail path/status fields and internal URL - Populate `ThumbnailURL` when a thumbnail path is present during decoration - Add `/box/:id/thumbnails/:file_id` route and handler to serve JPEG thumbnails - Introduce thumbnail status constants to standardize processing state reportingfeat: add thumbnail metadata and download endpoint - Extend `BoxFile` with thumbnail path/status fields and internal URL - Populate `ThumbnailURL` when a thumbnail path is present during decoration - Add `/box/:id/thumbnails/:file_id` route and handler to serve JPEG thumbnails - Introduce thumbnail status constants to standardize processing state reporting
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package server
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/gin-contrib/gzip"
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"warpbox/lib/boxstore"
|
|
"warpbox/lib/helpers"
|
|
"warpbox/lib/routing"
|
|
)
|
|
|
|
func Run(addr string) error {
|
|
router := gin.Default()
|
|
router.LoadHTMLGlob("templates/*.html")
|
|
|
|
routing.Register(router, routing.Handlers{
|
|
Index: handleIndex,
|
|
ShowBox: handleShowBox,
|
|
BoxLogin: handleBoxLogin,
|
|
BoxLoginPost: handleBoxLoginPost,
|
|
BoxStatus: handleBoxStatus,
|
|
DownloadBox: handleDownloadBox,
|
|
DownloadFile: handleDownloadFile,
|
|
DownloadThumbnail: handleDownloadThumbnail,
|
|
CreateBox: handleCreateBox,
|
|
ManifestFileUpload: handleManifestFileUpload,
|
|
FileStatusUpdate: handleFileStatusUpdate,
|
|
DirectBoxUpload: handleDirectBoxUpload,
|
|
LegacyUpload: handleLegacyUpload,
|
|
})
|
|
|
|
compressed := router.Group("/", gzip.Gzip(gzip.DefaultCompression))
|
|
compressed.Static("/static", "./static")
|
|
|
|
batchSize := helpers.EnvInt("WARPBOX_THUMBNAIL_BATCH_SIZE", 10, 1)
|
|
intervalSeconds := helpers.EnvInt("WARPBOX_THUMBNAIL_INTERVAL_SECONDS", 30, 1)
|
|
boxstore.StartThumbnailWorker(batchSize, time.Duration(intervalSeconds)*time.Second)
|
|
|
|
return router.Run(addr)
|
|
}
|