collection

package
v0.0.0-...-ba60b02 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2017 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

View Source
var StorageFile = "data.json"

StorageFile is the default name

View Source
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

func (*Collection) Reload

func (c *Collection) Reload() error

Reload the collection

func (*Collection) WriteItem

func (c *Collection) WriteItem(ID string, s *storage.Txt) error

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.

func NewItem

func NewItem(s *storage.Txt, id string) *Item

func (*Item) Marshal

func (i *Item) Marshal() ([]byte, error)

Marshal is used inside the httphandler to marshal the item

func (*Item) SetTitle

func (i *Item) SetTitle()

Jump to

Keyboard shortcuts

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