meta

package
v0.0.0-...-88bf645 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SearchFieldName     = SearchField("name")
	SearchFieldFavorite = SearchField("favorite")
	SearchFieldTag      = SearchField("tag")

	SortFieldName       = SortField("name")
	SortFieldCreateTime = SortField("createTime")

	SortOrderAscending  = SortOrder("ascending")
	SortOrderDescending = SortOrder("descending")
)
View Source
const CurrentVersion = 1

CurrentVersion the current version of `Meta` structure.

Variables

View Source
var BaseDirectory string

BaseDirectory the data directory

View Source
var ErrMetaDataNotFound = errors.New(2_000_000, "metadata for '%s' not found.")

Functions

func ListDir

func ListDir(path string) (files []string, err error)

ListDir returns a list of content of a directory.

Types

type Meta

type Meta struct {
	Name        string    `json:"name" db:"name" bson:"name"`
	CreateTime  time.Time `json:"create_time" db:"create_time" bson:"create_time"`
	Favorite    bool      `json:"favorite" db:"favorite" bson:"favorite"`
	FileIndices []int     `json:"file_indices" bson:"file_indices"`
	Thumbnail   []byte    `json:"thumbnail" db:"thumbnail" bson:"thumbnail"`
	IsRead      bool      `json:"is_read" db:"read" bson:"is_read"`
	Tags        []string  `json:"tags" db:"tags" bson:"tags"`

	Version int `json:"version" db:"version" bson:"version"`
}

Meta the metadata for each manga item. Do not change the field type nor names. Add new field when necessary. Also, when update the structure, if the new field is required, increment the CurrentVersion by one and create a migration function.

func Migrate

func Migrate(m Meta) (out Meta, err error)

func NewItem

func NewItem(name string) (i Meta, err error)

func (*Meta) GenerateImageIndices

func (m *Meta) GenerateImageIndices() error

func (*Meta) GenerateThumbnail

func (m *Meta) GenerateThumbnail(fileIndex int) error

func (*Meta) Open

func (m *Meta) Open() (reader io.ReadCloser, err error)

func (*Meta) PopulateTags

func (m *Meta) PopulateTags()

type MigrateFunction

type MigrateFunction func(m Meta) (out Meta, err error)

type Provider

type Provider interface {
	IsItemExist(name string) bool
	Write(i Meta) error
	Delete(i Meta) error
	Read(name string) (i Meta, err error)
	Open(name string) (i Meta, err error)
	ReadAll() (items []Meta, err error)
	Search(criteria []SearchCriteria, sort SortField, order SortOrder, pageSize int, page int) (items []Meta, err error)
	Count(criteria []SearchCriteria) (count int64, err error)
	Close() error
}

Provider meta data provider.

type ProviderFactory

type ProviderFactory func() (p Provider, err error)

type SearchCriteria

type SearchCriteria struct {
	Field SearchField
	Value interface{}
}

type SearchField

type SearchField string

type SortField

type SortField string

type SortOrder

type SortOrder string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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