- tablos.templ: TabloDetailPage gains files+activeTab params, 3-tab nav with hx-push-url
- tablos.templ: TabloOverviewTabFragment + TasksTabFragment (wraps KanbanBoard) added
- files.templ: FilesTabFragment, FileUploadForm (hx-encoding=multipart/form-data),
FileListRow, FileListEmpty, FileRowGone, UploadErrorFragment
- files_helpers.go: formatBytes() converts int64 bytes to human-readable string
- router.go: fileDeps FilesDeps param added; TabloTasksTabHandler + file routes wired
- handlers_tablos.go: both TabloDetailPage call sites updated (nil, 'overview')
- main.go: S3_ENDPOINT/S3_BUCKET/S3_REGION env vars read; files.NewStore constructed;
fileDeps wired; nil filesStore allowed when S3 env unset (503 from handlers)
- All test routers updated to pass FilesDeps{} in new param position
23 lines
502 B
Go
23 lines
502 B
Go
package templates
|
|
|
|
import "fmt"
|
|
|
|
// formatBytes converts a byte count to a human-readable string.
|
|
// Examples: 512 → "512 B", 1536 → "1.5 KB", 3670016 → "3.5 MB".
|
|
func formatBytes(n int64) string {
|
|
const (
|
|
kb = 1024
|
|
mb = 1024 * kb
|
|
gb = 1024 * mb
|
|
)
|
|
switch {
|
|
case n < kb:
|
|
return fmt.Sprintf("%d B", n)
|
|
case n < mb:
|
|
return fmt.Sprintf("%.1f KB", float64(n)/kb)
|
|
case n < gb:
|
|
return fmt.Sprintf("%.1f MB", float64(n)/mb)
|
|
default:
|
|
return fmt.Sprintf("%.1f GB", float64(n)/gb)
|
|
}
|
|
}
|