Documentation
¶
Index ¶
- Variables
- type Collection
- func (c *Collection) GetBasePath() string
- func (c *Collection) GetItem(ID string) (Item, bool)
- func (c *Collection) GetItemImages(ID string) (images []string, basepath string, ok bool)
- func (c *Collection) MakeSliceStringIndex()
- func (c *Collection) Marshal() ([]byte, error)
- func (c *Collection) Path() string
- func (c *Collection) Reload() error
- func (c *Collection) WriteItem(ID string, s *storage.Txt) error
- type Item
Constants ¶
This section is empty.
Variables ¶
var FieldsConfFile = "conf.yaml"
FieldsConfFile defines the default values for the storages That file has to be set into the root folder of the collection
var StorageFile = "data.json"
StorageFile is the default name
var SupportedImageExt = []string{".jpg", ".jpeg", ".png"}
SupportedImageExt defines the extensions for the supported Images If a file with such extension is located inside the item folder it will be handled as an image.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct {
// Default fields for all the storages of that collection
Fields []storage.Field
// The data storage
//Storages map[string]*storage.Txt
// Items include the storages
Items map[string]*Item
// All the images from a folder
Images map[string][]string
// Index map for the SliceString values. The logik of the keys is
// map[Field.Key]map[SliceStringValue]
// SliceStrings are used to support taxonomy like for example tags
SliceStringIndex map[string]map[string][]*Item
// contains filtered or unexported fields
}
Collection defines the fields for a storage that fields are used as default for new storages.
func LoadTxt ¶
func LoadTxt(fpath string) (*Collection, error)
LoadTxt the collection from a given path
func NewCollection ¶
func NewCollection(fpath string) *Collection
NewCollection returns an empty collection
func (*Collection) GetBasePath ¶
func (c *Collection) GetBasePath() string
GetBasePath returns the filepath to the collection inside of the filesystem
func (*Collection) GetItem ¶
func (c *Collection) GetItem(ID string) (Item, bool)
GetItem returns a storage from the collection
func (*Collection) GetItemImages ¶
func (c *Collection) GetItemImages(ID string) (images []string, basepath string, ok bool)
GetItemImages returns the image names, the basepath to load the images from the filesystem and a ok value
func (*Collection) MakeSliceStringIndex ¶
func (c *Collection) MakeSliceStringIndex()
MakeSliceStringIndex creates the index for all the SliceString values
func (*Collection) Marshal ¶
func (c *Collection) Marshal() ([]byte, error)
Marshal returns the whole collection as json object
func (*Collection) Path ¶
func (c *Collection) Path() string
Path returns the root path to the collection
type Item ¶
type Item struct {
ID string `json:"-"`
Data *storage.Txt `json:"data"`
Title string `json:"title"`
Images []string `json:"images"`
}
Item is used as API to provide also the images of the collection inside of one object.