album

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 4, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const MetaDataFileName = "metadata.json"

MetaDataFileName is te name of the file that will contain the folder/album metadata.

Variables

View Source
var DefaultThumbSize = ThumbSize{
	Width:  320,
	Height: 213,
}

DefaultThumbSize is the size we swill use for thumbnails if none is defined the number is super retro and it was picked arbitrarily beacause it's the only number I can think out of the top of my head on a plane.

Functions

This section is empty.

Types

type PictureGroup

type PictureGroup struct {
	// Parent is the blatant irony spitting in my face reminding us that, even if you don't think
	// you will ever use a linked list in real life scenarios, life is long.
	// it also contains a reference to the containing folder of this one, if any (notice that we
	// will only go as deep as the path passed to initialize the outmost album)
	Parent *PictureGroup `json:"-"`
	// Path is the absolute disk path of this folder/album
	Path string `json:"-"`
	// FolderName holds the name for this group's folder.
	FolderName string `json:"-"`
	// Title is a title representing this picture group/folder/album.
	Title string `json:"title"`
	// Description is a description of this folder.
	Description string `json:"description"`
	// Pictures holds a map of references to all the pictures in this album.
	Pictures map[string]*SinglePicture `json:"pictures"`
	// Order contains a list of strings ordered in the way the items in this album
	// are expected to be accessed.
	Order []string `json:"order"`

	// Recursion
	// SubGroups are folders/albums found inside this one.
	SubGroups map[string]*PictureGroup `json:"-"`
	// SubGroupOrder is the ordering of display for the subgroups, we store this.
	SubGroupOrder []string `json:"sub-group-order"`

	// AllowedThumbSizes holds all the allowed thumbnail sizes for this and children groups
	// it will override parent sizes and be inherited by children that do not specify them, if
	// none is defined it will default to one sane size.
	AllowedThumbSizes []*ThumbSize `json:"allowed-thumb-sizes"`
	// Logger holds a logger
	Logger *log.Logger `json:"-"`
}

PictureGroup holds information about a group of pictures from an album

func NewPictureGroup

func NewPictureGroup(logger *log.Logger, path string, allowedThumbsSizes []*ThumbSize, update, recursive bool, parent *PictureGroup) (*PictureGroup, error)

NewPictureGroup returns a PictureGroup reference with loaded metadata which might be optionally up to date. (this implies conciliation of filesystem with metadata files.)

func (*PictureGroup) AddImage

func (pg *PictureGroup) AddImage(path string) error

AddImage constructs the SingleImage for this path and then adds it to the corresponding references of this group.

func (*PictureGroup) AddSubGroup

func (pg *PictureGroup) AddSubGroup(fullPath, folderName string, recursive bool) error

AddSubGroup construct a SubGroup that lives under this one

func (*PictureGroup) ConstructMetadata

func (pg *PictureGroup) ConstructMetadata(recursive bool) error

ConstructMetadata will fill the in-memory metadata of this folder/album from the filesystem

func (*PictureGroup) GetImage

func (pg *PictureGroup) GetImage(name string) *SinglePicture

GetImage returns the SinglePicture for the <name> file if it exists.

func (*PictureGroup) HasImage

func (pg *PictureGroup) HasImage(name string) bool

HasImage returns true if the passed name matches an image in this folder.

func (*PictureGroup) HasSubAlbum

func (pg *PictureGroup) HasSubAlbum(name string) bool

HasSubAlbum returns true if the passed in name matches a subFolder.

func (*PictureGroup) NonDestructiveUpdateMetadata

func (pg *PictureGroup) NonDestructiveUpdateMetadata(recursive bool) error

NonDestructiveUpdateMetadata will see to concile all the metadata in the file, if existing and then update in-memory metadata.

func (*PictureGroup) ReadMetadata

func (pg *PictureGroup) ReadMetadata(metaOrigin io.Reader) error

ReadMetadata will load metadata for a picture group from the passed io.Reader.

func (*PictureGroup) TraverseFileSystemPath

func (pg *PictureGroup) TraverseFileSystemPath() string

TraverseFileSystemPath returns the path of the current folder relative to the root of file system.

func (*PictureGroup) TraversePath

func (pg *PictureGroup) TraversePath() string

TraversePath returns the path of the current folder relative to the root album.

func (*PictureGroup) WriteMetadata

func (pg *PictureGroup) WriteMetadata(metaDestination io.Writer) error

WriteMetadata will write metadata for this picture group to the passed io.Writer.

type SinglePicture

type SinglePicture struct {
	Parent *PictureGroup `json:"-"`
	// Path the relative path to the picture represented.
	Path string `json:"path"`
	// FileName holds the name for this picture's file.
	FileName string `json:"file-name"`
	// Title is a given title for this picture.
	Title string `json:"title"`
	// Description is a description of this picture.
	Description string `json:"description"`
	// Visible indicates if this picture is displayed.
	Visible bool `json:"visible"`
	// Existing indicates wether the file we represent is present on disk.
	Existing bool `json:"existing"`
	// Accessible tells us if we can actually read the file (or our best guess)
	Accessible bool `json:"accessible"`
}

SinglePicture contains the information pertaining a one picture of a folder, if nothing else the path should be there.

func (*SinglePicture) FileSystemThumb

func (s *SinglePicture) FileSystemThumb(width, height uint) string

FileSystemThumb returns the file path of the thumb for this picture with the given size

func (*SinglePicture) RelativePath

func (s *SinglePicture) RelativePath() string

RelativePath returns this file's path relative to the root album.

func (*SinglePicture) ThumbName

func (s *SinglePicture) ThumbName(width, height uint) string

ThumbName returns the file name of the thumb for this picture with the given size

func (*SinglePicture) Thumbnail

func (s *SinglePicture) Thumbnail(width, height uint) (io.ReadCloser, error)

Thumbnail returns a ReadCloser pointing to the desired size's thumbnail, bear in mind that the thumbnail might be created if it does not exist. Caller must close thumbnail after use.

type ThumbSize

type ThumbSize struct {
	Width  uint `json:"width"`
	Height uint `json:"height"`
}

ThumbSize represents the size of a thumbnail image.

Jump to

Keyboard shortcuts

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