files

package
v0.0.0-...-3792a54 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package files provides the Files feature with nested folder support.

Package files provides the Files feature with nested folder support.

Index

Constants

This section is empty.

Variables

Functions

func FileTypeIcon

func FileTypeIcon(contentType string) string

FileTypeIcon returns an SVG icon name for a content type.

func FormatFileSize

func FormatFileSize(bytes int64) string

FormatFileSize formats a file size in bytes to a human-readable string.

func IsViewable

func IsViewable(contentType string) bool

IsViewable returns true if the content type can be displayed inline in a browser.

func Routes

func Routes(h *Handler, sessionMgr *auth.SessionManager) http.Handler

Routes returns a chi.Router with file routes mounted.

Types

type BreadcrumbItem struct {
	ID   string
	Name string
	URL  string
}

BreadcrumbItem represents an item in the breadcrumb trail.

type BrowseVM

type BrowseVM struct {
	viewdata.BaseVM
	CurrentFolder   *FolderRow
	CurrentFolderID string
	ParentURL       string // URL to go up one level (empty if at root)
	Breadcrumbs     []BreadcrumbItem
	Folders         []FolderRow
	Files           []FileRow
	IsAdmin         bool
	SortBy          string
	SortOrder       string
	TypeFilter      string
	SearchQuery     string
	TotalFolders    int
	TotalFiles      int
	Success         string
	Error           string
}

BrowseVM is the view model for the browse page.

type FileFormVM

type FileFormVM struct {
	viewdata.BaseVM
	ID          string
	Name        string
	Description string
	Size        string
	ContentType string
	Error       string
}

FileFormVM is the view model for file edit form.

type FileInfoModalVM

type FileInfoModalVM struct {
	ID          string
	Name        string
	Description string
	Size        string
	ContentType string
	TypeIcon    string
	IsViewable  bool
	CreatedAt   string
	UpdatedAt   string
}

FileInfoModalVM is the view model for the file info modal.

type FileManageModalVM

type FileManageModalVM struct {
	ID          string
	Name        string
	Description string
	Size        string
	ContentType string
	TypeIcon    string
	IsViewable  bool
	BackURL     string
	CSRFToken   string
}

FileManageModalVM is the view model for the file manage modal.

type FileRow

type FileRow struct {
	ID          string
	Name        string
	Description string
	Size        string
	SizeBytes   int64
	ContentType string
	TypeIcon    string
	IsViewable  bool
	CreatedAt   string
	UpdatedAt   string
}

FileRow represents a file in the browse view.

type FileUploadVM

type FileUploadVM struct {
	viewdata.BaseVM
	FolderID   string
	FolderName string
	Error      string
	MaxSize    string
}

FileUploadVM is the view model for the file upload form.

type FolderFormVM

type FolderFormVM struct {
	viewdata.BaseVM
	ID          string
	Name        string
	Description string
	ParentID    string
	ParentName  string
	Error       string
}

FolderFormVM is the view model for folder new/edit forms.

type FolderInfoModalVM

type FolderInfoModalVM struct {
	ID          string
	Name        string
	Description string
	ItemCount   int64
	CreatedAt   string
	UpdatedAt   string
}

FolderInfoModalVM is the view model for the folder info modal.

type FolderManageModalVM

type FolderManageModalVM struct {
	ID          string
	Name        string
	Description string
	ItemCount   int64
	BackURL     string
	CSRFToken   string
}

FolderManageModalVM is the view model for the folder manage modal.

type FolderRow

type FolderRow struct {
	ID          string
	Name        string
	Description string
	ItemCount   int64
	CreatedAt   string
	UpdatedAt   string
}

FolderRow represents a folder in the browse view.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler provides file management handlers.

func NewHandler

func NewHandler(
	db *mongo.Database,
	fileStorage storage.Store,
	errLog *errorsfeature.ErrorLogger,
	auditLogger *auditlog.Logger,
	logger *zap.Logger,
) *Handler

NewHandler creates a new files Handler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址