Documentation
¶
Index ¶
- func RegisterCallbacks(db *gorm.DB)
- func RegisterMediaLibraryHandler(name string, handler MediaLibraryHandler)
- type AssetManager
- type Base
- func (Base) ConfigureQorMetaBeforeInitialize(meta resource.Metaor)
- func (b *Base) Cropped(values ...bool) (result bool)
- func (b Base) Ext() string
- func (b *Base) GetCropOption(name string) *image.Rectangle
- func (b Base) GetFileHeader() FileHeader
- func (b Base) GetFileName() string
- func (b Base) GetSizes() map[string]Size
- func (b Base) GetURL(option *Option, scope *gorm.Scope, field *gorm.Field, templater URLTemplater) string
- func (b Base) GetURLTemplate(option *Option) (path string)
- func (b Base) IsImage() bool
- func (b *Base) NeedCrop() bool
- func (b Base) Retrieve(url string) (*os.File, error)
- func (b *Base) Scan(data interface{}) (err error)
- func (b Base) String() string
- func (b Base) URL(styles ...string) string
- func (b Base) Value() (driver.Value, error)
- type CropOption
- type FileHeader
- type FileSystem
- type MediaLibrary
- type MediaLibraryHandler
- type Option
- type Size
- type URLTemplater
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterCallbacks ¶
RegisterCallbacks register callback into GORM DB
func RegisterMediaLibraryHandler ¶
func RegisterMediaLibraryHandler(name string, handler MediaLibraryHandler)
RegisterMediaLibraryHandler register Media library handler
Types ¶
type AssetManager ¶
type AssetManager struct {
gorm.Model
File FileSystem `media_library:"URL:/system/assets/{{primary_key}}/{{filename_with_hash}}"`
}
AssetManager defined a asset manager that could be used to manage assets in qor admin
func (*AssetManager) ConfigureQorResource ¶
func (*AssetManager) ConfigureQorResource(res resource.Resourcer)
ConfigureQorResource configure qor locale for Qor Admin
type Base ¶
type Base struct {
FileName string
Url string
CropOptions map[string]*CropOption `json:",omitempty"`
Delete bool `json:",omitempty"`
Crop bool `json:"-"`
FileHeader FileHeader `json:"-"`
Reader io.Reader `json:"-"`
// contains filtered or unexported fields
}
Base defined a base struct for storages
func (Base) ConfigureQorMetaBeforeInitialize ¶
ConfigureQorMetaBeforeInitialize configure this field for Qor Admin
func (*Base) GetCropOption ¶
GetCropOption get crop options
func (Base) GetFileHeader ¶
func (b Base) GetFileHeader() FileHeader
GetFileHeader get file's header, this value only exists when saving files
func (Base) GetURL ¶
func (b Base) GetURL(option *Option, scope *gorm.Scope, field *gorm.Field, templater URLTemplater) string
GetURL get default URL for a model based on its options
func (Base) GetURLTemplate ¶
GetURLTemplate get url template
type CropOption ¶
type CropOption struct {
X, Y, Width, Height int
}
CropOption includes crop options
type FileHeader ¶
FileHeader is an interface, for matched values, when call its `Open` method will return `multipart.File`
type FileSystem ¶
type FileSystem struct {
Base
}
FileSystem defined a media library storage using file system
func (FileSystem) GetFullPath ¶
func (f FileSystem) GetFullPath(url string, option *Option) (path string, err error)
GetFullPath return full file path from a relative file path
type MediaLibrary ¶
type MediaLibrary interface {
Scan(value interface{}) error
Value() (driver.Value, error)
GetURLTemplate(*Option) string
GetURL(option *Option, scope *gorm.Scope, field *gorm.Field, templater URLTemplater) string
GetFileHeader() FileHeader
GetFileName() string
GetSizes() map[string]Size
NeedCrop() bool
Cropped(values ...bool) bool
GetCropOption(name string) *image.Rectangle
Store(url string, option *Option, reader io.Reader) error
Retrieve(url string) (*os.File, error)
IsImage() bool
URL(style ...string) string
Ext() string
String() string
}
MediaLibrary is an interface including methods that needs for a media library storage
type MediaLibraryHandler ¶
type MediaLibraryHandler interface {
CouldHandle(media MediaLibrary) bool
Handle(media MediaLibrary, file multipart.File, option *Option) error
}
MediaLibraryHandler media library handler interface, defined which files could be handled, and the handler
type Size ¶
Size is a struct, used for `GetSizes` method, it will return a slice of Size, media library will crop images automatically based on it
type URLTemplater ¶
URLTemplater is a interface to return url template