asset

package
v0.0.0-...-3a06bfb Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FmtFields = []*formatter.Field[StockAsset]{
	{
		Name:   "sha",
		Header: "SHA",
		Show:   true,
		Getter: func(a StockAsset) any {
			return a.Model().SHA
		},
	},

	{
		Name:   "name",
		Header: "NAME",
		Show:   true,
		Getter: func(a StockAsset) any {
			return a.BaseName()
		},
	},
	{
		Name:   "url",
		Header: "URL",
		Show:   true,
		Getter: func(a StockAsset) any {
			url := a.Model().Url
			if url == "" {
				return "<none>"
			}
			return url
		},
	},
	{
		Name:   "fhash",
		Header: "FHASH",
		Show:   true,
		Getter: func(a StockAsset) any {
			return a.Model().FHash
		},
	},
	{
		Name:   "created",
		Header: "CREATED",
		Show:   true,
		Getter: func(a StockAsset) any {
			return a.Model().Created
		},
	},
	{
		Name:   "size",
		Header: "SIZE",
		Show:   true,
		Getter: func(a StockAsset) any {
			s, err := a.Content().Size()
			if err != nil {
				return content.IllegalSize
			}
			return s
		},
	},
	{
		Name:   "tags",
		Header: "TAGS",
		Show:   true,
		Getter: func(sa StockAsset) any {
			tags := sa.Model().Tags
			return strings.Join(tags, ", ")
		},
	},
}

Functions

This section is empty.

Types

type Applier

type Applier interface {
	Apply(app core.App, asset Asset) (Update, error)
}

type Asset

type Asset interface {
	Content() content.Content
	BaseName() string
	// contains filtered or unexported methods
}

func ApplyUpdate

func ApplyUpdate(ia Asset, transform Transform, up Update) (Asset, error)

func Tag

func Tag(ia Asset, spec tag.Spec) Asset

type ExternalLoader

type ExternalLoader func() (Asset, error)

func LoadFile

func LoadFile(filepath string, pos pos.P) ExternalLoader

func (ExternalLoader) Do

func (l ExternalLoader) Do(db.Context) (Asset, error)

type Loader

type Loader interface {
	Do(db.Context) (Asset, error)
}

type StockAsset

type StockAsset interface {
	Asset
	Model() *db.AssetModel
	CompareCreated(other StockAsset) int
}

func SaveAll

func SaveAll(ctx db.Context, app core.App, assets []Asset) ([]StockAsset, error)

type StockLoader

type StockLoader func(db.Context) (StockAsset, error)

func FromDBModel

func FromDBModel(app core.App, model *db.AssetModel, upstream Asset) StockLoader

func FromQ

func FromQ(app core.App, query assetq.Query) StockLoader

func (StockLoader) Do

func (l StockLoader) Do(c db.Context) (Asset, error)

type Transform

type Transform interface {
	Model() db.StepListTpl
}

type Update

type Update interface {
	// contains filtered or unexported methods
}

func MergeUpdates

func MergeUpdates(updateList ...Update) Update

func UpdateContent

func UpdateContent(content content.Content) Update

func UpdateExt

func UpdateExt(ext []byte) Update

func UpdateFileExtension

func UpdateFileExtension(ext string) Update

func UpdateUrl

func UpdateUrl(url string) Update

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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