Documentation
¶
Overview ¶
Package media defines the files the media library holds.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrConflict = errors.New("media: conflicting update")
ErrConflict reports that the media item changed after the update was prepared.
var ErrInvalidAuthor = errors.New("media: invalid author")
ErrInvalidAuthor reports that a media item carries no author.
var ErrInvalidFile = errors.New("media: invalid file")
ErrInvalidFile reports that a media item names no stored file.
var ErrInvalidMime = errors.New("media: invalid mime type")
ErrInvalidMime reports that a media item carries no content type.
var ErrInvalidOrder = errors.New("media: invalid order")
ErrInvalidOrder reports that a sort direction is not one the library sorts in.
var ErrInvalidOrderBy = errors.New("media: invalid orderby")
ErrInvalidOrderBy reports that a sort column is not one the library sorts by.
var ErrInvalidType = errors.New("media: invalid type")
ErrInvalidType reports that a media kind is not one the library tells apart.
var ErrNotFound = errors.New("media: not found")
ErrNotFound reports that no media item exists for the requested ID.
Functions ¶
This section is empty.
Types ¶
type Filter ¶
type Filter struct {
Type Type
Mimes []string
Authors []uuid.UUID
ExcludeAuthors []uuid.UUID
Before *time.Time
After *time.Time
ModifiedBefore *time.Time
ModifiedAfter *time.Time
Search string
OrderBy OrderBy
Order Order
Page int
PerPage int
}
Filter narrows a media listing by type, content type prefix, author, date and search, sorted as it names.
type Listed ¶ added in v0.19.0
Listed is a media item as a listing carries it, beside its author's name.
type Media ¶
type Media struct {
ID int64
Type Type
File string
Title string
AltText string
Caption string
Description string
MimeType string
Width int
Height int
Filesize int64
Sizes Sizes
AuthorID uuid.UUID
CreatedAt time.Time
UpdatedAt time.Time
}
Media is a stored upload with the descriptions the editor reads.
type Order ¶ added in v0.19.0
type Order string
Order names a sort direction.
The directions a media listing can be sorted in.
func ParseOrder ¶ added in v0.19.0
ParseOrder returns the direction named by raw, or ErrInvalidOrder.
type OrderBy ¶ added in v0.19.0
type OrderBy string
OrderBy names a column a media listing can be sorted by.
const ( OrderByDate OrderBy = "date" OrderByModified OrderBy = "modified" OrderByTitle OrderBy = "title" OrderByAuthor OrderBy = "author" )
The columns a media listing can be sorted by.
func ParseOrderBy ¶ added in v0.19.0
ParseOrderBy returns the column named by raw, or ErrInvalidOrderBy.
type Store ¶
type Store interface {
Create(ctx context.Context, m Media) (Media, error)
ByID(ctx context.Context, id int64) (Media, error)
ByIDs(ctx context.Context, ids []int64) ([]Media, error)
List(ctx context.Context, f Filter) ([]Listed, int, error)
Update(ctx context.Context, m Media, expectedUpdatedAt time.Time) (Media, error)
Delete(ctx context.Context, id int64) (Media, error)
}
Store persists the media library.
type SubSize ¶ added in v0.19.0
type SubSize struct {
File string `json:"file"`
Width int `json:"width"`
Height int `json:"height"`
MimeType string `json:"mime_type"`
Filesize int64 `json:"filesize"`
}
SubSize is one stored copy of an upload at an image size, with its file, measurements and byte count.