model

package
v0.0.0-...-a88b737 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2016 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(src, dst string) (err error)

http://stackoverflow.com/a/21067803 CopyFile copies a file from src to dst. If src and dst files exist, and are the same, then return success. Otherise, attempt to create a hard link between the two files. If that fail, copy the file contents from src to dst.

func StartDispatcher

func StartDispatcher(nworkers int, CacheInvalidation bool, WorkQueue chan File, log *log.Logger)

Dispatcher function to spawn a number of workers

func StartWorker

func StartWorker(CacheInvalidation bool, WorkQueue chan File, log *log.Logger)

Types

type ByDateTime

type ByDateTime []File

Sort files by DateTime

func (ByDateTime) Len

func (a ByDateTime) Len() int

func (ByDateTime) Less

func (a ByDateTime) Less(i, j int) bool

func (ByDateTime) Swap

func (a ByDateTime) Swap(i, j int)

type Context

type Context struct {
	TemplateBox *rice.Box
	StaticBox   *rice.Box
	Baseurl     string
	Log         *log.Logger
	WorkQueue   chan File
}

type File

type File struct {
	Filename        string    `json:"filename"`
	Tag             string    `json:"tag"`
	TagDir          string    `json:"-"`
	Bytes           int64     `json:"bytes"`
	BytesReadable   string    `json:"-"`
	MIME            string    `json:"mime"`
	CreatedReadable string    `json:"-"`
	CreatedAt       time.Time `json:"created"`
	Links           []Link    `json:"links"`
	Checksum        string    `json:"checksum,omitempty"`
	Algorithm       string    `json:"algorithm,omitempty"`
	Verified        bool      `json:"verified"`
	RemoteAddr      string    `json:"-"`
	UserAgent       string    `json:"-"`
	Tempfile        string    `json:"-"`

	// Image specific attributes
	DateTime         time.Time  `json:"datetime,omitempty"`
	DateTimeReadable string     `json:"-"`
	Longitude        float64    `json:"longitude,omitempty"`
	Latitude         float64    `json:"latitude,omitempty"`
	Altitude         string     `json:"altitude,omitempty"`
	Exif             *exif.Exif `json:"-"`
}

func (*File) ClearTemp

func (f *File) ClearTemp() error

func (*File) DateTimeString

func (f *File) DateTimeString() string

Return DateTime as a string. Useful in templates.

func (*File) DetectMIME

func (f *File) DetectMIME() error

func (*File) EnsureTagDirectoryExists

func (f *File) EnsureTagDirectoryExists() error

func (*File) Exists

func (f *File) Exists() bool

func (*File) GenerateImage

func (f *File) GenerateImage(width int, height int, crop bool) error
func (f *File) GenerateLinks(baseurl string)
func (f *File) GetLink(s string) string

Return the full URL from the links struct. Useful in templates.

func (*File) ImageExists

func (f *File) ImageExists(width int, height int) bool

func (*File) ImagePath

func (f *File) ImagePath(width int, height int) string

func (*File) MediaType

func (f *File) MediaType() string

func (*File) ParseExif

func (f *File) ParseExif() error

func (*File) Publish

func (f *File) Publish() error

func (*File) Purge

func (f *File) Purge() error

func (*File) Remove

func (f *File) Remove() error

func (*File) SetFilename

func (f *File) SetFilename(s string) error

func (*File) SetTag

func (f *File) SetTag(s string) error

func (*File) SetTagDir

func (f *File) SetTagDir(filedir string) error

func (*File) StatInfo

func (f *File) StatInfo() error

func (*File) VerifySHA256

func (f *File) VerifySHA256(s string) error

func (*File) WriteTempfile

func (f *File) WriteTempfile(d io.Reader, tempdir string) error
type Link struct {
	Rel  string
	Href string
}

type Tag

type Tag struct {
	Tag                string    `json:"tag"`
	TagDir             string    `json:"-"`
	ExpirationAt       time.Time `json:"-"`
	ExpirationReadable string    `json:"expiration"`
	Expired            bool      `json:"-"`
	LastUpdateAt       time.Time `json:"-"`
	LastUpdateReadable string    `json:"lastupdate"`
	Files              []File    `json:"files"`

	Album bool `json:"-"`
}

func (*Tag) CalculateExpiration

func (t *Tag) CalculateExpiration(expiration int64) error

func (*Tag) IsExpired

func (t *Tag) IsExpired(expiration int64) (bool, error)

func (*Tag) List

func (t *Tag) List(baseurl string) error

func (*Tag) Remove

func (t *Tag) Remove() error

func (*Tag) SetTag

func (t *Tag) SetTag(s string) error

func (*Tag) SetTagDir

func (t *Tag) SetTagDir(filedir string)

func (*Tag) StatInfo

func (t *Tag) StatInfo() error

func (*Tag) TagDirExists

func (t *Tag) TagDirExists() bool

Jump to

Keyboard shortcuts

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