data

package
v0.7.3-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2016 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package data contains the structure of all the data and is used to encode/decode JSON or XML format

Index

Constants

This section is empty.

Variables

View Source
var ErrFileNotFound = errors.New("File not found.")

ErrFileNotFound is used when try to load a file and that file does not exist

Functions

func LoadType

func LoadType(i Identifier, root string) error

LoadType loads the data from the data folder for a given type That type needs to implement the identifier interface.

func MakePath

func MakePath(i Identifier, root string) string

MakePath generates the path to a identifier, when a root folder is given.

func SaveType

func SaveType(i Identifier, root string) error

SaveType stores the data from a type into the data folder. The type needs to implement the Identifier interface.

Types

type Area

type Area struct {
	ID      string   `xml:"id,attr" json:"areaID"`
	Rect    Fabric   `xml:"rect" json:"rect"`
	Shape   string   `xml:"shape" json:"Shape"`
	Coords  string   `xml:"coords" json:"Coords"`
	Persons []string `xml:"persons" json:"Persons"`
	Text    string   `xml:"text" json:"Text"`
	Links   []Link   `xml:"links" json:"Links"`
}

Area defines parts of the picture

func (Area) ImageRect

func (a Area) ImageRect(scale float32) image.Rectangle

ImageRect returns an image.Rectangle for the area. This method is used to cut the area out of the image. The input scale factor scales the size of the source pic to the canvas size, where the area was defined

type Fabric

type Fabric struct {
	Type             string  `xml:"type" json:"type"`
	Left             float32 `xml:"left" json:"left"`
	Top              float32 `xml:"top" json:"top"`
	Width            int     `xml:"width" json:"width"`
	Height           int     `xml:"height" json:"height"`
	Fill             string  `xml:"fill" json:"fill"`
	Opacity          float32 `xml:"opacity" json:"opacity"`
	ScaleX           float32 `xml:"scaleX" json:"scaleX"`
	ScaleY           float32 `xml:"scaleY" json:"scaleY"`
	HasRotatingPoint bool    `xml:"hasRotatingPoint" json:"hasRotatingPoint"`
}

Fabric defines rects of the fabricjs library

type Ident

type Ident struct {
	Value string `xml:"value" json:"Value"`
	Type  string `xml:"type,attr" json:"Type"`
}

Ident is a unique identification

type Identifier

type Identifier interface {
	Identify() string
	TypeName() string
}

Identifier is used to get the ID of a type. That ID is used to generate the filepath for saving the data.

type Link struct {
	URL   string `xml:"url" json:"Url"`
	Text  string `xml:"text" json:"Text"`
	Title string `xml:"title" json:"Title"`
}

Link for a part of the blog

type Lister

type Lister interface {
	List() (*[]Picture, error)
}

Lister interface is used to get a list of all pictures inside a folder

type Person

type Person struct {
	ID          int               `xml:"id,attr" json:"intID"`
	GND         string            `xml:"gnd" json:"GND"`
	ExtID       string            `xml:"gnd" json:"personID"`
	Idents      []Ident           `xml:"idents" json:"idents"`
	MasterID    int               `xml:"master,attr" json:"masterID"`
	Type        string            `xml:"type,attr" json:"Type"`
	NameFamily  string            `xml:"name>family" json:"FamilyName"`
	NameGiven   string            `xml:"name>given" json:"GivenName"`
	FullName    string            `xml:"fullName" json:"FullName"`
	YearBirth   int               `xml:"yearBirth" json:"YearBirth"`
	YearDeath   int               `xml:"yearDeath" json:"YearDeath"`
	CityBirth   string            `xml:"cityBirth" json:"CityBirth"`
	CityDeath   string            `xml:"cityDeath" json:"CityDeath"`
	Text        string            `xml:"text" json:"Text"`
	ProfilePics map[string]Source `xml:"profilePics" json:"ProfilePics"`
	Pictures    []string          `xml:"pictures" json:"Pictures"`
	Links       []Link            `xml:"links" json:"Links"`
}

Person represents the entities of a person

func (*Person) GetID

func (p *Person) GetID() string

GetID returns the ID of the person

func (*Person) Identify

func (p *Person) Identify() string

Identify implements the Identifier interface for loading and saving

func (*Person) TypeName

func (p *Person) TypeName() string

TypeName implements the Identifier inteface for loading and saving

type PersonDBer

type PersonDBer interface {
	AddPerson(*Person)
	GetPerson(string) (*Person, bool)
	GetAll() map[string]Person
	SavePerson(p *Person) error
}

PersonDBer is the interface for a simple PersonDB

type Picture

type Picture struct {
	ID           string    `xml:"id,attr" json:"ID"`
	SrcPath      string    `xml:"-" json:"-"`
	File         string    `xml:"-" json:"-"`
	Title        string    `xml:"title" json:"Title"`
	Topic        string    `xml:"topic" json:"Topic"`
	Text         string    `xml:"text" json:"Text"`
	CanvasWidth  int       `xml:"canvasWidth" json:"canvasWidth"`
	CanvasHeight int       `xml:"canvasHeight" json:"canvasHeight"`
	Areas        []Area    `xml:"areas" json:"Areas"`
	Captured     int       `xml:"captured" json:"Captured"` //Year, when picture was digitalized
	Place        string    `xml:"place" json:"Place"`       //Place where the picture was issued
	YearIssued   string    `xml:"yearIssued" json:"YearIssued"`
	Persons      []string  `xml:"persons" json:"Persons"`
	Tags         []string  `xml:"tags" json:"Tags"`
	Links        []Link    `xml:"links" json:"Links"`
	Status       string    `xml:"status" json:"Status"`
	BlogDate     time.Time `xml:"-" json:"BlogDate"`
	PublishDate  time.Time `xml:"-" json:"PublishDate"`
}

Picture stores all the entities for the histblogger

func LoadPictures

func LoadPictures(root string) []Picture

LoadPictures loads the pictures from data folder. For loading the pictures the data.LoadType function is used.

func (*Picture) Identify

func (p *Picture) Identify() string

Identify implements the Identifier interface for loading and saving

func (*Picture) TypeName

func (p *Picture) TypeName() string

TypeName implements the Identifier inteface for loading and saving

type Source

type Source struct {
	Value       string `xml:"value" json:"Value"`
	Text        string `xml:"text" json:"Text"`
	Title       string `xml:"title" json:"Title"`
	Attribution string `xml:"attribution" json:"Attribution"`
}

Source defines a source with copyright and source information

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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